Skip to content

Commit

Permalink
Fix ldmsd_stream_subscribe intermingled events output
Browse files Browse the repository at this point in the history
Multiple threads in `ldmsd_stream_subscribe` can race to handle stream
recv events. The recv handler called `msglog()` multiple times to print
out the EVENT. This lead to intermingled events in the output. This
patch modifies the handler to print the events in single msglog call to
avoid the intermingled output.
  • Loading branch information
narategithub authored and tom95858 committed Aug 13, 2023
1 parent 01093a7 commit 1e4c27f
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions ldms/src/ldmsd/test/ldmsd_stream_subscribe.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,13 @@ static int stream_unsubscribe_status_ev(ldms_stream_event_t ev, void *arg)

static int stream_recv_ev(ldms_stream_event_t ev, void *arg)
{
if (!events_raw) {
if (ev->recv.type == LDMS_STREAM_STRING)
msglog("EVENT:{\"type\":\"string\",\"size\":%d,\"event\":", ev->recv.data_len);
else
msglog("EVENT:{\"type\":\"json\",\"size\":%d,\"event\":", ev->recv.data_len);
if (events_raw) {
msglog("%s\n", ev->recv.data);
return 0;
}
msglog(ev->recv.data);
if (!events_raw)
msglog("}");
msglog("\n");
msglog("EVENT:{\"type\":\"%s\",\"size\":%d,\"event\":%s}\n",
LDMS_STREAM_STRING ? "string" : "json",
ev->recv.data_len, ev->recv.data);
return 0;
}

Expand Down

0 comments on commit 1e4c27f

Please sign in to comment.