Includes cleanups
[invirt/third/libt4.git] / rpc / rpc.h
index 19ec96a..02c7c62 100644 (file)
--- a/rpc/rpc.h
+++ b/rpc/rpc.h
@@ -45,7 +45,7 @@ class rpcc : public chanmgr {
             cond c;
         };
 
-        void get_refconn(connection **ch);
+        void get_refconn(shared_ptr<connection> & ch);
         void update_xid_rep(int xid);
 
 
@@ -58,7 +58,7 @@ class rpcc : public chanmgr {
         bool retrans_;
         bool reachable_;
 
-        connection *chan_;
+        shared_ptr<connection> chan_;
 
         mutex m_; // protect insert/delete to calls[]
         mutex chan_m_;
@@ -95,7 +95,7 @@ class rpcc : public chanmgr {
 
         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);
@@ -175,7 +175,7 @@ class rpcs : public chanmgr {
     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_;
@@ -195,17 +195,13 @@ class rpcs : public chanmgr {
 
     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 *);
 
-    ThrPool* dispatchpool_;
-    tcpsconn *listener_;
+    unique_ptr<ThrPool> dispatchpool_;
+    unique_ptr<tcpsconn> listener_;
 
     public:
     rpcs(in_port_t port, size_t counts=0);
@@ -216,7 +212,7 @@ class rpcs : public chanmgr {
 
     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() {
@@ -227,6 +223,8 @@ class rpcs : public chanmgr {
     template<class F, class C=void> void reg(proc_t proc, F f, C *c=nullptr) {
         reg1(proc, marshalled_func<F, ReturnOnFailure>::wrap(f, c));
     }
+
+    void start();
 };
 
 #endif