Skip to contentSkip to conversation

Fix: consumer signal handling race

PATCH Mathieu Desnoyers 1 participant 1 message Sep 7, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

I notice this fix is now merged, thanks!

Mathieu

Quoted 59 lines · ----- On Sep 5, 2015, at 7:58 PM, Mathieu Desnoyers…

If a signal comes in after ctx has been destroyed, it will try to use a closed file descriptor.

---
src/bin/lttng-consumerd/lttng-consumerd.c | 10 ++++++++--
src/bin/lttng-sessiond/main.c | 1 -

2 files changed, 8 insertions(+), 3 deletions(-)
src/bin/lttng-consumerd/lttng-consumerd.c +4 -1
index 764cf4c..0d34fee 100644
@@ -109,7 +109,9 @@ static void sighandler(int sig)
 		return;
 	}
 
-	lttng_consumer_should_exit(ctx);
+	if (ctx) {
+		lttng_consumer_should_exit(ctx);
+	}
 }
 
 /*
@@ -312,6 +314,7 @@ int main(int argc, char **argv)
 {
 	int ret = 0, retval = 0;
 	void *status;
+	struct lttng_consumer_local_data *tmp_ctx;
 
 	if (set_signal_handler()) {
 		retval = -1;
@@ -626,7 +629,10 @@ exit_health_thread:

exit_health_pipe:

exit_init_data:

src/bin/lttng-consumerd/lttng-consumerd.c +4 -1
-	lttng_consumer_destroy(ctx);
+	tmp_ctx = ctx;
+	ctx = NULL;
+	cmm_barrier();	/* Clear ctx for signal handler. */
+	lttng_consumer_destroy(tmp_ctx);
	lttng_consumer_cleanup();

	if (health_consumerd) {
src/bin/lttng-sessiond/main.c +0 -2
index 2983cbf..7c48e4d 100644
@@ -712,7 +712,6 @@ static void sessiond_cleanup(void)
 	wait_consumer(&ustconsumer64_data);
 	wait_consumer(&ustconsumer32_data);
 
-
 	DBG("Cleaning up all agent apps");
 	agent_app_ht_clean();
 
--

2.1.4

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com