Explicit refcounting removed from connection object
[invirt/third/libt4.git] / rpc / rpc.h
index 19ec96a..9ec2fd8 100644 (file)
--- a/rpc/rpc.h
+++ b/rpc/rpc.h
@@ -45,7 +45,7 @@ class rpcc : public chanmgr {
             cond c;
         };
 
             cond c;
         };
 
-        void get_refconn(connection **ch);
+        void get_refconn(shared_ptr<connection> & ch);
         void update_xid_rep(int xid);
 
 
         void update_xid_rep(int xid);
 
 
@@ -58,7 +58,7 @@ class rpcc : public chanmgr {
         bool retrans_;
         bool reachable_;
 
         bool retrans_;
         bool reachable_;
 
-        connection *chan_;
+        shared_ptr<connection> chan_;
 
         mutex m_; // protect insert/delete to calls[]
         mutex chan_m_;
 
         mutex m_; // protect insert/delete to calls[]
         mutex chan_m_;
@@ -95,7 +95,7 @@ class rpcc : public chanmgr {
 
         void cancel();
 
 
         void cancel();
 
-        bool got_pdu(connection *c, const string & b);
+        bool got_pdu(const shared_ptr<connection> & c, const string & b);
 
         template<class R, typename ...Args>
             inline int call(proc_t proc, R & r, const Args&... args);
 
         template<class R, typename ...Args>
             inline int call(proc_t proc, R & r, const Args&... args);
@@ -175,7 +175,7 @@ class rpcs : public chanmgr {
     void updatestat(proc_t proc);
 
     // latest connection to the client
     void updatestat(proc_t proc);
 
     // latest connection to the client
-    map<unsigned int, connection *> conns_;
+    map<unsigned int, shared_ptr<connection>> conns_;
 
     // counting
     const size_t counting_;
 
     // counting
     const size_t counting_;
@@ -195,11 +195,7 @@ class rpcs : public chanmgr {
 
     protected:
 
 
     protected:
 
-    struct djob_t {
-        connection *conn;
-        string buf;
-    };
-    void dispatch(djob_t *);
+    void dispatch(shared_ptr<connection> c, const string & buf);
 
     // internal handler registration
     void reg1(proc_t proc, handler *);
 
     // internal handler registration
     void reg1(proc_t proc, handler *);
@@ -216,7 +212,7 @@ class rpcs : public chanmgr {
 
     void set_reachable(bool r) { reachable_ = r; }
 
 
     void set_reachable(bool r) { reachable_ = r; }
 
-    bool got_pdu(connection *c, const string & b);
+    bool got_pdu(const shared_ptr<connection> & c, const string & b);
 
     struct ReturnOnFailure {
         static inline int unmarshall_args_failure() {
 
     struct ReturnOnFailure {
         static inline int unmarshall_args_failure() {