X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=libust%2Ftracectl.c;h=ac551d50e802afec1bcd3a1abdcba6cddbf1c326;hb=9dec086e052cf7f583a3afaa3aab48a6de8d38ac;hp=2f9215e65b29adc0df6095ce72c206425304c559;hpb=1eba9d6b2081a1e75e7f711ac02023dde773bef1;p=ust.git diff --git a/libust/tracectl.c b/libust/tracectl.c index 2f9215e..ac551d5 100644 --- a/libust/tracectl.c +++ b/libust/tracectl.c @@ -469,7 +469,6 @@ static int do_cmd_get_subbuf_size(const char *recvbuf, struct ustcomm_source *sr static unsigned int pow2_higher_or_eq(unsigned int v) { int hb = fls(v); - int hbm1 = hb-1; int retval = 1<<(hb-1); if(v-retval == 0) @@ -788,6 +787,15 @@ static void listener_cleanup(void *ptr) ustcomm_fini_app(&ustcomm_app, 0); } +static void do_cmd_force_switch() +{ + struct blocked_consumer *bc; + + list_for_each_entry(bc, &blocked_consumers, list) { + ltt_force_switch(bc->buf, FORCE_FLUSH); + } +} + int process_client_cmd(char *recvbuf, struct ustcomm_source *src) { int result; @@ -994,6 +1002,28 @@ int process_client_cmd(char *recvbuf, struct ustcomm_source *src) free(reply); } + else if(nth_token_is(recvbuf, "get_sock_path", 0) == 1) { + char *reply = getenv("UST_DAEMON_SOCKET"); + if(!reply) { + asprintf(&reply, "%s/%s", SOCK_DIR, "ustd"); + result = ustcomm_send_reply(&ustcomm_app.server, reply, src); + free(reply); + } + else { + result = ustcomm_send_reply(&ustcomm_app.server, reply, src); + } + if(result) + ERR("ustcomm_send_reply failed"); + } + else if(nth_token_is(recvbuf, "set_sock_path", 0) == 1) { + char *sock_path = nth_token(recvbuf, 1); + result = setenv("UST_DAEMON_SOCKET", sock_path, 1); + if(result) + ERR("cannot set UST_DAEMON_SOCKET environment variable"); + } + else if(nth_token_is(recvbuf, "force_switch", 0) == 1) { + do_cmd_force_switch(); + } else { ERR("unable to parse message: %s", recvbuf); } @@ -1070,8 +1100,9 @@ void create_listener(void) if(result) { PERROR("pthread_sigmask: %s", strerror(result)); } - - have_listener = 1; + else { + have_listener = 1; + } } static int init_socket(void) @@ -1369,10 +1400,13 @@ int restarting_usleep(useconds_t usecs) return result; } -static void stop_listener() +static void stop_listener(void) { int result; + if(!have_listener) + return; + result = pthread_cancel(listener_thread); if(result != 0) { ERR("pthread_cancel: %s", strerror(result));