improve keepalive by changing the location of the unconnected buffers counter
[ust.git] / libust / tracectl.c
index c72d013d7535a5539960e4d111ad24b39bcc6e54..916b3548eee3de1f953713159c44794431c9874f 100644 (file)
@@ -357,10 +357,7 @@ static int do_cmd_get_shmid(const char *recvbuf, struct ustcomm_source *src)
                }
        }
 
-       if(found) {
-               buffers_to_export--;
-       }
-       else {
+       if(!found) {
                ERR("channel not found (%s)", channel_and_cpu);
        }
 
@@ -695,6 +692,14 @@ static int do_cmd_get_subbuffer(const char *recvbuf, struct ustcomm_source *src)
 
                        list_add(&bc->list, &blocked_consumers);
 
+                       /* Being here is the proof the daemon has mapped the buffer in its
+                        * memory. We may now decrement buffers_to_export.
+                        */
+                       if(atomic_long_read(&buf->consumed) == 0) {
+                               DBG("decrementing buffers_to_export");
+                               buffers_to_export--;
+                       }
+
                        break;
                }
        }
@@ -1455,6 +1460,10 @@ static void ust_fork(void)
 
        /* FIXME: technically, the locks could have been taken before the fork */
        DBG("ust: forking");
+
+       /* break lock if necessary */
+       ltt_unlock_traces();
+
        ltt_trace_stop("auto");
        ltt_trace_destroy("auto", 1);
        /* Delete all active connections */
@@ -1470,8 +1479,8 @@ static void ust_fork(void)
        }
 
        have_listener = 0;
-       create_listener();
        init_socket();
+       create_listener();
        ltt_trace_setup("auto");
        result = ltt_trace_set_type("auto", "ustrelay");
        if(result < 0) {
This page took 0.022908 seconds and 4 git commands to generate.