diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c index 7a580cc584c..999208d2fe7 100644 --- a/ctdb/common/system_linux.c +++ b/ctdb/common/system_linux.c @@ -92,9 +92,11 @@ int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface) return -1; } + DEBUG(DEBUG_NOTICE, (__location__ " Created SOCKET FD:%d for sending arp\n", s)); strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)); if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) { DEBUG(DEBUG_CRIT,(__location__ " interface '%s' not found\n", iface)); + close(s); return -1; } @@ -171,6 +173,7 @@ int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface) ret = sendto(s, buffer, 64, 0, (struct sockaddr *)&sall, sizeof(sall)); if (ret < 0 ){ DEBUG(DEBUG_CRIT,(__location__ " failed sendto\n")); + close(s); return -1; } @@ -183,9 +186,11 @@ int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface) return -1; } + DEBUG(DEBUG_NOTICE, (__location__ " Created SOCKET FD:%d for sending arp\n", s)); strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)); if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) { DEBUG(DEBUG_CRIT,(__location__ " interface '%s' not found\n", iface)); + close(s); return -1; } @@ -422,6 +427,8 @@ int ctdb_sys_open_capture_socket(const char *iface, void **private_data) return -1; } + DEBUG(DEBUG_NOTICE, (__location__ " Created RAW SOCKET FD:%d for tcp tickle\n", s)); + set_nonblocking(s); set_close_on_exec(s); diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c index 0af3bc1836e..cc496f54715 100644 --- a/ctdb/server/ctdb_daemon.c +++ b/ctdb/server/ctdb_daemon.c @@ -559,6 +559,8 @@ static void ctdb_accept_client(struct event_context *ev, struct fd_event *fde, set_nonblocking(fd); set_close_on_exec(fd); + DEBUG(DEBUG_NOTICE,(__location__ " Created SOCKET FD:%d to connected child\n", fd)); + client = talloc_zero(ctdb, struct ctdb_client); #ifdef _AIX if (getsockopt(fd, SOL_SOCKET, SO_PEERID, &cr, &crl) == 0) { diff --git a/ctdb/server/ctdb_lockwait.c b/ctdb/server/ctdb_lockwait.c index be3a0979d9d..e02cd21a944 100644 --- a/ctdb/server/ctdb_lockwait.c +++ b/ctdb/server/ctdb_lockwait.c @@ -146,6 +146,10 @@ struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db, } close(result->fd[1]); + set_close_on_exec(result->fd[0]); + + DEBUG(DEBUG_NOTICE, (__location__ " Created PIPE FD:%d to child lockwait process\n", result->fd[0])); + talloc_set_destructor(result, lockwait_destructor); result->fde = event_add_fd(ctdb_db->ctdb->ev, result, result->fd[0], diff --git a/ctdb/server/ctdb_logging.c b/ctdb/server/ctdb_logging.c index ebf4eef3574..7cd58ad1428 100644 --- a/ctdb/server/ctdb_logging.c +++ b/ctdb/server/ctdb_logging.c @@ -250,6 +250,8 @@ int ctdb_set_child_logging(struct ctdb_context *ctdb) set_close_on_exec(p[0]); ctdb->log->pfd = p[0]; + DEBUG(DEBUG_NOTICE, (__location__ " Created PIPE FD:%d for logging\n", p[0])); + close(1); close(2); if (p[1] != 1) { diff --git a/ctdb/server/ctdb_persistent.c b/ctdb/server/ctdb_persistent.c index f7578d15860..77538d98f91 100644 --- a/ctdb/server/ctdb_persistent.c +++ b/ctdb/server/ctdb_persistent.c @@ -454,8 +454,12 @@ struct childwrite_handle *ctdb_childwrite(struct ctdb_db_context *ctdb_db, } close(result->fd[1]); + set_close_on_exec(result->fd[0]); + talloc_set_destructor(result, childwrite_destructor); + DEBUG(DEBUG_NOTICE, (__location__ " Created PIPE FD:%d for ctdb_childwrite\n", result->fd[0])); + result->fde = event_add_fd(ctdb_db->ctdb->ev, result, result->fd[0], EVENT_FD_READ|EVENT_FD_AUTOCLOSE, childwrite_handler, (void *)result); diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c index 21dc28d05d2..862168e97ea 100644 --- a/ctdb/server/ctdb_recover.c +++ b/ctdb/server/ctdb_recover.c @@ -736,10 +736,14 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb, _exit(0); } close(state->fd[1]); + set_close_on_exec(state->fd[0]); + state->fd[1] = -1; talloc_set_destructor(state, set_recmode_destructor); + DEBUG(DEBUG_NOTICE, (__location__ " Created PIPE FD:%d for setrecmode\n", state->fd[0])); + state->te = event_add_timed(ctdb->ev, state, timeval_current_ofs(5, 0), ctdb_set_recmode_timeout, state); diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index d759856cd97..83fc808aa96 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -2520,6 +2520,9 @@ static int check_recovery_lock(struct ctdb_context *ctdb) } close(state->fd[1]); state->fd[1] = -1; + set_close_on_exec(state->fd[0]); + + DEBUG(DEBUG_NOTICE, (__location__ " Created PIPE FD:%d for check_recovery_lock\n", state->fd[0])); talloc_set_destructor(state, check_reclock_destructor); @@ -3311,6 +3314,8 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb) exit(1); } + DEBUG(DEBUG_NOTICE, (__location__ " Created PIPE FD:%d to recovery daemon\n", fd[0])); + event_add_fd(ctdb->ev, ctdb, fd[0], EVENT_FD_READ|EVENT_FD_AUTOCLOSE, ctdb_recoverd_parent, &fd[0]); diff --git a/ctdb/server/ctdb_traverse.c b/ctdb/server/ctdb_traverse.c index dbb4b4f6cc6..d66036f9a1c 100644 --- a/ctdb/server/ctdb_traverse.c +++ b/ctdb/server/ctdb_traverse.c @@ -176,6 +176,8 @@ static struct ctdb_traverse_local_handle *ctdb_traverse_local(struct ctdb_db_con } close(h->fd[1]); + set_close_on_exec(h->fd[0]); + talloc_set_destructor(h, traverse_local_destructor); DLIST_ADD(ctdb_db->traverse, h); @@ -184,6 +186,8 @@ static struct ctdb_traverse_local_handle *ctdb_traverse_local(struct ctdb_db_con setup a packet queue between the child and the parent. This copes with all the async and packet boundary issues */ + DEBUG(DEBUG_NOTICE, (__location__ " Created PIPE FD:%d to child traverse\n", h->fd[0])); + h->queue = ctdb_queue_setup(ctdb_db->ctdb, h, h->fd[0], 0, ctdb_traverse_local_handler, h); if (h->queue == NULL) { talloc_free(h); diff --git a/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c index 69991b51f20..b1927bab67f 100644 --- a/ctdb/server/ctdb_vacuum.c +++ b/ctdb/server/ctdb_vacuum.c @@ -847,6 +847,8 @@ ctdb_vacuum_event(struct event_context *ev, struct timed_event *te, timeval_current_ofs(ctdb->tunable.vacuum_max_run_time, 0), vacuum_child_timeout, child_ctx); + DEBUG(DEBUG_NOTICE, (__location__ " Created PIPE FD:%d to child vacuum process\n", child_ctx->fd[0])); + event_add_fd(ctdb->ev, child_ctx, child_ctx->fd[0], EVENT_FD_READ|EVENT_FD_AUTOCLOSE, vacuum_child_handler, diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c index 6d2b370c1d0..3d139c0c0f3 100644 --- a/ctdb/server/eventscript.c +++ b/ctdb/server/eventscript.c @@ -812,6 +812,8 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb, close(state->fd[1]); set_close_on_exec(state->fd[0]); + DEBUG(DEBUG_NOTICE, (__location__ " Created PIPE FD:%d to child eventscript process\n", state->fd[0])); + event_add_fd(ctdb->ev, state, state->fd[0], EVENT_FD_READ|EVENT_FD_AUTOCLOSE, ctdb_event_script_handler, state); diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c index e3d7772ae4e..20748606018 100644 --- a/ctdb/tcp/tcp_connect.c +++ b/ctdb/tcp/tcp_connect.c @@ -158,6 +158,8 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te, set_nonblocking(tnode->fd); set_close_on_exec(tnode->fd); + DEBUG(DEBUG_NOTICE, (__location__ " Created TCP SOCKET FD:%d\n", tnode->fd)); + /* Bind our side of the socketpair to the same address we use to listen * on incoming CTDB traffic. * We must specify this address to make sure that the address we expose to @@ -166,6 +168,8 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te, */ ZERO_STRUCT(sock_in); if (ctdb_tcp_get_address(ctdb, ctdb->address.address, &sock_in) != 0) { + DEBUG(DEBUG_ERR, (__location__ " Failed to find our address. Failing bind.\n")); + close(tnode->fd); return; } @@ -186,6 +190,7 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te, default: DEBUG(DEBUG_ERR, (__location__ " unknown family %u\n", sock_in.sa.sa_family)); + close(tnode->fd); return; } #ifdef HAVE_SOCK_SIN_LEN @@ -253,6 +258,8 @@ static void ctdb_listen_event(struct event_context *ev, struct fd_event *fde, set_nonblocking(in->fd); set_close_on_exec(in->fd); + DEBUG(DEBUG_NOTICE, (__location__ " Created SOCKET FD:%d to incoming ctdb connection\n", fd)); + setsockopt(in->fd,SOL_SOCKET,SO_KEEPALIVE,(char *)&one,sizeof(one)); in->queue = ctdb_queue_setup(ctdb, in, in->fd, CTDB_TCP_ALIGNMENT,