Small tidy up and fixed potential disconnect bug
This commit is contained in:
parent
4552684f01
commit
0383fcab8b
@ -230,7 +230,6 @@ func (s *Server) handleEvent(e Event) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//Stop the client, which will auto part channels and quit
|
|
||||||
e.client.disconnect()
|
e.client.disconnect()
|
||||||
|
|
||||||
case command == "TOPIC":
|
case command == "TOPIC":
|
||||||
@ -365,7 +364,6 @@ func (c *Client) clientThread() {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case signal := <-c.signalChan:
|
case signal := <-c.signalChan:
|
||||||
//Do stuff
|
|
||||||
if signal == signalStop {
|
if signal == signalStop {
|
||||||
readSignalChan <- signalStop
|
readSignalChan <- signalStop
|
||||||
writeSignalChan <- signalStop
|
writeSignalChan <- signalStop
|
||||||
@ -404,8 +402,7 @@ func (c *Client) readThread(signalChan chan int) {
|
|||||||
ln, err := c.connection.Read(buf)
|
ln, err := c.connection.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
//They must have dc'd
|
c.disconnect()
|
||||||
c.signalChan <- signalStop
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@ -435,8 +432,7 @@ func (c *Client) writeThread(signalChan chan int, outputChan chan string) {
|
|||||||
c.connection.SetWriteDeadline(time.Now().Add(time.Second * 30))
|
c.connection.SetWriteDeadline(time.Now().Add(time.Second * 30))
|
||||||
_, err := c.connection.Write(line)
|
_, err := c.connection.Write(line)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Write err: %q", err.Error())
|
c.disconnect()
|
||||||
c.signalChan <- signalStop
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user