3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 10:42:52 +01:00

flag socket as closed when writes fail

This commit is contained in:
Jeremy Latt 2014-02-23 17:16:35 -08:00
parent 0bf968e19e
commit 0856a9fa81

View File

@ -60,6 +60,7 @@ func (socket *Socket) readLines(commands chan<- Command) {
for {
line, err := socket.reader.ReadString('\n')
if socket.isError(err, R) {
socket.closed = true
break
}
line = strings.TrimRight(line, "\r\n")
@ -91,14 +92,17 @@ func (socket *Socket) Write(line string) (err error) {
return io.EOF
}
if _, err = socket.writer.WriteString(line); socket.isError(err, W) {
socket.closed = true
return
}
if _, err = socket.writer.WriteString(CRLF); socket.isError(err, W) {
socket.closed = true
return
}
if err = socket.writer.Flush(); socket.isError(err, W) {
socket.closed = true
return
}