projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: relayd and sessiond: dispatch thread exit is shared across threads
[lttng-tools.git]
/
src
/
bin
/
lttng-relayd
/
main.c
diff --git
a/src/bin/lttng-relayd/main.c
b/src/bin/lttng-relayd/main.c
index 5a12ba88847b01ef631639bf2a123fe63deb5cd4..81f10b78368c46401085477a51b799f90cf8fb19 100644
(file)
--- a/
src/bin/lttng-relayd/main.c
+++ b/
src/bin/lttng-relayd/main.c
@@
-74,6
+74,7
@@
static int thread_quit_pipe[2] = { -1, -1 };
*/
static int relay_cmd_pipe[2] = { -1, -1 };
*/
static int relay_cmd_pipe[2] = { -1, -1 };
+/* Shared between threads */
static int dispatch_thread_exit;
static pthread_t listener_thread;
static int dispatch_thread_exit;
static pthread_t listener_thread;
@@
-246,7
+247,9
@@
int notify_thread_pipe(int wpipe)
{
int ret;
{
int ret;
- ret = write(wpipe, "!", 1);
+ do {
+ ret = write(wpipe, "!", 1);
+ } while (ret < 0 && errno == EINTR);
if (ret < 0) {
PERROR("write poll pipe");
}
if (ret < 0) {
PERROR("write poll pipe");
}
@@
-270,7
+273,7
@@
void stop_threads(void)
}
/* Dispatch thread */
}
/* Dispatch thread */
-
dispatch_thread_exit = 1
;
+
CMM_STORE_SHARED(dispatch_thread_exit, 1)
;
futex_nto1_wake(&relay_cmd_queue.futex);
}
futex_nto1_wake(&relay_cmd_queue.futex);
}
@@
-606,7
+609,7
@@
void *relay_thread_dispatcher(void *data)
DBG("[thread] Relay dispatcher started");
DBG("[thread] Relay dispatcher started");
- while (!
dispatch_thread_exit
) {
+ while (!
CMM_LOAD_SHARED(dispatch_thread_exit)
) {
/* Atomically prepare the queue futex */
futex_nto1_prepare(&relay_cmd_queue.futex);
/* Atomically prepare the queue futex */
futex_nto1_prepare(&relay_cmd_queue.futex);
@@
-627,8
+630,10
@@
void *relay_thread_dispatcher(void *data)
* call is blocking so we can be assured that the data will be read
* at some point in time or wait to the end of the world :)
*/
* call is blocking so we can be assured that the data will be read
* at some point in time or wait to the end of the world :)
*/
- ret = write(relay_cmd_pipe[1], relay_cmd,
- sizeof(struct relay_command));
+ do {
+ ret = write(relay_cmd_pipe[1], relay_cmd,
+ sizeof(struct relay_command));
+ } while (ret < 0 && errno == EINTR);
free(relay_cmd);
if (ret < 0) {
PERROR("write cmd pipe");
free(relay_cmd);
if (ret < 0) {
PERROR("write cmd pipe");
@@
-1054,8
+1059,10
@@
int relay_recv_metadata(struct lttcomm_relayd_hdr *recv_hdr,
goto end;
}
goto end;
}
- ret = write(metadata_stream->fd, metadata_struct->payload,
- payload_size);
+ do {
+ ret = write(metadata_stream->fd, metadata_struct->payload,
+ payload_size);
+ } while (ret < 0 && errno == EINTR);
if (ret < (payload_size)) {
ERR("Relay error writing metadata on file");
ret = -1;
if (ret < (payload_size)) {
ERR("Relay error writing metadata on file");
ret = -1;
@@
-1189,7
+1196,9
@@
int relay_process_data(struct relay_command *cmd, struct lttng_ht *streams_ht)
goto end;
}
goto end;
}
- ret = write(stream->fd, data_buffer, data_size);
+ do {
+ ret = write(stream->fd, data_buffer, data_size);
+ } while (ret < 0 && errno == EINTR);
if (ret < data_size) {
ERR("Relay error writing data to file");
ret = -1;
if (ret < data_size) {
ERR("Relay error writing data to file");
ret = -1;
This page took
0.025103 seconds
and
4
git commands to generate.