about summary refs log tree commit diff stats
path: root/src/loader
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-14 21:59:25 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-14 21:59:25 +0100
commit515f896ae2182595876ae6510c7af3651605fab5 (patch)
treef403eadaa9df39c7987aae448c57f585e96fe5d3 /src/loader
parentfefdfbaa68762f9f154b00f54b99e14e259160b5 (diff)
downloadchawan-515f896ae2182595876ae6510c7af3651605fab5.tar.gz
loader: handle connections where pid/key does not match
This can easily happen if a buffer process is killed and/or a new
process takes its ID.
Diffstat (limited to 'src/loader')
-rw-r--r--src/loader/loader.nim9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/loader/loader.nim b/src/loader/loader.nim
index 135a8c96..1dd34bc6 100644
--- a/src/loader/loader.nim
+++ b/src/loader/loader.nim
@@ -576,8 +576,15 @@ proc acceptConnection(ctx: LoaderContext) =
     var key: ClientKey
     stream.sread(myPid)
     stream.sread(key)
+    if myPid notin ctx.clientData:
+      # possibly already removed
+      stream.close()
+      return
     let client = ctx.clientData[myPid]
-    doAssert client.key == key
+    if client.key != key:
+      # ditto
+      stream.close()
+      return
     var cmd: LoaderCommand
     stream.sread(cmd)
     template privileged_command =