Fix: misc spelling errors
[lttng-tools.git] / src / bin / lttng-sessiond / jul-thread.c
index 972186059dd3f08fa7ab5350fb804936ee16bb12..cc694df81066718a82ded69fc2baf36b683b726b 100644 (file)
@@ -34,7 +34,8 @@
  * can let the user define a custom one. However, localhost is ALWAYS the
  * default listening address.
  */
-static const char *default_reg_uri = "tcp://localhost";
+static const char *default_reg_uri =
+       "tcp://" DEFAULT_NETWORK_VIEWER_BIND_ADDRESS;
 
 /*
  * Update JUL application using the given socket. This is done just after
@@ -141,6 +142,8 @@ static struct lttcomm_sock *init_tcp_socket(void)
 
        ret = sock->ops->bind(sock);
        if (ret < 0) {
+               WARN("Another session daemon is using this JUL port. JUL support "
+                               "will be deactivated to prevent interfering with the tracing.");
                goto error;
        }
 
@@ -178,12 +181,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;
@@ -223,13 +227,14 @@ static int handle_registration(struct lttcomm_sock *reg_sock)
        jul_add_app(app);
 
        /*
-        * Attach JUL application to a UST app object if one exists.
-        *
-        * FIXME: This implies that the UST app object exists and created before
-        * JUL registration. Must confirm or else JUL app will leak until socket is
-        * closed by the application.
+        * We don't need to attach the JUL app to the app. If we ever do
+        * so, we should consider both registration order of JUL before
+        * app and app before JUL.
         */
-       jul_attach_app(app);
+
+       if (r_app) {
+               *r_app = app;
+       }
 
        return new_sock->fd;
 
@@ -317,23 +322,22 @@ restart:
                                        goto error;
                                }
 
-                               /*
-                                * FIXME: Should we try to invalidate the JUL socket in the
-                                * associated ust app.
-                                */
                                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,
@@ -345,6 +349,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;
This page took 0.024688 seconds and 5 git commands to generate.