summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2017-11-17 12:31:16 +1100
committerMartin Schwenke <martins@samba.org>2017-11-21 05:03:17 +0100
commit3b8f0cc21dd18e84ee78d0450d6f89435abf8dc1 (patch)
treec197f85857315199c0a4ca75081d507923cb36a3 /ctdb
parent984c3f4f66846fb05fbbbc0cb4d2a3d2cacb6444 (diff)
downloadsamba-3b8f0cc21dd18e84ee78d0450d6f89435abf8dc1.tar.gz
ctdb-common: Handle errors on unexpected socket close in sock_daemon
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/common/sock_daemon.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/ctdb/common/sock_daemon.c b/ctdb/common/sock_daemon.c
index ae291d773c3..0ef01666883 100644
--- a/ctdb/common/sock_daemon.c
+++ b/ctdb/common/sock_daemon.c
@@ -265,7 +265,11 @@ static int sock_socket_init(TALLOC_CTX *mem_ctx, const char *sockpath,
return ENOMEM;
}
- sock->sockpath = sockpath;
+ sock->sockpath = talloc_strdup(sock, sockpath);
+ if (sock->sockpath == NULL) {
+ talloc_free(sock);
+ return ENOMEM;
+ }
sock->funcs = funcs;
sock->private_data = private_data;
sock->fd = -1;
@@ -405,7 +409,8 @@ static int sock_socket_start_client_destructor(struct sock_client *client)
return 0;
}
-static bool sock_socket_start_recv(struct tevent_req *req, int *perr)
+static bool sock_socket_start_recv(struct tevent_req *req, int *perr,
+ TALLOC_CTX *mem_ctx, const char **sockpath)
{
struct sock_socket_start_state *state = tevent_req_data(
req, struct sock_socket_start_state);
@@ -420,6 +425,10 @@ static bool sock_socket_start_recv(struct tevent_req *req, int *perr)
return false;
}
+ if (sockpath != NULL) {
+ *sockpath = talloc_steal(mem_ctx, state->sock->sockpath);
+ }
+
return true;
}
@@ -735,13 +744,17 @@ static void sock_daemon_run_socket_fail(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(
subreq, struct tevent_req);
+ struct sock_daemon_run_state *state = tevent_req_data(
+ req, struct sock_daemon_run_state);
+ const char *sockpath = NULL;
int ret = 0;
bool status;
- status = sock_socket_start_recv(subreq, &ret);
+ status = sock_socket_start_recv(subreq, &ret, state, &sockpath);
TALLOC_FREE(subreq);
sock_daemon_run_shutdown(req);
if (! status) {
+ D_ERR("socket %s closed unexpectedly\n", sockpath);
tevent_req_error(req, ret);
} else {
tevent_req_done(req);