Skip to content

Commit

Permalink
Merge pull request #188 from aboseley/bugfix-handling-zmq_ctx_set-result
Browse files Browse the repository at this point in the history
context_ops: fix bug handling zmq_ctx_set result
  • Loading branch information
aboseley authored Nov 8, 2021
2 parents 810d888 + a7e7d0d commit 92ff7ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion azmq/detail/context_ops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace detail {
boost::system::error_code & ec) {
BOOST_ASSERT_MSG(ctx, "context must not be null");
auto rc = zmq_ctx_set(ctx.get(), option.name(), option.value());
if (!rc)
if (rc < 0)
ec = make_error_code();
return ec;
}
Expand Down
9 changes: 9 additions & 0 deletions test/context_ops/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,12 @@ TEST_CASE( "context_options", "[context]" ) {
REQUIRE(!ec);
REQUIRE(res.value() == 2);
}

TEST_CASE( "invalid option", "[context]" ) {
auto ctx = azmq::detail::context_ops::get_context();
using io_threads = azmq::detail::context_ops::io_threads;
boost::system::error_code ec;
azmq::detail::context_ops::set_option(ctx, io_threads(-1), ec);
REQUIRE(ec);
REQUIRE(ec.value() == EINVAL);
}

0 comments on commit 92ff7ff

Please sign in to comment.