Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
8980a985
Commit
8980a985
authored
Feb 24, 2010
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zmq_error used from ruby binding
parent
551fa104
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
14 deletions
+13
-14
rbzmq.cpp
bindings/ruby/rbzmq.cpp
+13
-14
No files found.
bindings/ruby/rbzmq.cpp
View file @
8980a985
...
...
@@ -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:
r
c
=
-
1
;
errno
=
EINVAL
;
r
b_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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment