Skip to content

Commit

Permalink
Ignore control character event if it comes (#21200)
Browse files Browse the repository at this point in the history
Why I did it
Fixes #21140

In #20024 and sonic-net/sonic-swss-common#906, we made the change that when a control character is read, zmq_message_read will return with rc 0, which will create an empty internal event.

As part of eventd design, empty structured events are dropped, which leads to control characters being a no-op which is the expected behavior.

In UT, we are still always expecting a control character to be the first message to be read by zmq which is not the case as described in #20024. We are also not ignoring empty events that are read which is being done by eventd.

With this change, control characters are properly ignored if it does after the first test event.

How I did it
Ignore empty structured events and not expect first zmq_message_read to be control character.

How to verify it
Manual test/pipeline
  • Loading branch information
zbud-msft authored and mssonicbld committed Dec 25, 2024
1 parent d219d4a commit d8afbcd
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/sonic-eventd/tests/eventd_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,12 @@ void run_cap(void *zctx, bool &term, string &read_source,
EXPECT_EQ(0, zmq_setsockopt(mock_cap, ZMQ_SUBSCRIBE, "", 0));
EXPECT_EQ(0, zmq_setsockopt(mock_cap, ZMQ_RCVTIMEO, &block_ms, sizeof (block_ms)));

zmq_msg_t msg;
zmq_msg_init(&msg);
int rc = zmq_msg_recv(&msg, mock_cap, 0);
EXPECT_EQ(1, rc); // read control character

while(!term) {
string source;
internal_event_t ev_int;

if (0 == zmq_message_read(mock_cap, 0, source, ev_int)) {
int rc = zmq_message_read(mock_cap, 0, source, ev_int);
if (0 == rc && !ev_int.empty()) { // ignore control character empty event
cnt = ++i;
}
}
Expand Down

0 comments on commit d8afbcd

Please sign in to comment.