Clean-ups
[invirt/third/libt4.git] / rpc / rpc.cc
index 5d28f8f..e6ec410 100644 (file)
@@ -81,6 +81,8 @@ rpcc::rpcc(const string & d) : dst_(make_sockaddr(d))
 rpcc::~rpcc() {
     lock ml(m_);
     cancel(ml);
 rpcc::~rpcc() {
     lock ml(m_);
     cancel(ml);
+
+    lock cl(chan_m_);
     IF_LEVEL(2) LOG << "delete nonce " << clt_nonce_ << " chan " << (chan_?(int)chan_->fd:-1);
     chan_.reset();
     VERIFY(calls_.size() == 0);
     IF_LEVEL(2) LOG << "delete nonce " << clt_nonce_ << " chan " << (chan_?(int)chan_->fd:-1);
     chan_.reset();
     VERIFY(calls_.size() == 0);
@@ -254,7 +256,7 @@ int rpcc::call1(proc_id_t proc, milliseconds to, string & rep, marshall & req) {
                     << ntoh(dst_.sin_port) << " done? " << ca.done << " ret " << ca.intret;
 
     // destruction of req automatically frees its buffer
                     << ntoh(dst_.sin_port) << " done? " << ca.done << " ret " << ca.intret;
 
     // destruction of req automatically frees its buffer
-    return (ca.done? ca.intret : rpc_protocol::timeout_failure);
+    return ca.done ? ca.intret : rpc_protocol::timeout_failure;
 }
 
 void rpcc::get_latest_connection(shared_ptr<connection> & ch) {
 }
 
 void rpcc::get_latest_connection(shared_ptr<connection> & ch) {
@@ -266,14 +268,9 @@ void rpcc::get_latest_connection(shared_ptr<connection> & ch) {
         ch = chan_;
 }
 
         ch = chan_;
 }
 
-// PollMgr's thread is being used to
-// make this upcall from connection object to rpcc.
-// this funtion must not block.
-//
-// this function keeps no reference for connection *c
-bool
-rpcc::got_pdu(const shared_ptr<connection> &, const string & b)
-{
+// Runs in poll_mgr's thread as an upcall from the connection object to the
+// rpcc.  Does not call blocking RPC handlers.
+bool rpcc::got_pdu(const shared_ptr<connection> &, const string & b) {
     unmarshall rep(b, true);
     rpc_protocol::reply_header h;
     rep.read_header(h);
     unmarshall rep(b, true);
     rpc_protocol::reply_header h;
     rep.read_header(h);