From 633cb4908567df55b6ff00a29f5dda86002ae9bc Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Oct 26 2017 20:49:25 +0000 Subject: [PATCH 1/3] Emit debug on queue errors Signed-off-by: Simo Sorce --- diff --git a/proxy/src/gp_workers.c b/proxy/src/gp_workers.c index 2a33c21..18f38f6 100644 --- a/proxy/src/gp_workers.c +++ b/proxy/src/gp_workers.c @@ -314,6 +314,8 @@ static void gp_handle_reply(verto_ctx *vctx, verto_ev *ev) case GP_QUERY_IN: /* ?! fallback and kill client conn */ case GP_QUERY_ERR: + GPDEBUGN(3, "[status] Handling query error, terminating CID %d.\n", + gp_conn_get_cid(q->conn)); gp_conn_free(q->conn); gp_query_free(q, true); break; From a38158ccb14122c96cafab46e9798e98d6959fc3 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Oct 26 2017 21:03:31 +0000 Subject: [PATCH 2/3] Revert "Fix potential deadlock on socket grab" This reverts commit 461a5fa9f91a2753ebeef6323a64239c35e2f250. This commit erroneously unconditionally release the very lock we wanted to grab. This caused the socketd to not be locked to our thread. Another thread could come along and change the global ctx while we were still using the socket from another thread, causing concurrency issues as only one request can be in flight on any given socket at the same time. In special cases where the "thread" uid/gid changes (like in rpc.gssd) we end up closing the socket while we are still waiting for an answer from the server, causing additional issues and confusion. Signed-off-by: Simo Sorce --- diff --git a/proxy/src/client/gpm_common.c b/proxy/src/client/gpm_common.c index 75c64d7..55fd8b7 100644 --- a/proxy/src/client/gpm_common.c +++ b/proxy/src/client/gpm_common.c @@ -163,7 +163,9 @@ static int gpm_grab_sock(struct gpm_ctx *gpmctx) ret = gpm_open_socket(gpmctx); } - pthread_mutex_unlock(&gpmctx->lock); + if (ret) { + pthread_mutex_unlock(&gpmctx->lock); + } return ret; } From cf9763c32c918531c3d9745d3f721426bdf62b24 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Oct 26 2017 21:03:36 +0000 Subject: [PATCH 3/3] Do not call gpm_grab_sock() twice This is the correct fix for the potential deadlock mentioned in the previous commit. In the gpm_get_ctx() call we unnecessarily call gpm_grab_sock() which would cause the lock to be held by one thread and never released. We already call gpm_grab_sock() as the first thing after gpm_get_ctx() in gpm_make_call(), plus gpm_make_call() properly release the socket once done. Signed-off-by: Simo Sorce --- diff --git a/proxy/src/client/gpm_common.c b/proxy/src/client/gpm_common.c index 55fd8b7..f9f9258 100644 --- a/proxy/src/client/gpm_common.c +++ b/proxy/src/client/gpm_common.c @@ -520,11 +520,6 @@ static struct gpm_ctx *gpm_get_ctx(void) pthread_once(&gpm_init_once_control, gpm_init_once); - ret = gpm_grab_sock(&gpm_global_ctx); - if (ret) { - return NULL; - } - return &gpm_global_ctx; }