prepare the 0.3 release
[lttngtop.git] / src / iostreamtop.c
index 367fdee6ef2e281c2cbcbde3bc0019b74872ac08..44fe37b89995aadc722ca5786d3f859a5830b4e8 100644 (file)
@@ -48,7 +48,8 @@ void add_file(struct processtop *proc, struct files *file, int fd)
                if (tmp_file == NULL)
                        g_ptr_array_index(proc->process_files_table, fd) = file;
                else {
-                       if (strcmp(tmp_file->name, file->name) != 0) {
+                       if (!tmp_file->name ||
+                                       strcmp(tmp_file->name, file->name) != 0) {
                                size = proc->process_files_table->len;
                                g_ptr_array_set_size(proc->process_files_table,
                                                                size+1);
@@ -102,7 +103,7 @@ void insert_file(struct processtop *proc, int fd)
                return;
        if (fd >= proc->process_files_table->len) {
                tmp = g_new0(struct files, 1);
-               tmp->name = "Unknown";
+               tmp->name = NULL;
                tmp->read = 0;
                tmp->write = 0;
                tmp->fd = fd;
@@ -112,7 +113,7 @@ void insert_file(struct processtop *proc, int fd)
                tmp = g_ptr_array_index(proc->process_files_table, fd);
                if (tmp == NULL) {
                        tmp = g_new0(struct files, 1);
-                       tmp->name = "Unknown";
+                       tmp->name = NULL;
                        tmp->read = 0;
                        tmp->write = 0;
                        tmp->fd = fd;
@@ -123,7 +124,7 @@ void insert_file(struct processtop *proc, int fd)
                        if (parent) {
                                tmp_parent = g_ptr_array_index(
                                        parent->process_files_table, fd);
-                               if (tmp_parent &&
+                               if (tmp_parent && tmp->name && tmp_parent->name &&
                                   (strcmp(tmp->name, tmp_parent->name)) != 0)
                                        tmp->name = strdup(tmp_parent->name);
                        }
@@ -139,6 +140,12 @@ void close_file(struct processtop *proc, int fd)
        if (file != NULL) {
                file->flag = __NR_close;
                lttngtop.nbfiles--;
+               /*
+               if (file->name) {
+                       free(file->name);
+                       file->name = NULL;
+               }
+               */
        }
        lttngtop.nbclosedfiles++;
 }
@@ -400,7 +407,6 @@ error:
        return BT_CB_ERROR_STOP;
 }
 
-
 enum bt_cb_ret handle_sys_open(struct bt_ctf_event *call_data,
                void *private_data)
 {
@@ -447,6 +453,43 @@ error:
        return BT_CB_ERROR_STOP;
 }
 
+enum bt_cb_ret handle_sys_socket(struct bt_ctf_event *call_data,
+               void *private_data)
+{
+
+       struct processtop *tmp;
+       unsigned long timestamp;
+       uint64_t cpu_id;
+       int64_t tid;
+       char *procname, *hostname;
+       char *file;
+
+       timestamp = bt_ctf_get_timestamp(call_data);
+       if (timestamp == -1ULL)
+               goto error;
+
+       tid = get_context_tid(call_data);
+       cpu_id = get_cpu_id(call_data);
+
+       procname = get_context_comm(call_data);
+       hostname = get_context_hostname(call_data);
+
+       file = strdup("socket");
+
+       tmp = get_proc(&lttngtop, tid, procname, timestamp, hostname);
+       if (!tmp)
+               goto end;
+
+       tmp->syscall_info = create_syscall_info(__NR_open, cpu_id, tid, -1);
+
+       tmp->files_history = create_file(tmp->files_history, file);
+
+end:
+       return BT_CB_OK;
+
+error:
+       return BT_CB_ERROR_STOP;
+}
 
 enum bt_cb_ret handle_sys_close(struct bt_ctf_event *call_data,
                void *private_data)
This page took 0.02321 seconds and 4 git commands to generate.