]> xenbits.xensource.com Git - xenclient/toolstack.git/commitdiff
[eventloop] check watches on registration and connection completion.
authorPrashanth Mundkur <prashanth.mundkur@citrix.com>
Tue, 30 Jun 2009 22:38:42 +0000 (15:38 -0700)
committerPrashanth Mundkur <prashanth.mundkur@citrix.com>
Tue, 30 Jun 2009 22:45:11 +0000 (15:45 -0700)
libs/stdext/eventloop.ml

index b4337fe86a25dfb7087ab98ec7fa8603c1600bb2..b514fa9e3a5bf33a7e28023d52fd95239f8930ee 100644 (file)
@@ -155,6 +155,8 @@ let register_conn t fd ?(enable_send=false) ?(enable_recv=true) callbacks =
        Unix.set_nonblock fd;
        if conn_state.recv_enabled then
                Unixext.Fdset.set t.readers fd;
+       if conn_state.send_enabled then
+               Unixext.Fdset.set t.writers fd;
        fd
 
 let remove_conn t handle =
@@ -256,6 +258,8 @@ let dispatch_read t fd cs =
                        cs.status <- Connected;
                        if not cs.recv_enabled then
                                Unixext.Fdset.clear t.readers fd;
+                       if not cs.send_enabled then
+                               Unixext.Fdset.clear t.writers fd;
                        cs.callbacks.connect_callback t fd
                | Some err ->
                        cs.callbacks.error_callback t fd (err, "connect", "")
@@ -283,10 +287,10 @@ let dispatch_write t fd cs =
                (match Unix.getsockopt_error fd with
                | None ->
                        cs.status <- Connected;
-                       if cs.recv_enabled then
-                               Unixext.Fdset.set t.readers fd
-                       else
+                       if not cs.recv_enabled then
                                Unixext.Fdset.clear t.readers fd;
+                       if not cs.send_enabled then
+                               Unixext.Fdset.clear t.writers fd;
                        cs.callbacks.connect_callback t fd
                | Some err ->
                        cs.callbacks.error_callback t fd (err, "connect", "")