mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
flag socket as closed when writes fail
This commit is contained in:
parent
0bf968e19e
commit
0856a9fa81
@ -60,6 +60,7 @@ func (socket *Socket) readLines(commands chan<- Command) {
|
|||||||
for {
|
for {
|
||||||
line, err := socket.reader.ReadString('\n')
|
line, err := socket.reader.ReadString('\n')
|
||||||
if socket.isError(err, R) {
|
if socket.isError(err, R) {
|
||||||
|
socket.closed = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
line = strings.TrimRight(line, "\r\n")
|
line = strings.TrimRight(line, "\r\n")
|
||||||
@ -91,14 +92,17 @@ func (socket *Socket) Write(line string) (err error) {
|
|||||||
return io.EOF
|
return io.EOF
|
||||||
}
|
}
|
||||||
if _, err = socket.writer.WriteString(line); socket.isError(err, W) {
|
if _, err = socket.writer.WriteString(line); socket.isError(err, W) {
|
||||||
|
socket.closed = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = socket.writer.WriteString(CRLF); socket.isError(err, W) {
|
if _, err = socket.writer.WriteString(CRLF); socket.isError(err, W) {
|
||||||
|
socket.closed = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = socket.writer.Flush(); socket.isError(err, W) {
|
if err = socket.writer.Flush(); socket.isError(err, W) {
|
||||||
|
socket.closed = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user