Improve comments after review
authorDavid Goulet <dgoulet@efficios.com>
Mon, 26 Aug 2013 19:34:06 +0000 (15:34 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 26 Aug 2013 19:40:13 +0000 (15:40 -0400)
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/consumer.c
src/bin/lttng-sessiond/consumer.h
src/bin/lttng-sessiond/main.c

index d79dee3cafd99c1232f2458a985561fb0e7a1875..8f05476a7fe606935d8f3fcca23d75b2e945bb43 100644 (file)
@@ -62,8 +62,8 @@ int consumer_socket_send(struct consumer_socket *socket, void *msg, size_t len)
                /* The above call will print a PERROR on error. */
                DBG("Error when sending data to consumer on sock %d", fd);
                /*
-                * At this point, the socket is not usable anymore thus flagging it
-                * invalid and closing it.
+                * At this point, the socket is not usable anymore thus closing it and
+                * setting the file descriptor to -1 so it is not reused.
                 */
 
                /* This call will PERROR on error. */
@@ -106,8 +106,8 @@ int consumer_socket_recv(struct consumer_socket *socket, void *msg, size_t len)
                /* The above call will print a PERROR on error. */
                DBG("Error when receiving data from the consumer socket %d", fd);
                /*
-                * At this point, the socket is not usable anymore thus flagging it
-                * invalid and closing it.
+                * At this point, the socket is not usable anymore thus closing it and
+                * setting the file descriptor to -1 so it is not reused.
                 */
 
                /* This call will PERROR on error. */
index d9a78359926516cc311bc7ee5dc63f44bf080079..27da4e38c2bfa7e70a460e4c61abeec40cd82e0b 100644 (file)
@@ -105,7 +105,11 @@ struct consumer_data {
        char err_unix_sock_path[PATH_MAX];
        char cmd_unix_sock_path[PATH_MAX];
 
-       /* communication lock */
+       /*
+        * This lock has two purposes. It protects any change to the consumer
+        * socket and make sure only one thread uses this object for read/write
+        * operations.
+        */
        pthread_mutex_t lock;
 };
 
index 85904c812cdbab2f53ef0747014ad274a2e38ac4..195174a4edf259d24e2e0d523f0dd243805e4f01 100644 (file)
@@ -1021,7 +1021,8 @@ restart:
                        lttcomm_connect_unix_sock(consumer_data->cmd_unix_sock_path);
                consumer_data->metadata_fd =
                        lttcomm_connect_unix_sock(consumer_data->cmd_unix_sock_path);
-               if (consumer_data->cmd_sock < 0 || consumer_data->metadata_fd < 0) {
+               if (consumer_data->cmd_sock < 0
+                               || consumer_data->metadata_fd < 0) {
                        PERROR("consumer connect cmd socket");
                        /* On error, signal condition and quit. */
                        signal_consumer_condition(consumer_data, -1);
@@ -1140,8 +1141,8 @@ exit:
 error:
        /*
         * We lock here because we are about to close the sockets and some other
-        * thread might be using them so wait before we are exclusive which will
-        * abort all other consumer command by other threads.
+        * thread might be using them so get exclusive access which will abort all
+        * other consumer command by other threads.
         */
        pthread_mutex_lock(&consumer_data->lock);
 
@@ -1188,6 +1189,7 @@ error:
        unlink(consumer_data->cmd_unix_sock_path);
        consumer_data->pid = 0;
        pthread_mutex_unlock(&consumer_data->lock);
+
        /* Cleanup metadata socket mutex. */
        pthread_mutex_destroy(consumer_data->metadata_sock.lock);
        free(consumer_data->metadata_sock.lock);
This page took 0.02994 seconds and 5 git commands to generate.