-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address comments from PR 812: Add check before deserializing messages #816
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,19 +81,24 @@ TEST(events_common, send_recv) | |
void *sock_p1 = zmq_socket (zmq_ctx, ZMQ_PAIR); | ||
EXPECT_EQ(0, zmq_bind (sock_p1, path)); | ||
|
||
string source("Hello"), source1, source2("#"); | ||
string source("Hello"), source1, source2, source3; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Ut can pass without any code change in zmq_read_part, which means the UT change is not necessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By read the eventd code, I found it's using event_service. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussion offline ,suggest revert this PR. |
||
|
||
map<string, string> m = {{"foo", "bar"}, {"hello", "world"}, {"good", "day"}}; | ||
map<string, string> m1, m2; | ||
map<string, string> m1, m2, m3; | ||
|
||
EXPECT_EQ(0, zmq_message_send(sock_p0, source, m)); | ||
|
||
EXPECT_EQ(0, zmq_message_read(sock_p1, 0, source1, m1)); | ||
|
||
EXPECT_EQ(source, source1); | ||
EXPECT_EQ(m, m1); | ||
|
||
|
||
EXPECT_EQ(0, zmq_message_send(sock_p0, source2, m2)); | ||
EXPECT_EQ(0, zmq_message_read(sock_p1, 0, source3, m3)); | ||
|
||
EXPECT_EQ(0, deserialize(source2, m2)); | ||
EXPECT_EQ(source2, source3); | ||
EXPECT_EQ(m2, m3); | ||
|
||
zmq_close(sock_p0); | ||
zmq_close(sock_p1); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I check eventd code, it's not use zmq_read_part, how this change can fix the original eventd issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By read eventd code, I found it's a code bug in channel read, please check following code and fix it:
int
event_service::channel_read(int &code, event_serialized_lst_t &data)
{
event_serialized_lst_t().swap(data);
return zmq_message_read(m_socket, 0, code, data); <== code is a int*
}
template<typename P1, typename P2>
int
zmq_message_read(void *sock, int flag, P1 &pt1, P2 &pt2)
{
auto render = boost::serialization::singleton::get_const_instance();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May not related with original issue, suggest create UT in other PR to fix.
#closed