From: Pierre-Marc Fournier Date: Sat, 27 Feb 2010 17:06:04 +0000 (-0500) Subject: improve keepalive by changing the location of the unconnected buffers counter X-Git-Tag: v1.9.1~698 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d5adede06d9dc0c4675c4c4052eb98f74973f4a5;p=lttng-ust.git improve keepalive by changing the location of the unconnected buffers counter to a location that guarantees the buffer has been mapped by the daemon Fixes a race. --- diff --git a/libust/tracectl.c b/libust/tracectl.c index c34a3ce4..916b3548 100644 --- a/libust/tracectl.c +++ b/libust/tracectl.c @@ -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; } }