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
8ab3c4a1
Commit
8ab3c4a1
authored
Jan 31, 2013
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue #500
parent
309740e1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
97 additions
and
10 deletions
+97
-10
.gitignore
.gitignore
+3
-0
zmq_ctx_get.txt
doc/zmq_ctx_get.txt
+5
-1
zmq_ctx_set.txt
doc/zmq_ctx_set.txt
+11
-0
ctx.cpp
src/ctx.cpp
+15
-5
ctx.hpp
src/ctx.hpp
+3
-0
options.hpp
src/options.hpp
+0
-1
socket_base.cpp
src/socket_base.cpp
+1
-0
Makefile.am
tests/Makefile.am
+3
-3
test_ctx_options.cpp
tests/test_ctx_options.cpp
+56
-0
No files found.
.gitignore
View file @
8ab3c4a1
...
...
@@ -45,6 +45,7 @@ tests/test_router_mandatory
tests/test_disconnect_inproc
tests/test_raw_sock
tests/test_disconnect_inproc
tests/test_ctx_options
src/platform.hpp*
src/stamp-h1
perf/local_lat
...
...
@@ -73,3 +74,5 @@ foreign/openpgm/*
!foreign/openpgm/Makefile.am
zeromq-*.tar.gz
zeromq-*.zip
core
doc/zmq_ctx_get.txt
View file @
8ab3c4a1
...
...
@@ -26,11 +26,15 @@ ZMQ_IO_THREADS: Get number of I/O threads
The 'ZMQ_IO_THREADS' argument returns the size of the 0MQ thread pool
for this context.
ZMQ_MAX_SOCKETS:
S
et maximum number of sockets
ZMQ_MAX_SOCKETS:
G
et maximum number of sockets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_MAX_SOCKETS' argument returns the maximum number of sockets
allowed for this context.
ZMQ_IPV6: Set IPv6 option
~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_IPV6' argument returns the IPv6 option for the context.
RETURN VALUE
------------
...
...
doc/zmq_ctx_set.txt
View file @
8ab3c4a1
...
...
@@ -40,6 +40,17 @@ on the context.
[horizontal]
Default value:: 1024
ZMQ_IPV6: Set IPv6 option
~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_IPV6' argument sets the IPv6 value for all sockets created in
the context from this point onwards. A value of `1` means IPv6 is
enabled, while `0` means the socket will use only IPv4. When IPv6 is
enabled, a socket will connect to, or accept connections from, both
IPv4 and IPv6 hosts.
[horizontal]
Default value:: 0
RETURN VALUE
------------
...
...
src/ctx.cpp
View file @
8ab3c4a1
...
...
@@ -45,7 +45,8 @@ zmq::ctx_t::ctx_t () :
slot_count
(
0
),
slots
(
NULL
),
max_sockets
(
ZMQ_MAX_SOCKETS_DFLT
),
io_thread_count
(
ZMQ_IO_THREADS_DFLT
)
io_thread_count
(
ZMQ_IO_THREADS_DFLT
),
ipv6
(
false
)
{
}
...
...
@@ -139,6 +140,12 @@ int zmq::ctx_t::set (int option_, int optval_)
io_thread_count
=
optval_
;
opt_sync
.
unlock
();
}
else
if
(
option_
==
ZMQ_IPV6
&&
optval_
>=
0
)
{
opt_sync
.
lock
();
ipv6
=
optval_
;
opt_sync
.
unlock
();
}
else
{
errno
=
EINVAL
;
rc
=
-
1
;
...
...
@@ -154,6 +161,9 @@ int zmq::ctx_t::get (int option_)
else
if
(
option_
==
ZMQ_IO_THREADS
)
rc
=
io_thread_count
;
else
if
(
option_
==
ZMQ_IPV6
)
rc
=
ipv6
;
else
{
errno
=
EINVAL
;
rc
=
-
1
;
...
...
@@ -168,7 +178,7 @@ zmq::socket_base_t *zmq::ctx_t::create_socket (int type_)
starting
=
false
;
// Initialise the array of mailboxes. Additional three slots are for
// zmq_term thread and reaper thread.
// zmq_
ctx_
term thread and reaper thread.
opt_sync
.
lock
();
int
mazmq
=
max_sockets
;
int
ios
=
io_thread_count
;
...
...
@@ -177,7 +187,7 @@ zmq::socket_base_t *zmq::ctx_t::create_socket (int type_)
slots
=
(
mailbox_t
**
)
malloc
(
sizeof
(
mailbox_t
*
)
*
slot_count
);
alloc_assert
(
slots
);
// Initialise the infrastructure for zmq_term thread.
// Initialise the infrastructure for zmq_
ctx_
term thread.
slots
[
term_tid
]
=
&
term_mailbox
;
// Create the reaper thread.
...
...
@@ -203,7 +213,7 @@ zmq::socket_base_t *zmq::ctx_t::create_socket (int type_)
}
}
// Once zmq_term() was called, we can't create new sockets.
// Once zmq_
ctx_
term() was called, we can't create new sockets.
if
(
terminating
)
{
slot_sync
.
unlock
();
errno
=
ETERM
;
...
...
@@ -250,7 +260,7 @@ void zmq::ctx_t::destroy_socket (class socket_base_t *socket_)
// Remove the socket from the list of sockets.
sockets
.
erase
(
socket_
);
// If zmq_term() was already called and there are no more socket
// If zmq_
ctx_
term() was already called and there are no more socket
// we can ask reaper thread to terminate.
if
(
terminating
&&
sockets
.
empty
())
reaper
->
stop
();
...
...
src/ctx.hpp
View file @
8ab3c4a1
...
...
@@ -161,6 +161,9 @@ namespace zmq
// Number of I/O threads to launch.
int
io_thread_count
;
// Is IPv6 enabled on this context?
bool
ipv6
;
// Synchronisation of access to context options.
mutex_t
opt_sync
;
...
...
src/options.hpp
View file @
8ab3c4a1
...
...
@@ -33,7 +33,6 @@
namespace
zmq
{
struct
options_t
{
options_t
();
...
...
src/socket_base.cpp
View file @
8ab3c4a1
...
...
@@ -135,6 +135,7 @@ zmq::socket_base_t::socket_base_t (ctx_t *parent_, uint32_t tid_, int sid_) :
monitor_events
(
0
)
{
options
.
socket_id
=
sid_
;
options
.
ipv6
=
parent_
->
get
(
ZMQ_IPV6
);
}
zmq
::
socket_base_t
::~
socket_base_t
()
...
...
tests/Makefile.am
View file @
8ab3c4a1
...
...
@@ -19,8 +19,8 @@ noinst_PROGRAMS = test_pair_inproc \
test_monitor
\
test_router_mandatory
\
test_raw_sock
\
test_disconnect_inproc
test_disconnect_inproc
\
test_ctx_options
if
!ON_MINGW
noinst_PROGRAMS
+=
test_shutdown_stress
\
...
...
@@ -46,7 +46,7 @@ test_monitor_SOURCES = test_monitor.cpp
test_router_mandatory_SOURCES
=
test_router_mandatory.cpp
test_raw_sock_SOURCES
=
test_raw_sock.cpp
test_disconnect_inproc_SOURCES
=
test_disconnect_inproc.cpp
test_ctx_set_SOURCES
=
test_ctx_options.cpp
if
!ON_MINGW
test_shutdown_stress_SOURCES
=
test_shutdown_stress.cpp
test_pair_ipc_SOURCES
=
test_pair_ipc.cpp testutil.hpp
...
...
tests/test_ctx_options.cpp
0 → 100644
View file @
8ab3c4a1
/*
Copyright (c) 2007-2013 iMatix Corporation
Copyright (c) 2007-2012 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../include/zmq.h"
#include <string.h>
#include <stdbool.h>
#undef NDEBUG
#include <assert.h>
int
main
(
void
)
{
int
rc
;
// Set up our context and sockets
void
*
ctx
=
zmq_ctx_new
();
assert
(
ctx
);
assert
(
zmq_ctx_get
(
ctx
,
ZMQ_MAX_SOCKETS
)
==
ZMQ_MAX_SOCKETS_DFLT
);
assert
(
zmq_ctx_get
(
ctx
,
ZMQ_IO_THREADS
)
==
ZMQ_IO_THREADS_DFLT
);
assert
(
zmq_ctx_get
(
ctx
,
ZMQ_IPV6
)
==
0
);
rc
=
zmq_ctx_set
(
ctx
,
ZMQ_IPV6
,
true
);
assert
(
zmq_ctx_get
(
ctx
,
ZMQ_IPV6
)
==
true
);
void
*
router
=
zmq_socket
(
ctx
,
ZMQ_ROUTER
);
int
ipv6
;
size_t
optsize
=
sizeof
(
int
);
rc
=
zmq_getsockopt
(
router
,
ZMQ_IPV6
,
&
ipv6
,
&
optsize
);
assert
(
rc
==
0
);
assert
(
ipv6
);
rc
=
zmq_close
(
router
);
assert
(
rc
==
0
);
rc
=
zmq_ctx_term
(
ctx
);
assert
(
rc
==
0
);
return
0
;
}
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