mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-31 01:43:02 +08:00
Problem: test_client/server_drop_more are invalid
These tests connected CLIENT and SERVER to DEALER... this isn't allowed. I changed to CLIENT-to-SERVER in both cases. The result was aborts in client.cpp and server.cpp which cannot handle invalid multipart data. I removed the asserts in each of these in xsend. Solution: fix the test cases and remove the (unwanted?) asserts in client.cpp:xsend and server.cpp:xsend.
This commit is contained in:
parent
c2dffb9908
commit
6b00f40f74
@ -54,8 +54,6 @@ void zmq::client_t::xattach_pipe (pipe_t *pipe_, bool subscribe_to_all_)
|
|||||||
|
|
||||||
int zmq::client_t::xsend (msg_t *msg_)
|
int zmq::client_t::xsend (msg_t *msg_)
|
||||||
{
|
{
|
||||||
zmq_assert(!(msg_->flags () & msg_t::more));
|
|
||||||
|
|
||||||
return lb.sendpipe (msg_, NULL);
|
return lb.sendpipe (msg_, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +93,6 @@ void zmq::server_t::xwrite_activated (pipe_t *pipe_)
|
|||||||
|
|
||||||
int zmq::server_t::xsend (msg_t *msg_)
|
int zmq::server_t::xsend (msg_t *msg_)
|
||||||
{
|
{
|
||||||
zmq_assert(!(msg_->flags () & msg_t::more));
|
|
||||||
|
|
||||||
// Find the pipe associated with the routing stored in the message.
|
// Find the pipe associated with the routing stored in the message.
|
||||||
uint32_t routing_id = msg_->get_routing_id ();
|
uint32_t routing_id = msg_->get_routing_id ();
|
||||||
outpipes_t::iterator it = outpipes.find (routing_id);
|
outpipes_t::iterator it = outpipes.find (routing_id);
|
||||||
|
@ -38,14 +38,14 @@ int main (void)
|
|||||||
assert (ctx);
|
assert (ctx);
|
||||||
|
|
||||||
void *client = zmq_socket (ctx, ZMQ_CLIENT);
|
void *client = zmq_socket (ctx, ZMQ_CLIENT);
|
||||||
void *dealer = zmq_socket (ctx, ZMQ_DEALER);
|
void *server = zmq_socket (ctx, ZMQ_SERVER);
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = zmq_bind (client, "inproc://serverdropmore");
|
rc = zmq_bind (client, "inproc://serverdropmore");
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
|
||||||
rc = zmq_connect (dealer, "inproc://serverdropmore");
|
rc = zmq_connect (server, "inproc://serverdropmore");
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
|
||||||
zmq_msg_t msg;
|
zmq_msg_t msg;
|
||||||
@ -53,28 +53,28 @@ int main (void)
|
|||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
|
||||||
// we will send 2 3-frames messages and then single frame message, only last one should be received
|
// we will send 2 3-frames messages and then single frame message, only last one should be received
|
||||||
rc = send_msg (&msg, dealer, ZMQ_SNDMORE, 1);
|
rc = send_msg (&msg, client, ZMQ_SNDMORE, 1);
|
||||||
assert(rc == 1);
|
assert(rc == 1);
|
||||||
|
|
||||||
rc = send_msg (&msg, dealer, ZMQ_SNDMORE, 2);
|
rc = send_msg (&msg, client, ZMQ_SNDMORE, 2);
|
||||||
assert(rc == 1);
|
assert(rc == 1);
|
||||||
|
|
||||||
rc = send_msg (&msg, dealer, 0, 3);
|
rc = send_msg (&msg, client, 0, 3);
|
||||||
assert(rc == 1);
|
assert(rc == 1);
|
||||||
|
|
||||||
rc = send_msg (&msg, dealer, ZMQ_SNDMORE, 4);
|
rc = send_msg (&msg, client, ZMQ_SNDMORE, 4);
|
||||||
assert(rc == 1);
|
assert(rc == 1);
|
||||||
|
|
||||||
rc = send_msg (&msg, dealer, ZMQ_SNDMORE, 5);
|
rc = send_msg (&msg, client, ZMQ_SNDMORE, 5);
|
||||||
assert(rc == 1);
|
assert(rc == 1);
|
||||||
|
|
||||||
rc = send_msg (&msg, dealer, 0, 6);
|
rc = send_msg (&msg, client, 0, 6);
|
||||||
assert(rc == 1);
|
assert(rc == 1);
|
||||||
|
|
||||||
rc = send_msg (&msg, dealer, 0, 7);
|
rc = send_msg (&msg, client, 0, 7);
|
||||||
assert(rc == 1);
|
assert(rc == 1);
|
||||||
|
|
||||||
rc = zmq_msg_recv (&msg, client, 0);
|
rc = zmq_msg_recv (&msg, server, 0);
|
||||||
assert (rc == 1);
|
assert (rc == 1);
|
||||||
|
|
||||||
assert (zmq_msg_more (&msg) == 0);
|
assert (zmq_msg_more (&msg) == 0);
|
||||||
@ -88,7 +88,7 @@ int main (void)
|
|||||||
rc = zmq_close (client);
|
rc = zmq_close (client);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
|
||||||
rc = zmq_close (dealer);
|
rc = zmq_close (server);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
|
||||||
rc = zmq_ctx_term (ctx);
|
rc = zmq_ctx_term (ctx);
|
||||||
@ -100,12 +100,10 @@ int main (void)
|
|||||||
int send_msg (zmq_msg_t *msg, void *s, int flags, int value)
|
int send_msg (zmq_msg_t *msg, void *s, int flags, int value)
|
||||||
{
|
{
|
||||||
int rc = zmq_msg_close (msg);
|
int rc = zmq_msg_close (msg);
|
||||||
|
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
zmq_msg_init_size (msg, 1);
|
zmq_msg_init_size (msg, 1);
|
||||||
|
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ int main (void)
|
|||||||
assert (ctx);
|
assert (ctx);
|
||||||
|
|
||||||
void *server = zmq_socket (ctx, ZMQ_SERVER);
|
void *server = zmq_socket (ctx, ZMQ_SERVER);
|
||||||
void *client = zmq_socket (ctx, ZMQ_DEALER);
|
void *client = zmq_socket (ctx, ZMQ_CLIENT);
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@ -100,12 +100,10 @@ int main (void)
|
|||||||
int send_msg (zmq_msg_t *msg, void *s, int flags, int value)
|
int send_msg (zmq_msg_t *msg, void *s, int flags, int value)
|
||||||
{
|
{
|
||||||
int rc = zmq_msg_close (msg);
|
int rc = zmq_msg_close (msg);
|
||||||
|
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
zmq_msg_init_size (msg, 1);
|
zmq_msg_init_size (msg, 1);
|
||||||
|
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user