Fix disconnect in process handling.

This commit is contained in:
cheatfate 2018-07-24 18:43:30 +03:00
parent 40bfc25ea3
commit 216fd7b744
1 changed files with 7 additions and 5 deletions

View File

@ -309,7 +309,7 @@ when defined(windows):
elif int(err) == ERROR_OPERATION_ABORTED: elif int(err) == ERROR_OPERATION_ABORTED:
# CancelIO() interrupt # CancelIO() interrupt
transp.state.incl(ReadPaused) transp.state.incl(ReadPaused)
elif int(err) == ERROR_NETNAME_DELETED: elif int(err) in {ERROR_NETNAME_DELETED, WSAECONNABORTED}:
transp.state.incl({ReadEof, ReadPaused}) transp.state.incl({ReadEof, ReadPaused})
else: else:
transp.setReadError(err) transp.setReadError(err)
@ -340,9 +340,10 @@ when defined(windows):
# CancelIO() interrupt # CancelIO() interrupt
transp.state.excl(ReadPending) transp.state.excl(ReadPending)
transp.state.incl(ReadPaused) transp.state.incl(ReadPaused)
elif int32(err) in {WSAECONNRESET, WSAENETRESET}: elif int32(err) in {WSAECONNRESET, WSAENETRESET, WSAECONNABORTED}:
transp.state.excl(ReadPending)
transp.state.incl({ReadEof, ReadPaused})
if not isNil(transp.reader): if not isNil(transp.reader):
transp.state = {ReadEof, ReadPaused}
transp.reader.complete() transp.reader.complete()
transp.reader = nil transp.reader = nil
elif int32(err) != ERROR_IO_PENDING: elif int32(err) != ERROR_IO_PENDING:
@ -613,13 +614,13 @@ else:
if int(err) == EINTR: if int(err) == EINTR:
continue continue
elif int(err) in {ECONNRESET}: elif int(err) in {ECONNRESET}:
transp.state = transp.state + {ReadEof, ReadPaused} transp.state.incl({ReadEof, ReadPaused})
cdata.fd.removeReader() cdata.fd.removeReader()
else: else:
transp.setReadError(err) transp.setReadError(err)
cdata.fd.removeReader() cdata.fd.removeReader()
elif res == 0: elif res == 0:
transp.state = transp.state + {ReadEof, ReadPaused} transp.state.incl({ReadEof, ReadPaused})
cdata.fd.removeReader() cdata.fd.removeReader()
else: else:
transp.offset += res transp.offset += res
@ -943,6 +944,7 @@ proc readExactly*(transp: StreamTransport, pbytes: pointer,
## will raise ``TransportIncompleteError``. ## will raise ``TransportIncompleteError``.
checkClosed(transp) checkClosed(transp)
checkPending(transp) checkPending(transp)
var index = 0 var index = 0
while true: while true:
if transp.offset == 0: if transp.offset == 0: