improve keepalive by changing the location of the unconnected buffers counter
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Sat, 27 Feb 2010 17:06:04 +0000 (12:06 -0500)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Sat, 27 Feb 2010 17:06:04 +0000 (12:06 -0500)
to a location that guarantees the buffer has been mapped by the daemon
Fixes a race.

libust/tracectl.c

index c34a3ce4ad3f673393ef3df9da5f89baa965d7e8..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;
                }
        }
This page took 0.02537 seconds and 4 git commands to generate.