Implement health check for app registration dispatch
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 14 Jun 2013 12:02:27 +0000 (08:02 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 14 Jun 2013 13:09:50 +0000 (09:09 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
include/lttng/lttng.h
src/bin/lttng-sessiond/health.h
src/bin/lttng-sessiond/main.c

index d2ce75fb14c75ad5d9ca79f60da4c93574d413d7..83232454f865c5b38d5ed00dcd117c8b538c40e0 100644 (file)
@@ -141,6 +141,7 @@ enum lttng_health_component {
        LTTNG_HEALTH_CONSUMER,
        LTTNG_HEALTH_HT_CLEANUP,
        LTTNG_HEALTH_APP_MANAGE_NOTIFY,
+       LTTNG_HEALTH_APP_REG_DISPATCH,
        LTTNG_HEALTH_ALL,
 };
 
index dc5b0b19958fc509ffe15a40d138a334ab76d4e9..d04d18b78ff4b436f59dae699892638f98e8c565 100644 (file)
@@ -46,6 +46,7 @@ enum health_type {
        HEALTH_TYPE_CONSUMER    = 4,
        HEALTH_TYPE_HT_CLEANUP          = 5,
        HEALTH_TYPE_APP_MANAGE_NOTIFY   = 6,
+       HEALTH_TYPE_APP_REG_DISPATCH    = 7,
 
        HEALTH_NUM_TYPE,
 };
index f1cd1b6407f4ee6f34cd18d976368825c3d5d7e3..007c722921700e351cfedd6441fc31a16a9683b3 100644 (file)
@@ -1340,7 +1340,7 @@ error:
  */
 static void *thread_dispatch_ust_registration(void *data)
 {
-       int ret;
+       int ret, err = -1;
        struct cds_wfq_node *node;
        struct ust_command *ust_cmd = NULL;
        struct {
@@ -1348,11 +1348,17 @@ static void *thread_dispatch_ust_registration(void *data)
                struct cds_list_head head;
        } *wait_node = NULL, *tmp_wait_node;
 
+       health_register(HEALTH_TYPE_APP_REG_DISPATCH);
+
+       health_code_update();
+
        CDS_LIST_HEAD(wait_queue);
 
        DBG("[thread] Dispatch UST command started");
 
        while (!CMM_LOAD_SHARED(dispatch_thread_exit)) {
+               health_code_update();
+
                /* Atomically prepare the queue futex */
                futex_nto1_prepare(&ust_cmd_queue.futex);
 
@@ -1360,6 +1366,7 @@ static void *thread_dispatch_ust_registration(void *data)
                        struct ust_app *app = NULL;
                        ust_cmd = NULL;
 
+                       health_code_update();
                        /* Dequeue command for registration */
                        node = cds_wfq_dequeue_blocking(&ust_cmd_queue.queue);
                        if (node == NULL) {
@@ -1424,6 +1431,7 @@ static void *thread_dispatch_ust_registration(void *data)
                                 */
                                cds_list_for_each_entry_safe(wait_node, tmp_wait_node,
                                                &wait_queue, head) {
+                                       health_code_update();
                                        if (wait_node->app->pid == ust_cmd->reg_msg.pid) {
                                                wait_node->app->notify_sock = ust_cmd->sock;
                                                cds_list_del(&wait_node->head);
@@ -1510,9 +1518,13 @@ static void *thread_dispatch_ust_registration(void *data)
                        }
                } while (node != NULL);
 
+               health_poll_entry();
                /* Futex wait on queue. Blocking call on futex() */
                futex_nto1_wait(&ust_cmd_queue.futex);
+               health_poll_exit();
        }
+       /* Normal exit, no error */
+       err = 0;
 
 error:
        /* Clean up wait queue. */
@@ -1523,6 +1535,11 @@ error:
        }
 
        DBG("Dispatch thread dying");
+       if (err) {
+               health_error();
+               ERR("Health error occurred in %s", __func__);
+       }
+       health_unregister();
        return NULL;
 }
 
@@ -3232,6 +3249,9 @@ restart:
                case LTTNG_HEALTH_APP_MANAGE_NOTIFY:
                        reply.ret_code = health_check_state(HEALTH_TYPE_APP_MANAGE_NOTIFY);
                        break;
+               case LTTNG_HEALTH_APP_REG_DISPATCH:
+                       reply.ret_code = health_check_state(HEALTH_TYPE_APP_REG_DISPATCH);
+                       break;
                case LTTNG_HEALTH_ALL:
                        reply.ret_code =
                                health_check_state(HEALTH_TYPE_APP_MANAGE) &&
@@ -3240,7 +3260,8 @@ restart:
                                health_check_state(HEALTH_TYPE_KERNEL) &&
                                check_consumer_health() &&
                                health_check_state(HEALTH_TYPE_HT_CLEANUP) &&
-                               health_check_state(HEALTH_TYPE_APP_MANAGE_NOTIFY);
+                               health_check_state(HEALTH_TYPE_APP_MANAGE_NOTIFY) &&
+                               health_check_state(HEALTH_TYPE_APP_REG_DISPATCH);
                        break;
                default:
                        reply.ret_code = LTTNG_ERR_UND;
This page took 0.03037 seconds and 5 git commands to generate.