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
a68e6739
Commit
a68e6739
authored
Sep 09, 2010
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
when no I/O threads are available error is raised instead of assertion
parent
47e87b7e
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
59 additions
and
19 deletions
+59
-19
zmq_bind.txt
doc/zmq_bind.txt
+2
-0
zmq_connect.txt
doc/zmq_connect.txt
+2
-0
zmq.h
include/zmq.h
+1
-1
connect_session.cpp
src/connect_session.cpp
+9
-4
ctx.cpp
src/ctx.cpp
+5
-2
ctx.hpp
src/ctx.hpp
+3
-2
object.cpp
src/object.cpp
+2
-2
object.hpp
src/object.hpp
+1
-1
socket_base.cpp
src/socket_base.cpp
+18
-3
zmq.cpp
src/zmq.cpp
+2
-0
zmq_connecter.cpp
src/zmq_connecter.cpp
+7
-2
zmq_listener.cpp
src/zmq_listener.cpp
+7
-2
No files found.
doc/zmq_bind.txt
View file @
a68e6739
...
...
@@ -58,6 +58,8 @@ The requested 'address' specifies a nonexistent interface.
The 0MQ 'context' associated with the specified 'socket' was terminated.
*EFAULT*::
The provided 'socket' was not valid (NULL).
*EMTHREAD*::
No I/O thread is available to accomplish the task.
EXAMPLE
...
...
doc/zmq_connect.txt
View file @
a68e6739
...
...
@@ -56,6 +56,8 @@ The requested 'transport' protocol is not compatible with the socket type.
The 0MQ 'context' associated with the specified 'socket' was terminated.
*EFAULT*::
The provided 'socket' was not valid (NULL).
*EMTHREAD*::
No I/O thread is available to accomplish the task.
EXAMPLE
...
...
include/zmq.h
View file @
a68e6739
...
...
@@ -85,7 +85,7 @@ ZMQ_EXPORT void zmq_version (int *major, int *minor, int *patch);
#define EFSM (ZMQ_HAUSNUMERO + 51)
#define ENOCOMPATPROTO (ZMQ_HAUSNUMERO + 52)
#define ETERM (ZMQ_HAUSNUMERO + 53)
#define EMTHREAD (ZMQ_HAUSNUMERO + 54)
/* Old error code, remove in 3.x */
#define EMTHREAD (ZMQ_HAUSNUMERO + 54)
/* This function retrieves the errno as it is known to 0MQ library. The goal */
/* of this function is to make the code 100% portable, including where 0MQ */
...
...
src/connect_session.cpp
View file @
a68e6739
...
...
@@ -43,13 +43,18 @@ void zmq::connect_session_t::process_plug ()
void
zmq
::
connect_session_t
::
start_connecting
()
{
// Choose I/O thread to run connecter in. Given that we are already
// running in an I/O thread, there must be at least one available.
io_thread_t
*
io_thread
=
choose_io_thread
(
options
.
affinity
);
zmq_assert
(
io_thread
);
// Create the connecter object.
// Both TCP and IPC transports are using the same infrastructure.
if
(
protocol
==
"tcp"
||
protocol
==
"ipc"
)
{
zmq_connecter_t
*
connecter
=
new
(
std
::
nothrow
)
zmq_connecter_t
(
choose_io_thread
(
options
.
affinity
),
this
,
options
,
protocol
.
c_str
(),
address
.
c_str
());
io_thread
,
this
,
options
,
protocol
.
c_str
(),
address
.
c_str
());
zmq_assert
(
connecter
);
launch_child
(
connecter
);
return
;
...
...
@@ -70,7 +75,7 @@ void zmq::connect_session_t::start_connecting ()
// PGM sender.
pgm_sender_t
*
pgm_sender
=
new
(
std
::
nothrow
)
pgm_sender_t
(
choose_io_thread
(
options
.
affinity
)
,
options
);
io_thread
,
options
);
zmq_assert
(
pgm_sender
);
int
rc
=
pgm_sender
->
init
(
udp_encapsulation
,
address
.
c_str
());
...
...
@@ -82,7 +87,7 @@ void zmq::connect_session_t::start_connecting ()
// PGM receiver.
pgm_receiver_t
*
pgm_receiver
=
new
(
std
::
nothrow
)
pgm_receiver_t
(
choose_io_thread
(
options
.
affinity
)
,
options
);
io_thread
,
options
);
zmq_assert
(
pgm_receiver
);
int
rc
=
pgm_receiver
->
init
(
udp_encapsulation
,
address
.
c_str
());
...
...
src/ctx.cpp
View file @
a68e6739
...
...
@@ -64,7 +64,8 @@ zmq::ctx_t::ctx_t (uint32_t io_threads_) :
}
// In the unused part of the slot array, create a list of empty slots.
for
(
uint32_t
i
=
slot_count
-
1
;
i
>=
io_threads_
;
i
--
)
{
for
(
int32_t
i
=
(
int32_t
)
slot_count
-
1
;
i
>=
(
int32_t
)
io_threads_
;
i
--
)
{
empty_slots
.
push_back
(
i
);
slots
[
i
]
=
NULL
;
}
...
...
@@ -221,8 +222,10 @@ void zmq::ctx_t::send_command (uint32_t slot_, const command_t &command_)
zmq
::
io_thread_t
*
zmq
::
ctx_t
::
choose_io_thread
(
uint64_t
affinity_
)
{
if
(
io_threads
.
empty
())
return
NULL
;
// Find the I/O thread with minimum load.
zmq_assert
(
io_threads
.
size
()
>
0
);
int
min_load
=
-
1
;
io_threads_t
::
size_type
result
=
0
;
for
(
io_threads_t
::
size_type
i
=
0
;
i
!=
io_threads
.
size
();
i
++
)
{
...
...
src/ctx.hpp
View file @
a68e6739
...
...
@@ -65,8 +65,9 @@ namespace zmq
void
send_command
(
uint32_t
slot_
,
const
command_t
&
command_
);
// Returns the I/O thread that is the least busy at the moment.
// Taskset specifies which I/O threads are eligible (0 = all).
class
io_thread_t
*
choose_io_thread
(
uint64_t
taskset_
);
// Affinity specifies which I/O threads are eligible (0 = all).
// Returns NULL is no I/O thread is available.
class
io_thread_t
*
choose_io_thread
(
uint64_t
affinity_
);
// Management of inproc endpoints.
int
register_endpoint
(
const
char
*
addr_
,
class
socket_base_t
*
socket_
);
...
...
src/object.cpp
View file @
a68e6739
...
...
@@ -142,9 +142,9 @@ void zmq::object_t::log (zmq_msg_t *msg_)
ctx
->
log
(
msg_
);
}
zmq
::
io_thread_t
*
zmq
::
object_t
::
choose_io_thread
(
uint64_t
taskset
_
)
zmq
::
io_thread_t
*
zmq
::
object_t
::
choose_io_thread
(
uint64_t
affinity
_
)
{
return
ctx
->
choose_io_thread
(
taskset
_
);
return
ctx
->
choose_io_thread
(
affinity
_
);
}
void
zmq
::
object_t
::
zombify_socket
(
socket_base_t
*
socket_
)
...
...
src/object.hpp
View file @
a68e6739
...
...
@@ -54,7 +54,7 @@ namespace zmq
void
log
(
zmq_msg_t
*
msg_
);
// Chooses least loaded I/O thread.
class
io_thread_t
*
choose_io_thread
(
uint64_t
taskset
_
);
class
io_thread_t
*
choose_io_thread
(
uint64_t
affinity
_
);
// Zombify particular socket. In other words, pass the ownership to
// the context.
...
...
src/socket_base.cpp
View file @
a68e6739
...
...
@@ -289,8 +289,17 @@ int zmq::socket_base_t::bind (const char *addr_)
return
register_endpoint
(
addr_
,
this
);
if
(
protocol
==
"tcp"
||
protocol
==
"ipc"
)
{
// Choose I/O thread to run the listerner in.
io_thread_t
*
io_thread
=
choose_io_thread
(
options
.
affinity
);
if
(
!
io_thread
)
{
errno
=
EMTHREAD
;
return
-
1
;
}
// Create and run the listener.
zmq_listener_t
*
listener
=
new
(
std
::
nothrow
)
zmq_listener_t
(
choose_io_thread
(
options
.
affinity
)
,
this
,
options
);
io_thread
,
this
,
options
);
zmq_assert
(
listener
);
int
rc
=
listener
->
set_address
(
protocol
.
c_str
(),
address
.
c_str
());
if
(
rc
!=
0
)
{
...
...
@@ -376,10 +385,16 @@ int zmq::socket_base_t::connect (const char *addr_)
return
0
;
}
// Choose the I/O thread to run the session in.
io_thread_t
*
io_thread
=
choose_io_thread
(
options
.
affinity
);
if
(
!
io_thread
)
{
errno
=
EMTHREAD
;
return
-
1
;
}
// Create session.
connect_session_t
*
session
=
new
(
std
::
nothrow
)
connect_session_t
(
choose_io_thread
(
options
.
affinity
),
this
,
options
,
protocol
.
c_str
(),
address
.
c_str
());
io_thread
,
this
,
options
,
protocol
.
c_str
(),
address
.
c_str
());
zmq_assert
(
session
);
// If 'immediate connect' feature is required, we'll create the pipes
...
...
src/zmq.cpp
View file @
a68e6739
...
...
@@ -88,6 +88,8 @@ const char *zmq_strerror (int errnum_)
return
"The protocol is not compatible with the socket type"
;
case
ETERM
:
return
"Context was terminated"
;
case
EMTHREAD
:
return
"No thread available"
;
default:
#if defined _MSC_VER
#pragma warning (push)
...
...
src/zmq_connecter.cpp
View file @
a68e6739
...
...
@@ -77,9 +77,14 @@ void zmq::zmq_connecter_t::out_event ()
return
;
}
// Choose I/O thread to run connecter in. Given that we are already
// running in an I/O thread, there must be at least one available.
io_thread_t
*
io_thread
=
choose_io_thread
(
options
.
affinity
);
zmq_assert
(
io_thread
);
// Create an init object.
zmq_init_t
*
init
=
new
(
std
::
nothrow
)
zmq_init_t
(
choose_io_thread
(
options
.
affinity
),
NULL
,
session
,
fd
,
options
);
zmq_init_t
*
init
=
new
(
std
::
nothrow
)
zmq_init_t
(
io_thread
,
NULL
,
session
,
fd
,
options
);
zmq_assert
(
init
);
launch_sibling
(
init
);
...
...
src/zmq_listener.cpp
View file @
a68e6739
...
...
@@ -64,9 +64,14 @@ void zmq::zmq_listener_t::in_event ()
if
(
fd
==
retired_fd
)
return
;
// Choose I/O thread to run connecter in. Given that we are already
// running in an I/O thread, there must be at least one available.
io_thread_t
*
io_thread
=
choose_io_thread
(
options
.
affinity
);
zmq_assert
(
io_thread
);
// Create and launch an init object.
zmq_init_t
*
init
=
new
(
std
::
nothrow
)
zmq_init_t
(
choose_io_thread
(
options
.
affinity
),
socket
,
NULL
,
fd
,
options
);
zmq_init_t
*
init
=
new
(
std
::
nothrow
)
zmq_init_t
(
io_thread
,
socket
,
NULL
,
fd
,
options
);
zmq_assert
(
init
);
launch_sibling
(
init
);
}
...
...
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