diff options
Diffstat (limited to 'rpc/rpc-lib')
| -rw-r--r-- | rpc/rpc-lib/src/rpc-clnt.c | 41 | ||||
| -rw-r--r-- | rpc/rpc-lib/src/rpc-clnt.h | 3 | 
2 files changed, 44 insertions, 0 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c index 4c8333b7d5d..20981ef9c9c 100644 --- a/rpc/rpc-lib/src/rpc-clnt.c +++ b/rpc/rpc-lib/src/rpc-clnt.c @@ -1744,6 +1744,47 @@ out:          return;  } +void +rpc_clnt_disconnect (struct rpc_clnt *rpc) +{ +        rpc_clnt_connection_t *conn  = NULL; +        rpc_transport_t       *trans = NULL; + +        if (!rpc) +                goto out; + +        conn = &rpc->conn; + +        pthread_mutex_lock (&conn->lock); +        { +                if (conn->timer) { +                        gf_timer_call_cancel (rpc->ctx, conn->timer); +                        conn->timer = NULL; +                } + +                if (conn->reconnect) { +                        gf_timer_call_cancel (rpc->ctx, conn->reconnect); +                        conn->reconnect = NULL; +                } +                conn->connected = 0; + +                if (conn->ping_timer) { +                        gf_timer_call_cancel (rpc->ctx, conn->ping_timer); +                        conn->ping_timer = NULL; +                        conn->ping_started = 0; +                } +                trans = conn->trans; +        } +        pthread_mutex_unlock (&conn->lock); + +        if (trans) { +                rpc_transport_disconnect (trans); +        } + +out: +        return; +} +  void  rpc_clnt_reconfig (struct rpc_clnt *rpc, struct rpc_clnt_config *config) diff --git a/rpc/rpc-lib/src/rpc-clnt.h b/rpc/rpc-lib/src/rpc-clnt.h index 6492a81f24e..faae4855a6c 100644 --- a/rpc/rpc-lib/src/rpc-clnt.h +++ b/rpc/rpc-lib/src/rpc-clnt.h @@ -244,6 +244,9 @@ int rpcclnt_cbk_program_register (struct rpc_clnt *svc,  void  rpc_clnt_disable (struct rpc_clnt *rpc); +void +rpc_clnt_disconnect (struct rpc_clnt *rpc); +  char  rpc_clnt_is_disabled (struct rpc_clnt *rpc);  | 
