flush at every second
[lttngtop.git] / src / lttngtop.c
index 9ac8d39c1c9f8c262a9fea039de0c7c9b663e339..7d89e5c8af12896dcc38eb36cf79251bed207cfd 100644 (file)
@@ -88,9 +88,13 @@ static struct poptOption long_options[] = {
 
 void *refresh_thread(void *p)
 {
+       struct mmap_stream *mmap_info;
+
        while (1) {
                if (quit)
                        return NULL;
+               bt_list_for_each_entry(mmap_info, &mmap_list.head, list)
+                       helper_kernctl_buffer_flush(mmap_info->fd);
                sem_wait(&pause_sem);
                sem_post(&pause_sem);
                sem_post(&timer);
@@ -138,7 +142,6 @@ enum bt_cb_ret print_timestamp(struct bt_ctf_event *call_data, void *private_dat
        struct tm start;
        uint64_t ts_nsec_start;
 
-
        timestamp = bt_ctf_get_timestamp(call_data);
 
        start = format_timestamp(timestamp);
@@ -343,7 +346,6 @@ void init_lttngtop()
        copies = g_ptr_array_new();
        global_perf_liszt = g_hash_table_new(g_str_hash, g_str_equal);
 
-
        sem_init(&goodtodisplay, 0, 0);
        sem_init(&goodtoupdate, 0, 1);
        sem_init(&timer, 0, 1);
@@ -766,34 +768,33 @@ end:
        return ret;
 }
 
-void *live_consume()
+void live_consume(struct bt_context **bt_ctx)
 {
-       struct bt_context *bt_ctx = NULL;
        int ret;
 
        if (!metadata_ready) {
                sem_wait(&metadata_available);
-               if (access("/tmp/livesession/metadata", F_OK) != 0) {
+               if (access("/tmp/livesession/kernel/metadata", F_OK) != 0) {
                        fprintf(stderr,"no metadata\n");
-                       return NULL;
+                       goto end;
                }
                metadata_ready = 1;
-               metadata_fp = fopen("/tmp/livesession/metadata", "r");
+               metadata_fp = fopen("/tmp/livesession/kernel/metadata", "r");
        }
 
        if (!trace_opened) {
-               bt_ctx = bt_context_create();
-               ret = bt_context_add_trace(bt_ctx, NULL, "ctf",
+               *bt_ctx = bt_context_create();
+               ret = bt_context_add_trace(*bt_ctx, NULL, "ctf",
                                lttngtop_ctf_packet_seek, &mmap_list, metadata_fp);
                if (ret < 0) {
                        printf("Error adding trace\n");
-                       return NULL;
+                       goto end;
                }
                trace_opened = 1;
        }
-       iter_trace(bt_ctx);
 
-       return NULL;
+end:
+       return;
 }
 
 int setup_consumer(char *command_sock_path, pthread_t *threads,
@@ -856,7 +857,7 @@ void *setup_live_tracing()
        /* setup the session */
        dom.type = LTTNG_DOMAIN_KERNEL;
 
-       ret = system("rm -rf /tmp/livesession");
+       ret = unlink("/tmp/livesession");
 
        lttng_destroy_session("test");
        if ((ret = lttng_create_session("test", "/tmp/livesession")) < 0) {
@@ -952,9 +953,13 @@ int main(int argc, char **argv)
                        pthread_create(&display_thread, NULL, ncurses_display, (void *) NULL);
                        pthread_create(&timer_thread, NULL, refresh_thread, (void *) NULL);
                }
-               live_consume();
+               live_consume(&bt_ctx);
+               iter_trace(bt_ctx);
+
+               quit = 1;
+               pthread_join(display_thread, NULL);
+               pthread_join(timer_thread, NULL);
 
-               sleep(2000);
                lttng_stop_tracing("test");
                lttng_destroy_session("test");
 
This page took 0.023644 seconds and 4 git commands to generate.