summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2012-02-21 15:02:39 +0530
committerVijay Bellur <vijay@gluster.com>2012-02-21 01:42:42 -0800
commitbca46fd46b1a1a28daeb9ea3f47cef9bbacecd6d (patch)
tree161737d7de86c7310c5cba84900b64867005e740 /rpc
parent7197111677619da96c80572a09331d6e28c1015b (diff)
rpc/clnt: handle PARENT_DOWN event appropriately
Change-Id: I4644e944bad4d240d16de47786b9fa277333dba4 BUG: 767862 Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Amar Tumballi <amarts@redhat.com> Reviewed-on: http://review.gluster.com/2735 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'rpc')
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.c71
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.h5
-rw-r--r--rpc/rpc-lib/src/rpc-transport.c14
-rw-r--r--rpc/rpc-lib/src/rpc-transport.h3
4 files changed, 82 insertions, 11 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index ec73631d484..b2b20ea3103 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -554,6 +554,12 @@ rpc_clnt_connection_cleanup (rpc_clnt_connection_t *conn)
}
conn->connected = 0;
+
+ if (conn->ping_timer) {
+ gf_timer_call_cancel (clnt->ctx, conn->ping_timer);
+ conn->ping_timer = NULL;
+ conn->ping_started = 0;
+ }
}
pthread_mutex_unlock (&conn->lock);
@@ -842,12 +848,12 @@ int
rpc_clnt_notify (rpc_transport_t *trans, void *mydata,
rpc_transport_event_t event, void *data, ...)
{
- rpc_clnt_connection_t *conn = NULL;
- struct rpc_clnt *clnt = NULL;
- int ret = -1;
- rpc_request_info_t *req_info = NULL;
- rpc_transport_pollin_t *pollin = NULL;
- struct timeval tv = {0, };
+ rpc_clnt_connection_t *conn = NULL;
+ struct rpc_clnt *clnt = NULL;
+ int ret = -1;
+ rpc_request_info_t *req_info = NULL;
+ rpc_transport_pollin_t *pollin = NULL;
+ struct timeval tv = {0, };
conn = mydata;
if (conn == NULL) {
@@ -864,7 +870,8 @@ rpc_clnt_notify (rpc_transport_t *trans, void *mydata,
pthread_mutex_lock (&conn->lock);
{
- if (conn->reconnect == NULL) {
+ if (!conn->rpc_clnt->disabled
+ && (conn->reconnect == NULL)) {
tv.tv_sec = 10;
conn->reconnect =
@@ -1412,6 +1419,12 @@ rpc_clnt_submit (struct rpc_clnt *rpc, rpc_clnt_prog_t *prog,
goto out;
}
+ conn = &rpc->conn;
+
+ if (conn->trans == NULL) {
+ goto out;
+ }
+
rpcreq = mem_get (rpc->reqpool);
if (rpcreq == NULL) {
goto out;
@@ -1431,8 +1444,6 @@ rpc_clnt_submit (struct rpc_clnt *rpc, rpc_clnt_prog_t *prog,
callid = rpc_clnt_new_callid (rpc);
- conn = &rpc->conn;
-
rpcreq->prog = prog;
rpcreq->procnum = procnum;
rpcreq->conn = conn;
@@ -1554,9 +1565,9 @@ rpc_clnt_destroy (struct rpc_clnt *rpc)
return;
if (rpc->conn.trans) {
- rpc->conn.trans->mydata = NULL;
+ rpc_transport_unregister_notify (rpc->conn.trans);
+ rpc_transport_disconnect (rpc->conn.trans);
rpc_transport_unref (rpc->conn.trans);
- //rpc_transport_destroy (rpc->conn.trans);
}
rpc_clnt_connection_cleanup (&rpc->conn);
@@ -1595,6 +1606,44 @@ rpc_clnt_unref (struct rpc_clnt *rpc)
void
+rpc_clnt_disable (struct rpc_clnt *rpc)
+{
+ rpc_clnt_connection_t *conn = NULL;
+
+ if (!rpc) {
+ goto out;
+ }
+
+ conn = &rpc->conn;
+
+ pthread_mutex_lock (&conn->lock);
+ {
+ rpc->disabled = 1;
+
+ if (conn->timer) {
+ gf_timer_call_cancel (rpc->ctx, conn->timer);
+ conn->timer = 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;
+ }
+
+ }
+ pthread_mutex_unlock (&conn->lock);
+
+ rpc_transport_disconnect (rpc->conn.trans);
+
+out:
+ return;
+}
+
+
+void
rpc_clnt_reconfig (struct rpc_clnt *rpc, struct rpc_clnt_config *config)
{
if (config->rpc_timeout) {
diff --git a/rpc/rpc-lib/src/rpc-clnt.h b/rpc/rpc-lib/src/rpc-clnt.h
index dcd926da93f..4fce0854604 100644
--- a/rpc/rpc-lib/src/rpc-clnt.h
+++ b/rpc/rpc-lib/src/rpc-clnt.h
@@ -187,6 +187,7 @@ typedef struct rpc_clnt {
glusterfs_ctx_t *ctx;
int refcount;
int auth_null;
+ char disabled;
} rpc_clnt_t;
@@ -242,4 +243,8 @@ int rpcclnt_cbk_program_register (struct rpc_clnt *svc,
int
rpc_clnt_transport_unix_options_build (dict_t **options, char *filepath);
+
+void
+rpc_clnt_disable (struct rpc_clnt *rpc);
+
#endif /* !_RPC_CLNT_H */
diff --git a/rpc/rpc-lib/src/rpc-transport.c b/rpc/rpc-lib/src/rpc-transport.c
index b97ba61bf2b..8a3b839c497 100644
--- a/rpc/rpc-lib/src/rpc-transport.c
+++ b/rpc/rpc-lib/src/rpc-transport.c
@@ -520,6 +520,20 @@ out:
return ret;
}
+
+inline int
+rpc_transport_unregister_notify (rpc_transport_t *trans)
+{
+ GF_VALIDATE_OR_GOTO ("rpc-transport", trans, out);
+
+ trans->notify = NULL;
+ trans->mydata = NULL;
+
+out:
+ return 0;
+}
+
+
//give negative values to skip setting that value
//this function asserts if both the values are negative.
//why call it if you dont set it.
diff --git a/rpc/rpc-lib/src/rpc-transport.h b/rpc/rpc-lib/src/rpc-transport.h
index f838d4baf2c..16e061a5988 100644
--- a/rpc/rpc-lib/src/rpc-transport.h
+++ b/rpc/rpc-lib/src/rpc-transport.h
@@ -276,6 +276,9 @@ int
rpc_transport_register_notify (rpc_transport_t *trans, rpc_transport_notify_t,
void *mydata);
+int
+rpc_transport_unregister_notify (rpc_transport_t *trans);
+
int32_t
rpc_transport_get_peername (rpc_transport_t *this, char *hostname, int hostlen);