Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions c_src/erlzmq_nif.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ NIF(erlzmq_nif_context)
sizeof(erlzmq_context_t));
assert(context);
context->context_zmq = zmq_init(thread_count);
assert(context->context_zmq);
if (!context->context_zmq) {
return return_zmq_errno(env, zmq_errno());
}

char thread_socket_id[64];
sprintf(thread_socket_id, "inproc://erlzmq-%ld", (long int) context);
Expand Down Expand Up @@ -195,7 +197,9 @@ NIF(erlzmq_nif_socket)
socket->context = context;
socket->socket_index = context->socket_index++;
socket->socket_zmq = zmq_socket(context->context_zmq, socket_type);
assert(socket->socket_zmq);
if (!socket->socket_zmq) {
return return_zmq_errno(env, zmq_errno());
}
socket->active = active;
socket->mutex = enif_mutex_create("erlzmq_socket_t_mutex");
assert(socket->mutex);
Expand Down
3 changes: 3 additions & 0 deletions test/erlzmq_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ reqrep_tcp_test() ->
basic_tests("tcp://127.0.0.1:5556", req, rep, active),
basic_tests("tcp://127.0.0.1:5557", req, rep, passive).

bad_init_test() ->
?assertEqual({error, einval}, erlzmq:context(-1)).

shutdown_stress_test() ->
?assertMatch(ok, shutdown_stress_loop(10)).

Expand Down