diff options
author | bptato <nincsnevem662@gmail.com> | 2024-02-08 17:46:40 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-02-08 18:01:46 +0100 |
commit | 761a69376aec86076669e8de7d9c57be4dea3896 (patch) | |
tree | 2d0f0e1798951e7939ae31940ea22e0072b95c13 /src | |
parent | bb67136fd92e1bf777f51816bdb73ff0a0001f4c (diff) | |
download | chawan-761a69376aec86076669e8de7d9c57be4dea3896.tar.gz |
loader: fix double-close bugs
Diffstat (limited to 'src')
-rw-r--r-- | src/loader/loader.nim | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/loader/loader.nim b/src/loader/loader.nim index ada37648..71aca5ad 100644 --- a/src/loader/loader.nim +++ b/src/loader/loader.nim @@ -323,8 +323,9 @@ proc runFileLoader*(fd: cint, config: LoaderConfig) = if Error in event.events: assert event.fd != ctx.fd let handle = ctx.handleMap[event.fd] - if handle.fd == event.fd: # ostream died - unregWrite.add(handle) + if handle.fd == event.fd: + if unregWrite.len == 0 or unregWrite[^1] != handle: # ostream died + unregWrite.add(handle) else: # istream died unregRead.add(handle) for handle in unregRead: @@ -341,7 +342,6 @@ proc runFileLoader*(fd: cint, config: LoaderConfig) = handle.ostream.close() handle.ostream = nil if handle.istream != nil: - handle.istream.close() ctx.handleMap.del(handle.istream.fd) ctx.selector.unregister(handle.istream.fd) handle.istream.close() |