summary refs log tree commit diff stats
path: root/lib/upcoming
diff options
context:
space:
mode:
authorRuslan Mustakov <r.mustakov@gmail.com>2016-09-02 19:15:59 +0700
committerRuslan Mustakov <r.mustakov@gmail.com>2016-09-02 19:15:59 +0700
commitb676a08b3a4632d80bf46cb57d8e72ddf3398b39 (patch)
treef63e846b85b4fcf6468e91d5c6fbe739eccb600f /lib/upcoming
parent0848e9dc0b0f5a54b3788eddfc5137cf73f283c9 (diff)
downloadNim-b676a08b3a4632d80bf46cb57d8e72ddf3398b39.tar.gz
Async read/write procedures no longer replace each other in upcoming asyncdispatch
Diffstat (limited to 'lib/upcoming')
-rw-r--r--lib/upcoming/asyncdispatch.nim10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/upcoming/asyncdispatch.nim b/lib/upcoming/asyncdispatch.nim
index 19c9815d2..3c11e082f 100644
--- a/lib/upcoming/asyncdispatch.nim
+++ b/lib/upcoming/asyncdispatch.nim
@@ -1368,19 +1368,25 @@ else:
 
   proc addRead*(fd: AsyncFD, cb: Callback) =
     let p = getGlobalDispatcher()
+    var newEvents = {Event.Read}
     withData(p.selector, fd.SocketHandle, adata) do:
       adata.readCB = cb
+      if adata.writeCB != nil:
+        newEvents.incl(Event.Write)
     do:
       raise newException(ValueError, "File descriptor not registered.")
-    p.selector.updateHandle(fd.SocketHandle, {Event.Read})
+    p.selector.updateHandle(fd.SocketHandle, newEvents)
 
   proc addWrite*(fd: AsyncFD, cb: Callback) =
     let p = getGlobalDispatcher()
+    var newEvents = {Event.Write}
     withData(p.selector, fd.SocketHandle, adata) do:
       adata.writeCB = cb
+      if adata.readCB != nil:
+        newEvents.incl(Event.Read)
     do:
       raise newException(ValueError, "File descriptor not registered.")
-    p.selector.updateHandle(fd.SocketHandle, {Event.Write})
+    p.selector.updateHandle(fd.SocketHandle, newEvents)
 
   proc poll*(timeout = 500) =
     var keys: array[64, ReadyKey[AsyncData]]