1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

add logging everytime we create a filedescriptor in the main ctdb daemon

so we can spot if there are leaks.

plug two leaks for filedescriptors related to when sending ARP fail
and one leak when we can not parse the local address during tcp connection establish

(This used to be ctdb commit ddd089810a14efe4be6e1ff3eccaa604e4913c9e)
This commit is contained in:
Ronnie Sahlberg 2009-10-15 11:24:54 +11:00
parent 6152a7060b
commit 9de3652380
11 changed files with 43 additions and 0 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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],

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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]);

View File

@ -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);

View File

@ -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,

View File

@ -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);

View File

@ -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,