summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorcheatfate <ka@hardcore.kiev.ua>2016-10-16 04:03:45 +0300
committercheatfate <ka@hardcore.kiev.ua>2016-10-16 04:03:45 +0300
commit0ff7fbea34cde649ac085c7c6da6a0e61bfd873b (patch)
tree61f1b975bb7c74fed554fcb7e4a0ac81f0ad86a3 /lib
parent2d2b1a9d481bffaecac35e1e52929cea66f69e0e (diff)
downloadNim-0ff7fbea34cde649ac085c7c6da6a0e61bfd873b.tar.gz
Fix handle of error only events.
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/asyncdispatch.nim4
-rw-r--r--lib/upcoming/asyncdispatch.nim24
2 files changed, 14 insertions, 14 deletions
diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim
index 8336da1fb..f575a7529 100644
--- a/lib/pure/asyncdispatch.nim
+++ b/lib/pure/asyncdispatch.nim
@@ -1055,7 +1055,7 @@ else:
         # so that exceptions can be raised from `send(...)` and
         # `recv(...)` routines.
 
-        if EvRead in info.events:
+        if EvRead in info.events or info.events == {EvError}:
           # Callback may add items to ``data.readCBs`` which causes issues if
           # we are iterating over ``data.readCBs`` at the same time. We therefore
           # make a copy to iterate over.
@@ -1066,7 +1066,7 @@ else:
               # Callback wants to be called again.
               data.readCBs.add(cb)
 
-        if EvWrite in info.events:
+        if EvWrite in info.events or info.events == {EvError}:
           let currentCBs = data.writeCBs
           data.writeCBs = @[]
           for cb in currentCBs:
diff --git a/lib/upcoming/asyncdispatch.nim b/lib/upcoming/asyncdispatch.nim
index 29b955c46..731ef52dc 100644
--- a/lib/upcoming/asyncdispatch.nim
+++ b/lib/upcoming/asyncdispatch.nim
@@ -1194,21 +1194,21 @@ else:
         var fd = keys[i].fd.SocketHandle
         let events = keys[i].events
 
-        if Event.Read in events:
+        if Event.Read in events or events == {Event.Error}:
           let cb = keys[i].data.readCB
-          doAssert(cb != nil)
-          if cb(fd.AsyncFD):
-            p.selector.withData(fd, adata) do:
-              if adata.readCB == cb:
-                adata.readCB = nil
+          if cb != nil:
+            if cb(fd.AsyncFD):
+              p.selector.withData(fd, adata) do:
+                if adata.readCB == cb:
+                  adata.readCB = nil
 
-        if Event.Write in events:
+        if Event.Write in events or events == {Event.Error}:
           let cb = keys[i].data.writeCB
-          doAssert(cb != nil)
-          if cb(fd.AsyncFD):
-            p.selector.withData(fd, adata) do:
-              if adata.writeCB == cb:
-                adata.writeCB = nil
+          if cb != nil:
+            if cb(fd.AsyncFD):
+              p.selector.withData(fd, adata) do:
+                if adata.writeCB == cb:
+                  adata.writeCB = nil
 
         when supportedPlatform:
           if (customSet * events) != {}: