inet/inet6 sockets: apply timeout
[lttng-tools.git] / src / bin / lttng-sessiond / main.c
index 048c1e16d83feb66ff4c499470189e655e163727..d22e2a63d7d5d96526a7e93b2c2761a0c0894924 100644 (file)
@@ -446,7 +446,10 @@ static void cleanup(void)
 
        DBG("Cleaning up");
 
-       /* First thing first, stop all threads */
+       /*
+        * Close the thread quit pipe. It has already done its job,
+        * since we are now called.
+        */
        utils_close_pipe(thread_quit_pipe);
 
        /*
@@ -675,6 +678,8 @@ static int update_kernel_stream(struct consumer_data *consumer_data, int fd)
                                if (ret < 0) {
                                        goto error;
                                }
+                               /* Update the stream global counter */
+                               ksess->stream_count_global += ret;
 
                                /*
                                 * Have we already sent fds to the consumer? If yes, it means
@@ -1293,11 +1298,17 @@ static void *thread_manage_apps(void *data)
                                                goto error;
                                        }
 
-                                       /* Set socket timeout for both receiving and ending */
+                                       /*
+                                        * Set socket timeout for both receiving and ending.
+                                        * app_socket_timeout is in seconds, whereas
+                                        * lttcomm_setsockopt_rcv_timeout and
+                                        * lttcomm_setsockopt_snd_timeout expect msec as
+                                        * parameter.
+                                        */
                                        (void) lttcomm_setsockopt_rcv_timeout(sock,
-                                                       app_socket_timeout);
+                                                       app_socket_timeout * 1000);
                                        (void) lttcomm_setsockopt_snd_timeout(sock,
-                                                       app_socket_timeout);
+                                                       app_socket_timeout * 1000);
 
                                        DBG("Apps with sock %d added to poll set", sock);
 
@@ -2428,6 +2439,7 @@ static int create_ust_session(struct ltt_session *session,
        lus->uid = session->uid;
        lus->gid = session->gid;
        lus->output_traces = session->output_traces;
+       lus->snapshot_mode = session->snapshot_mode;
        session->ust_session = lus;
 
        /* Copy session output to the newly created UST session */
@@ -2485,6 +2497,7 @@ static int create_kernel_session(struct ltt_session *session)
        session->kernel_session->uid = session->uid;
        session->kernel_session->gid = session->gid;
        session->kernel_session->output_traces = session->output_traces;
+       session->kernel_session->snapshot_mode = session->snapshot_mode;
 
        return LTTNG_OK;
 
@@ -2540,6 +2553,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock,
 
        switch (cmd_ctx->lsm->cmd_type) {
        case LTTNG_CREATE_SESSION:
+       case LTTNG_CREATE_SESSION_SNAPSHOT:
        case LTTNG_DESTROY_SESSION:
        case LTTNG_LIST_SESSIONS:
        case LTTNG_LIST_DOMAINS:
@@ -2602,6 +2616,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock,
        /* Commands that DO NOT need a session. */
        switch (cmd_ctx->lsm->cmd_type) {
        case LTTNG_CREATE_SESSION:
+       case LTTNG_CREATE_SESSION_SNAPSHOT:
        case LTTNG_CALIBRATE:
        case LTTNG_LIST_SESSIONS:
        case LTTNG_LIST_TRACEPOINTS:
@@ -3293,6 +3308,45 @@ skip_domain:
                                cmd_ctx->lsm->u.snapshot_record.wait);
                break;
        }
+       case LTTNG_CREATE_SESSION_SNAPSHOT:
+       {
+               size_t nb_uri, len;
+               struct lttng_uri *uris = NULL;
+
+               nb_uri = cmd_ctx->lsm->u.uri.size;
+               len = nb_uri * sizeof(struct lttng_uri);
+
+               if (nb_uri > 0) {
+                       uris = zmalloc(len);
+                       if (uris == NULL) {
+                               ret = LTTNG_ERR_FATAL;
+                               goto error;
+                       }
+
+                       /* Receive variable len data */
+                       DBG("Waiting for %zu URIs from client ...", nb_uri);
+                       ret = lttcomm_recv_unix_sock(sock, uris, len);
+                       if (ret <= 0) {
+                               DBG("No URIs received from client... continuing");
+                               *sock_error = 1;
+                               ret = LTTNG_ERR_SESSION_FAIL;
+                               free(uris);
+                               goto error;
+                       }
+
+                       if (nb_uri == 1 && uris[0].dtype != LTTNG_DST_PATH) {
+                               DBG("Creating session with ONE network URI is a bad call");
+                               ret = LTTNG_ERR_SESSION_FAIL;
+                               free(uris);
+                               goto error;
+                       }
+               }
+
+               ret = cmd_create_session_snapshot(cmd_ctx->lsm->session.name, uris,
+                               nb_uri, &cmd_ctx->creds);
+               free(uris);
+               break;
+       }
        default:
                ret = LTTNG_ERR_UND;
                break;
@@ -4583,6 +4637,9 @@ int main(int argc, char **argv)
 
        write_pidfile();
 
+       /* Initialize communication library */
+       lttcomm_init();
+
        /* Create thread to manage the client socket */
        ret = pthread_create(&ht_cleanup_thread, NULL,
                        thread_ht_cleanup, (void *) NULL);
This page took 0.027546 seconds and 4 git commands to generate.