Skip to content

Commit 92ff7ff

Browse files
authored
Merge pull request #188 from aboseley/bugfix-handling-zmq_ctx_set-result
context_ops: fix bug handling zmq_ctx_set result
2 parents 810d888 + a7e7d0d commit 92ff7ff

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

azmq/detail/context_ops.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace detail {
5353
boost::system::error_code & ec) {
5454
BOOST_ASSERT_MSG(ctx, "context must not be null");
5555
auto rc = zmq_ctx_set(ctx.get(), option.name(), option.value());
56-
if (!rc)
56+
if (rc < 0)
5757
ec = make_error_code();
5858
return ec;
5959
}

test/context_ops/main.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,12 @@ TEST_CASE( "context_options", "[context]" ) {
3939
REQUIRE(!ec);
4040
REQUIRE(res.value() == 2);
4141
}
42+
43+
TEST_CASE( "invalid option", "[context]" ) {
44+
auto ctx = azmq::detail::context_ops::get_context();
45+
using io_threads = azmq::detail::context_ops::io_threads;
46+
boost::system::error_code ec;
47+
azmq::detail::context_ops::set_option(ctx, io_threads(-1), ec);
48+
REQUIRE(ec);
49+
REQUIRE(ec.value() == EINVAL);
50+
}

0 commit comments

Comments
 (0)