Skip to content

Commit c9dd12e

Browse files
zbud-msftbradh352
authored andcommitted
Ignore control character event if it comes (sonic-net#21200)
Why I did it Fixes sonic-net#21140 In sonic-net#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 sonic-net#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
1 parent 8631be6 commit c9dd12e

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/sonic-eventd/tests/eventd_ut.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,12 @@ void run_cap(void *zctx, bool &term, string &read_source,
164164
EXPECT_EQ(0, zmq_setsockopt(mock_cap, ZMQ_SUBSCRIBE, "", 0));
165165
EXPECT_EQ(0, zmq_setsockopt(mock_cap, ZMQ_RCVTIMEO, &block_ms, sizeof (block_ms)));
166166

167-
zmq_msg_t msg;
168-
zmq_msg_init(&msg);
169-
int rc = zmq_msg_recv(&msg, mock_cap, 0);
170-
EXPECT_EQ(1, rc); // read control character
171167

172168
while(!term) {
173169
string source;
174170
internal_event_t ev_int;
175-
176-
if (0 == zmq_message_read(mock_cap, 0, source, ev_int)) {
171+
int rc = zmq_message_read(mock_cap, 0, source, ev_int);
172+
if (0 == rc && !ev_int.empty()) { // ignore control character empty event
177173
cnt = ++i;
178174
}
179175
}

0 commit comments

Comments
 (0)