diff options
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/ruby/rbzmq.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/bindings/ruby/rbzmq.cpp b/bindings/ruby/rbzmq.cpp index 9683de4..1a31f6b 100644 --- a/bindings/ruby/rbzmq.cpp +++ b/bindings/ruby/rbzmq.cpp @@ -18,7 +18,6 @@ */ #include <assert.h> -#include <errno.h> #include <string.h> #include <ruby.h> @@ -44,7 +43,7 @@ static VALUE context_initialize (VALUE self_, VALUE app_threads_, void *ctx = zmq_init (NUM2INT (app_threads_), NUM2INT (io_threads_), NUM2INT (flags_)); if (!ctx) { - rb_raise (rb_eRuntimeError, zmq_strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (zmq_errno ())); return Qnil; } @@ -76,7 +75,7 @@ static VALUE socket_initialize (VALUE self_, VALUE context_, VALUE type_) void *s = zmq_socket (DATA_PTR (context_), NUM2INT (type_)); if (!s) { - rb_raise (rb_eRuntimeError, zmq_strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (zmq_errno ())); return Qnil; } @@ -118,12 +117,12 @@ static VALUE socket_setsockopt (VALUE self_, VALUE option_, break; default: - rc = -1; - errno = EINVAL; + rb_raise (rb_eRuntimeError, zmq_strerror (EINVAL)); + return Qnil; } if (rc != 0) { - rb_raise (rb_eRuntimeError, zmq_strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (zmq_errno ())); return Qnil; } @@ -137,7 +136,7 @@ static VALUE socket_bind (VALUE self_, VALUE addr_) int rc = zmq_bind (DATA_PTR (self_), rb_string_value_cstr (&addr_)); if (rc != 0) { - rb_raise (rb_eRuntimeError, zmq_strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (zmq_errno ())); return Qnil; } @@ -150,7 +149,7 @@ static VALUE socket_connect (VALUE self_, VALUE addr_) int rc = zmq_connect (DATA_PTR (self_), rb_string_value_cstr (&addr_)); if (rc != 0) { - rb_raise (rb_eRuntimeError, zmq_strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (zmq_errno ())); return Qnil; } @@ -166,20 +165,20 @@ static VALUE socket_send (VALUE self_, VALUE msg_, VALUE flags_) zmq_msg_t msg; int rc = zmq_msg_init_size (&msg, RSTRING_LEN (msg_)); if (rc != 0) { - rb_raise (rb_eRuntimeError, zmq_strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (zmq_errno ())); return Qnil; } memcpy (zmq_msg_data (&msg), RSTRING_PTR (msg_), RSTRING_LEN (msg_)); rc = zmq_send (DATA_PTR (self_), &msg, NUM2INT (flags_)); - if (rc != 0 && errno == EAGAIN) { + if (rc != 0 && zmq_errno () == EAGAIN) { rc = zmq_msg_close (&msg); assert (rc == 0); return Qfalse; } if (rc != 0) { - rb_raise (rb_eRuntimeError, zmq_strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (zmq_errno ())); rc = zmq_msg_close (&msg); assert (rc == 0); return Qnil; @@ -196,7 +195,7 @@ static VALUE socket_flush (VALUE self_) int rc = zmq_flush (DATA_PTR (self_)); if (rc != 0) { - rb_raise (rb_eRuntimeError, zmq_strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (zmq_errno ())); return Qnil; } @@ -212,14 +211,14 @@ static VALUE socket_recv (VALUE self_, VALUE flags_) assert (rc == 0); rc = zmq_recv (DATA_PTR (self_), &msg, NUM2INT (flags_)); - if (rc != 0 && errno == EAGAIN) { + if (rc != 0 && zmq_errno () == EAGAIN) { rc = zmq_msg_close (&msg); assert (rc == 0); return Qnil; } if (rc != 0) { - rb_raise (rb_eRuntimeError, zmq_strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (zmq_errno ())); rc = zmq_msg_close (&msg); assert (rc == 0); return Qnil; |