X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fjul-thread.c;h=9c924ea40ebfe5c4f721ff099b0b327b149500aa;hp=b4a71d79849d36d739020faa6733e1916cfaca76;hb=1b500e7ab6676535ce092106bf4f97929fc2dd54;hpb=8c93562f396a3e785c5193ca32b40f1f16599a6a diff --git a/src/bin/lttng-sessiond/jul-thread.c b/src/bin/lttng-sessiond/jul-thread.c index b4a71d798..9c924ea40 100644 --- a/src/bin/lttng-sessiond/jul-thread.c +++ b/src/bin/lttng-sessiond/jul-thread.c @@ -180,12 +180,13 @@ static void destroy_tcp_socket(struct lttcomm_sock *sock) /* * Handle a new JUL registration using the reg socket. After that, a new JUL * application is added to the global hash table and attach to an UST app - * object. + * object. If r_app is not NULL, the created app is set to the pointer. * * Return the new FD created upon accept() on success or else a negative errno * value. */ -static int handle_registration(struct lttcomm_sock *reg_sock) +static int handle_registration(struct lttcomm_sock *reg_sock, + struct jul_app **r_app) { int ret; pid_t pid; @@ -230,6 +231,10 @@ static int handle_registration(struct lttcomm_sock *reg_sock) * app and app before JUL. */ + if (r_app) { + *r_app = app; + } + return new_sock->fd; error_socket: @@ -319,16 +324,19 @@ restart: destroy_jul_app(pollfd); } else if (revents & (LPOLLIN)) { int new_fd; + struct jul_app *app = NULL; /* Pollin event of JUL app socket should NEVER happen. */ assert(pollfd == reg_sock->fd); - new_fd = handle_registration(reg_sock); + new_fd = handle_registration(reg_sock, &app); if (new_fd < 0) { WARN("[jul-thread] JUL registration failed. Ignoring."); /* Somehow the communication failed. Just continue. */ continue; } + /* Should not have a NULL app on success. */ + assert(app); /* Only add poll error event to only detect shutdown. */ ret = lttng_poll_add(&events, new_fd, @@ -340,6 +348,9 @@ restart: /* Update newly registered app. */ update_jul_app(new_fd); + + /* On failure, the poll will detect it and clean it up. */ + (void) jul_send_registration_done(app); } else { ERR("Unknown poll events %u for sock %d", revents, pollfd); continue;