From 92db7cdc97f4bb5776fa698442d8af4e5c1e3bf3 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Mon, 26 Aug 2013 15:34:06 -0400 Subject: [PATCH] Improve comments after review Acked-by: Mathieu Desnoyers Signed-off-by: David Goulet --- src/bin/lttng-sessiond/consumer.c | 8 ++++---- src/bin/lttng-sessiond/consumer.h | 6 +++++- src/bin/lttng-sessiond/main.c | 8 +++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index d79dee3ca..8f05476a7 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -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. */ diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h index d9a783599..27da4e38c 100644 --- a/src/bin/lttng-sessiond/consumer.h +++ b/src/bin/lttng-sessiond/consumer.h @@ -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; }; diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 85904c812..195174a4e 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -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); -- 2.34.1