Blob Blame History Raw
diff --git a/nsock/src/nsock_core.c b/nsock/src/nsock_core.c
index ec38cad..aac2c1b 100644
--- a/nsock/src/nsock_core.c
+++ b/nsock/src/nsock_core.c
@@ -1230,6 +1230,14 @@ void nsp_add_event(mspool *nsp, msevent *nse) {
       assert(0);
       break; /* unreached */
   }
+
+  /* It can happen that the event already completed. In which case we can
+   *    * already deliver it, even though we're probably not inside nsock_loop(). */
+  if (nse->event_done) {
+	  msevent_dispatch_and_delete(nsp, nse, 1);
+	  update_first_events(nse);
+	   
+  }
 }
 
 /* An event has been completed and the handler is about to be called. This