Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc: Improve rpc clnt connection cleanup process #4329

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 11 additions & 19 deletions rpc/rpc-lib/src/rpc-clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ int
rpc_clnt_reconnect_cleanup(rpc_clnt_connection_t *conn)
{
struct rpc_clnt *clnt = NULL;
int ret = 0;
gf_boolean_t reconnect_unref = _gf_false;

if (!conn) {
Expand All @@ -441,11 +440,9 @@ rpc_clnt_reconnect_cleanup(rpc_clnt_connection_t *conn)
pthread_mutex_lock(&conn->lock);
{
if (conn->reconnect) {
ret = gf_timer_call_cancel(clnt->ctx, conn->reconnect);
if (!ret) {
reconnect_unref = _gf_true;
conn->cleanup_gen++;
}
gf_timer_call_cancel(clnt->ctx, conn->reconnect);
conn->cleanup_gen++;
reconnect_unref = _gf_true;
conn->reconnect = NULL;
}
}
Expand All @@ -469,7 +466,6 @@ rpc_clnt_connection_cleanup(rpc_clnt_connection_t *conn)
struct saved_frames *saved_frames = NULL;
struct rpc_clnt *clnt = NULL;
int unref = 0;
int ret = 0;
gf_boolean_t timer_unref = _gf_false;
gf_boolean_t reconnect_unref = _gf_false;

Expand All @@ -486,15 +482,13 @@ rpc_clnt_connection_cleanup(rpc_clnt_connection_t *conn)

/* bailout logic cleanup */
if (conn->timer) {
ret = gf_timer_call_cancel(clnt->ctx, conn->timer);
if (!ret)
timer_unref = _gf_true;
gf_timer_call_cancel(clnt->ctx, conn->timer);
timer_unref = _gf_true;
conn->timer = NULL;
}
if (conn->reconnect) {
ret = gf_timer_call_cancel(clnt->ctx, conn->reconnect);
if (!ret)
reconnect_unref = _gf_true;
gf_timer_call_cancel(clnt->ctx, conn->reconnect);
reconnect_unref = _gf_true;
conn->reconnect = NULL;
}

Expand Down Expand Up @@ -1816,20 +1810,18 @@ rpc_clnt_disable(struct rpc_clnt *rpc)
rpc->disabled = 1;

if (conn->timer) {
ret = gf_timer_call_cancel(rpc->ctx, conn->timer);
gf_timer_call_cancel(rpc->ctx, conn->timer);
/* If the event is not fired and it actually cancelled
* the timer, do the unref else registered call back
* function will take care of it.
*/
if (!ret)
timer_unref = _gf_true;
timer_unref = _gf_true;
conn->timer = NULL;
}

if (conn->reconnect) {
ret = gf_timer_call_cancel(rpc->ctx, conn->reconnect);
if (!ret)
reconnect_unref = _gf_true;
gf_timer_call_cancel(rpc->ctx, conn->reconnect);
reconnect_unref = _gf_true;
conn->reconnect = NULL;
}
conn->status = RPC_STATUS_INITIALIZED;
Expand Down