citrun

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

commit 8870045c0242d98a1554b944424f223e48e4405e
parent 9d38b6da7463f5f524e1395a7b538a8996bd0a0b
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Sat,  9 Apr 2016 10:23:03 -0600

lib: add initial reconnect support

Diffstat:
Mlib/runtime.c | 24++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/lib/runtime.c b/lib/runtime.c @@ -56,18 +56,22 @@ control_thread(void *arg) memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; strncpy(addr.sun_path, viewer_sock, sizeof(addr.sun_path) - 1); - if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) == -1) { - warn("connect"); - pthread_exit(NULL); - } - - /* Send static information first. */ - send_metadata(fd); while (1) { - /* Synchronously send execution data */ - send_execution_data(fd); - xread(fd, &response, 1); + if (connect(fd, (struct sockaddr *)&addr, sizeof(addr))) { + warn("connect"); + sleep(1); + continue; + } + + /* Send static information first. */ + send_metadata(fd); + + while (1) { + /* Synchronously send execution data */ + send_execution_data(fd); + xread(fd, &response, 1); + } } }