From: Prashanth Mundkur Date: Tue, 30 Jun 2009 22:38:42 +0000 (-0700) Subject: [eventloop] check watches on registration and connection completion. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=3a3261ded764b6c8819f78efa644ee9e81337c46;p=xenclient%2Ftoolstack.git [eventloop] check watches on registration and connection completion. --- diff --git a/libs/stdext/eventloop.ml b/libs/stdext/eventloop.ml index b4337fe..b514fa9 100644 --- a/libs/stdext/eventloop.ml +++ b/libs/stdext/eventloop.ml @@ -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", "")