add get/set commands for daemon socket path
[ust.git] / libust / tracectl.c
index 2f9215e65b29adc0df6095ce72c206425304c559..1b684445e63f1a2efa38bd59f0678f018adb6a9a 100644 (file)
@@ -994,6 +994,25 @@ 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 {
                ERR("unable to parse message: %s", recvbuf);
        }
@@ -1070,8 +1089,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 +1389,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));
This page took 0.023345 seconds and 4 git commands to generate.