summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2010-08-28 08:44:12 +0200
committerMartin Sustrik <sustrik@250bpm.com>2010-08-28 08:44:12 +0200
commit92923cd40b645af844c5ed1055a0a45c6daa3c89 (patch)
tree9543dfec1918d142dd757bcf1378af65ecea6e3d
parent035c937ee7452708a9dd3abd851fda6a753808f4 (diff)
bug in pipe deactivation fixed
-rw-r--r--src/pipe.cpp8
-rw-r--r--src/socket_base.cpp2
-rw-r--r--tests/test_pair.cpp7
-rw-r--r--tests/test_reqrep.cpp4
4 files changed, 10 insertions, 11 deletions
diff --git a/src/pipe.cpp b/src/pipe.cpp
index 5780635..8785330 100644
--- a/src/pipe.cpp
+++ b/src/pipe.cpp
@@ -80,11 +80,8 @@ bool zmq::reader_t::check_read ()
return false;
// Check if there's an item in the pipe.
- // If not, deactivate the pipe.
- if (!pipe->check_read ()) {
- terminate ();
+ if (!pipe->check_read ())
return false;
- }
// If the next item in the pipe is message delimiter,
// initiate its termination.
@@ -198,7 +195,8 @@ bool zmq::writer_t::check_write ()
if (terminating)
return false;
- if (pipe_full () && (msg_store == NULL || msg_store->full () || extra_msg_flag)) {
+ if (pipe_full () && (msg_store == NULL || msg_store->full () ||
+ extra_msg_flag)) {
stalled = true;
return false;
}
diff --git a/src/socket_base.cpp b/src/socket_base.cpp
index f575c0a..fe06d2f 100644
--- a/src/socket_base.cpp
+++ b/src/socket_base.cpp
@@ -244,7 +244,7 @@ int zmq::socket_base_t::getsockopt (int option_, void *optval_,
errno = EINVAL;
return -1;
}
- process_commands(false, false);
+ process_commands (false, false);
*((uint32_t*) optval_) = 0;
if (has_out ())
*((uint32_t*) optval_) |= ZMQ_POLLOUT;
diff --git a/tests/test_pair.cpp b/tests/test_pair.cpp
index 381874f..c10e0a6 100644
--- a/tests/test_pair.cpp
+++ b/tests/test_pair.cpp
@@ -39,9 +39,10 @@ int main ()
{
const string returned = zmqtestutil::ping_pong (p, expect);
assert (expect == returned);
+
// Adjust socket state so that poll shows only 1 pending message.
zmq::message_t mx ;
- p.first->recv(&mx, 0);
+ p.first->recv (&mx, 0);
}
{
@@ -58,8 +59,7 @@ int main ()
p.first->send (m1, 0);
- // Now use polling. Timout makes test abort on error.
- int rc = zmq::poll (&items [0], 2, 1000);
+ int rc = zmq::poll (&items [0], 2, -1);
assert (rc == 1);
assert ((items [1].revents & ZMQ_POLLIN) != 0);
@@ -74,4 +74,5 @@ int main ()
delete (p.second);
return 0 ;
+assert (false);
}
diff --git a/tests/test_reqrep.cpp b/tests/test_reqrep.cpp
index f33b4b5..eab7e8b 100644
--- a/tests/test_reqrep.cpp
+++ b/tests/test_reqrep.cpp
@@ -39,6 +39,7 @@ int main()
{
const string returned = zmqtestutil::ping_pong (p, expect);
assert (expect == returned);
+
// Adjust socket state, so that first is clean for another send.
zmq::message_t mx ;
p.first->recv(&mx, 0);
@@ -58,8 +59,7 @@ int main()
p.first->send (m1, 0);
- // Now use polling. Timout makes test abort on error.
- int rc = zmq::poll(&items [0], 2, 1000);
+ int rc = zmq::poll(&items [0], 2, -1);
assert (rc == 1);
assert ((items [1].revents & ZMQ_POLLIN) != 0);