libust: Fix multiple fd close during fork v2
authorNils Carlson <nils.carlson@ericsson.com>
Wed, 23 Feb 2011 12:34:41 +0000 (13:34 +0100)
committerNils Carlson <nils.carlson@ericsson.com>
Wed, 23 Feb 2011 15:53:46 +0000 (16:53 +0100)
Remove superfluous fd closes during fork and also destroy all
traces instead of just "auto".

Changes since v1: Also stop all traces

Reported-by: Yannick Brosseau <yannick.brosseau@gmail.com>
Signed-off-by: Nils Carlson <nils.carlson@ericsson.com>
libust/tracectl.c

index 1bd722949aaca5c4335f53b16b270d30e68f238d..f720244530c9f60b77f5978875f712a5ea69658a 100644 (file)
@@ -1569,6 +1569,7 @@ static void ust_fork(void)
 {
        struct ust_buffer *buf, *buf_tmp;
        struct ustcomm_sock *sock, *sock_tmp;
+       struct ust_trace *trace, *trace_tmp;
        int result;
 
        /* FIXME: technically, the locks could have been taken before the fork */
@@ -1580,7 +1581,14 @@ static void ust_fork(void)
        /* break lock if necessary */
        ltt_unlock_traces();
 
-       ltt_trace_stop("auto");
+       /*
+        * FIXME: This could be prettier, we loop over the list twice and
+        * following good locking practice should lock around the loop
+        */
+       cds_list_for_each_entry_safe(trace, trace_tmp, &ltt_traces.head, list) {
+               ltt_trace_stop(trace->trace_name);
+       }
+
        /* Delete all active connections, but leave them in the epoll set */
        cds_list_for_each_entry_safe(sock, sock_tmp, &ust_socks, list) {
                ustcomm_del_sock(sock, 1);
@@ -1589,18 +1597,16 @@ static void ust_fork(void)
        /* Delete all blocked consumers */
        cds_list_for_each_entry_safe(buf, buf_tmp, &open_buffers_list,
                                 open_buffers_list) {
-               result = close(buf->data_ready_fd_read);
-               if (result == -1) {
-                       PERROR("close");
-               }
-               result = close(buf->data_ready_fd_write);
-               if (result == -1) {
-                       PERROR("close");
-               }
                cds_list_del(&buf->open_buffers_list);
        }
 
-       ltt_trace_destroy("auto", 1);
+       /*
+        * FIXME: This could be prettier, we loop over the list twice and
+        * following good locking practice should lock around the loop
+        */
+       cds_list_for_each_entry_safe(trace, trace_tmp, &ltt_traces.head, list) {
+               ltt_trace_destroy(trace->trace_name, 1);
+       }
 
        /* Clean up the listener socket and epoll, keeping the scoket file */
        ustcomm_del_named_sock(listen_sock, 1);
This page took 0.026975 seconds and 4 git commands to generate.