summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-lib/src
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2018-11-08 08:25:00 +0200
committerAmar Tumballi <amarts@redhat.com>2018-11-15 05:04:13 +0000
commit8a5adc811637b147e6e42d952498bc99e3d670bb (patch)
treea63004a3e1c92ae1f1887b5b8652f7bce642fc6f /rpc/rpc-lib/src
parent013c8295d7cd7f5ad52bcf2585936ed320b8bbc7 (diff)
rpc/rpc-lib/src/rpc-clnt.c: unlock sooner, if we fail to connect.
Previously, we did not go to unlock the mutex if we failed to connect. This patch fixes it. Compile-tested only! updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I0fcca066a2601dba6bc3e9eb8b3c9fc757ffe4db
Diffstat (limited to 'rpc/rpc-lib/src')
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index 56bde4ed8ab..9582f02b461 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -55,13 +55,13 @@ _is_lock_fop(struct saved_frame *sframe)
(fop == GFS3_OP_FENTRYLK));
}
-struct saved_frame *
+static struct saved_frame *
__saved_frames_put(struct saved_frames *frames, void *frame,
struct rpc_req *rpcreq)
{
- struct saved_frame *saved_frame = NULL;
+ struct saved_frame *saved_frame = mem_get(
+ rpcreq->conn->rpc_clnt->saved_frames_pool);
- saved_frame = mem_get(rpcreq->conn->rpc_clnt->saved_frames_pool);
if (!saved_frame) {
goto out;
}
@@ -199,19 +199,16 @@ out:
}
/* to be called with conn->lock held */
-struct saved_frame *
+static struct saved_frame *
__save_frame(struct rpc_clnt *rpc_clnt, call_frame_t *frame,
struct rpc_req *rpcreq)
{
- rpc_clnt_connection_t *conn = NULL;
+ rpc_clnt_connection_t *conn = &rpc_clnt->conn;
struct timespec timeout = {
0,
};
- struct saved_frame *saved_frame = NULL;
-
- conn = &rpc_clnt->conn;
-
- saved_frame = __saved_frames_put(conn->saved_frames, frame, rpcreq);
+ struct saved_frame *saved_frame = __saved_frames_put(conn->saved_frames,
+ frame, rpcreq);
if (saved_frame == NULL) {
goto out;
@@ -1678,18 +1675,18 @@ rpc_clnt_submit(struct rpc_clnt *rpc, rpc_clnt_prog_t *prog, int procnum,
{
if (conn->connected == 0) {
if (rpc->disabled)
- goto nosubmit;
+ goto unlock;
ret = rpc_transport_connect(conn->trans, conn->config.remote_port);
if (ret < 0) {
gf_log(conn->name, GF_LOG_WARNING,
"error returned while attempting to "
"connect to host:%s, port:%d",
conn->config.remote_host, conn->config.remote_port);
+ goto unlock;
}
}
ret = rpc_transport_submit_request(conn->trans, &req);
- nosubmit:
if (ret == -1) {
gf_log(conn->name, GF_LOG_WARNING,
"failed to submit rpc-request "
@@ -1698,9 +1695,7 @@ rpc_clnt_submit(struct rpc_clnt *rpc, rpc_clnt_prog_t *prog, int procnum,
"ProgVers: %d, Proc: %d) to rpc-transport (%s)",
cframe->root->unique, rpcreq->xid, rpcreq->prog->progname,
rpcreq->prog->progver, rpcreq->procnum, conn->name);
- }
-
- if ((ret >= 0) && frame) {
+ } else if ((ret >= 0) && frame) {
/* Save the frame in queue */
__save_frame(rpc, frame, rpcreq);
@@ -1722,6 +1717,7 @@ rpc_clnt_submit(struct rpc_clnt *rpc, rpc_clnt_prog_t *prog, int procnum,
rpcreq->prog->progver, rpcreq->procnum, conn->name);
}
}
+unlock:
pthread_mutex_unlock(&conn->lock);
if (need_unref)