Fix: handle the registration done command for JUL
authorDavid Goulet <dgoulet@efficios.com>
Wed, 26 Feb 2014 21:13:34 +0000 (16:13 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 26 Feb 2014 21:13:34 +0000 (16:13 -0500)
Lockstep with lttng-ust.

Part of the fix for issue #692

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/jul-thread.c
src/bin/lttng-sessiond/jul.c
src/bin/lttng-sessiond/jul.h
src/common/sessiond-comm/jul.h
tests/regression/ust/java-jul/test_java_jul

index b4a71d79849d36d739020faa6733e1916cfaca76..9c924ea40ebfe5c4f721ff099b0b327b149500aa 100644 (file)
@@ -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;
index 3c251998ef560d13d965337515746d9ada832cf1..40730bb4fdf188cbc97f8daabd5c6b5025f2dfd4 100644 (file)
@@ -344,6 +344,21 @@ error:
        return ret;
 }
 
+/*
+ * Send back the registration DONE command to a given JUL application.
+ *
+ * Return 0 on success or else a negative value.
+ */
+int jul_send_registration_done(struct jul_app *app)
+{
+       assert(app);
+       assert(app->sock);
+
+       DBG("JUL sending registration done to app socket %d", app->sock->fd);
+
+       return send_header(app->sock, 0, JUL_CMD_REG_DONE, 0);
+}
+
 /*
  * Enable JUL event on every JUL applications registered with the session
  * daemon.
index 1bcd5ef795edb190af64aa635ce7c0b12177cdc9..ccd59bc727ed5f18abca64c14b0a36fadeda0fb9 100644 (file)
@@ -119,6 +119,7 @@ void jul_add_app(struct jul_app *app);
 void jul_delete_app(struct jul_app *app);
 struct jul_app *jul_find_app_by_sock(int sock);
 void jul_destroy_app(struct jul_app *app);
+int jul_send_registration_done(struct jul_app *app);
 
 /* JUL action API */
 int jul_enable_event(struct jul_event *event);
index c9ab3d45a4ce7bce8d9e8318b80a07b9cc6d1fc2..f269fa81699e6dafdce93bba46db2417aa8bb437 100644 (file)
@@ -30,6 +30,7 @@ enum lttcomm_jul_command {
        JUL_CMD_LIST       = 1,
        JUL_CMD_ENABLE     = 2,
        JUL_CMD_DISABLE    = 3,
+       JUL_CMD_REG_DONE   = 4, /* End registration process. */
 };
 
 /*
index 6ea0638598d48029d668fb86a22274bfed74bb84..affb7eb6de55fc8dba91b6a0d79e086c814e693d 100755 (executable)
@@ -66,7 +66,7 @@ function test_jul_before_start ()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting all events.
-       trace_matches $EVENT_NAME $(($NR_ITER - 1)) $TRACE_PATH
+       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -89,7 +89,7 @@ function test_jul_after_start ()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting all events.
-       trace_matches $EVENT_NAME $(($NR_ITER - 1)) $TRACE_PATH
+       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -112,7 +112,7 @@ function test_jul_loglevel ()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting all events.
-       trace_matches $EVENT_NAME $(($NR_ITER - 1)) $TRACE_PATH
+       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
        if [ $? -ne 0 ]; then
                return $?
        fi
@@ -152,7 +152,7 @@ function test_jul_loglevel ()
        destroy_lttng_session $SESSION_NAME
 
        # Validate test. Expecting all events.
-       trace_matches $EVENT_NAME $(($NR_ITER - 1)) $TRACE_PATH
+       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
        return $?
 }
 
This page took 0.029726 seconds and 5 git commands to generate.