From 393bc3911a4d704f85d6331aca2fb4a5b57b5e8a Mon Sep 17 00:00:00 2001 From: Pierre-Marc Fournier Date: Sat, 27 Feb 2010 12:12:59 -0500 Subject: [PATCH] ust_fork(): close the ustcomm_app socket in the child on fork() This fixes a bug where the parent's connections remained jammed open. --- libust/tracectl.c | 2 ++ libustcomm/ustcomm.c | 10 ++++++++++ libustcomm/ustcomm.h | 1 + 3 files changed, 13 insertions(+) diff --git a/libust/tracectl.c b/libust/tracectl.c index 220d37f..848b272 100644 --- a/libust/tracectl.c +++ b/libust/tracectl.c @@ -1478,6 +1478,8 @@ static void ust_fork(void) list_del(&bc->list); } + ustcomm_free_app(&ustcomm_app); + buffers_to_export = 0; have_listener = 0; init_socket(); diff --git a/libustcomm/ustcomm.c b/libustcomm/ustcomm.c index 7dd1251..5f2517b 100644 --- a/libustcomm/ustcomm.c +++ b/libustcomm/ustcomm.c @@ -678,6 +678,16 @@ free_name: return -1; } +void ustcomm_free_app(struct ustcomm_app *app) +{ + int result; + result = close(app->server.listen_fd); + if(result == -1) { + PERROR("close"); + return; + } +} + /* Used by the daemon to initialize its server so applications * can connect to it. */ diff --git a/libustcomm/ustcomm.h b/libustcomm/ustcomm.h index a554678..05d90eb 100644 --- a/libustcomm/ustcomm.h +++ b/libustcomm/ustcomm.h @@ -68,6 +68,7 @@ extern int ustcomm_app_recv_message(struct ustcomm_app *app, char **msg, struct extern int ustcomm_init_app(pid_t pid, struct ustcomm_app *handle); extern void ustcomm_fini_app(struct ustcomm_app *handle); +extern void ustcomm_free_app(struct ustcomm_app *app); extern int ustcomm_init_ustd(struct ustcomm_ustd *handle, const char *sock_path); -- 2.34.1