Rolled handle infrastructure into rpcc.
[invirt/third/libt4.git] / rpc / connection.cc
index c7e8f95..31ec5fa 100644 (file)
@@ -15,7 +15,7 @@ connection::connection(connection_delegate * delegate, socket_t && f1, int l1)
 
     signal(SIGPIPE, SIG_IGN);
 
-    poll_mgr::shared_mgr.add_callback(fd, CB_RDONLY, this);
+    global->shared_mgr.add_callback(fd, CB_RDONLY, this);
 }
 
 connection::~connection() {
@@ -28,7 +28,7 @@ connection::~connection() {
     }
     // after block_remove_fd, select will never wait on fd and no callbacks
     // will be active
-    poll_mgr::shared_mgr.block_remove_fd(fd);
+    global->shared_mgr.block_remove_fd(fd);
     VERIFY(dead_);
     VERIFY(wpdu_.status == unused);
 }
@@ -64,11 +64,11 @@ bool connection::send(const string & b) {
     if (!writepdu()) {
         dead_ = true;
         ml.unlock();
-        poll_mgr::shared_mgr.block_remove_fd(fd);
+        global->shared_mgr.block_remove_fd(fd);
         ml.lock();
     } else if (wpdu_.status == inflight && wpdu_.cursor < b.size()) {
         // should be rare to need to explicitly add write callback
-        poll_mgr::shared_mgr.add_callback(fd, CB_WRONLY, this);
+        global->shared_mgr.add_callback(fd, CB_WRONLY, this);
         while (!dead_ && wpdu_.status == inflight && wpdu_.cursor < b.size())
             send_complete_.wait(ml);
     }
@@ -84,11 +84,11 @@ void connection::write_cb(int s) {
     VERIFY(!dead_);
     VERIFY(fd == s);
     if (wpdu_.status != inflight) {
-        poll_mgr::shared_mgr.del_callback(fd, CB_WRONLY);
+        global->shared_mgr.del_callback(fd, CB_WRONLY);
         return;
     }
     if (!writepdu()) {
-        poll_mgr::shared_mgr.del_callback(fd, CB_RDWR);
+        global->shared_mgr.del_callback(fd, CB_RDWR);
         dead_ = true;
     } else {
         VERIFY(wpdu_.status != error);
@@ -127,7 +127,7 @@ void connection::read_cb(int s) {
     if (rpdu_.status == unused || rpdu_.cursor < rpdu_.buf.size()) {
         if (!readpdu()) {
             IF_LEVEL(5) LOG << "readpdu on fd " << s << " failed; dying";
-            poll_mgr::shared_mgr.del_callback(fd, CB_RDWR);
+            global->shared_mgr.del_callback(fd, CB_RDWR);
             dead_ = true;
             send_complete_.notify_one();
         }
@@ -214,11 +214,11 @@ connection_listener::connection_listener(connection_delegate * delegate, in_port
 
     IF_LEVEL(2) LOG << "listen on " << port_ << " " << sin.sin_port;
 
-    poll_mgr::shared_mgr.add_callback(tcp_, CB_RDONLY, this);
+    global->shared_mgr.add_callback(tcp_, CB_RDONLY, this);
 }
 
 connection_listener::~connection_listener() {
-    poll_mgr::shared_mgr.block_remove_fd(tcp_);
+    global->shared_mgr.block_remove_fd(tcp_);
 }
 
 void connection_listener::read_cb(int) {