citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit f6e6449416940ce9173a798a14a83edbf279a757
parent 6b0435681d8d37d04db4903bbc3416a725d56cb4
Author: Kyle Milz <kyle@0x30.net>
Date:   Wed, 22 Jun 2016 20:15:34 -0600

lib: wait for total tu count to be consistent before proceeding

Diffstat:
Mlib/runtime.c | 29++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/lib/runtime.c b/lib/runtime.c @@ -4,7 +4,7 @@ #include <pthread.h> /* pthread_create */ #include <stdlib.h> /* getenv */ #include <string.h> /* strlcpy */ -#include <unistd.h> /* getpid, getppid, getpgrp, read, write */ +#include <unistd.h> /* getpid, getppid, getpgrp, read, usleep, write */ #include <sys/socket.h> /* socket */ #include <sys/un.h> /* sockaddr_un */ @@ -142,6 +142,31 @@ send_execution_data(int fd) } } +static void +settle(void) +{ + struct citrun_node *walk; + unsigned int previous_total; + unsigned int total = 0; + unsigned int spun = 0; + + do { + usleep(100 * 1000); + + walk = citrun_nodes_head; + previous_total = total; + total = 0; + + while (walk != NULL) { + walk = walk->next; + ++total; + } + ++spun; + } while (previous_total != total); + + warnx("spun %u times", spun); +} + /* Sets up connection to the server socket and drops into an io loop. */ static void * control_thread(void *arg) @@ -171,6 +196,8 @@ control_thread(void *arg) continue; } + settle(); + /* Send static information first. */ send_metadata(fd);