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
e8e2944f
Commit
e8e2944f
authored
Oct 17, 2010
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZMQ_RECONNECT_IVL socket options added.
Signed-off-by:
Martin Sustrik
<
sustrik@250bpm.com
>
parent
8b883768
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
79 additions
and
30 deletions
+79
-30
zmq_getsockopt.txt
doc/zmq_getsockopt.txt
+13
-2
zmq_setsockopt.txt
doc/zmq_setsockopt.txt
+13
-0
zmq.h
include/zmq.h
+1
-0
config.hpp
src/config.hpp
+0
-3
options.cpp
src/options.cpp
+40
-17
options.hpp
src/options.hpp
+3
-0
zmq_connecter.cpp
src/zmq_connecter.cpp
+8
-7
zmq_connecter.hpp
src/zmq_connecter.hpp
+1
-1
No files found.
doc/zmq_getsockopt.txt
View file @
e8e2944f
...
...
@@ -212,8 +212,8 @@ Default value:: 0
Applicable socket types:: all
ZMQ_LINGER:
Set
linger period for socket shutdown
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ZMQ_LINGER:
Retrieve
linger period for socket shutdown
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~
The 'ZMQ_LINGER' option shall retrieve the period for pending outbound
messages to linger in memory after closing the socket. Value of -1 means
infinite. Pending messages will be kept until they are fully transferred to
...
...
@@ -227,6 +227,17 @@ Option value unit:: milliseconds
Default value:: -1
Applicable socket types:: all
ZMQ_RECONNECT_IVL: Retrieve reconnect period for connection-based transports
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_RECONNECT' option shall retrieve the period indicating how long it
takes for a disconnected underlying connection to attempt to reconnect.
[horizontal]
Option value type:: int
Option value unit:: milliseconds
Default value:: 100
Applicable socket types:: all
ZMQ_FD: Retrieve file descriptor associated with the socket
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
doc/zmq_setsockopt.txt
View file @
e8e2944f
...
...
@@ -232,6 +232,19 @@ Default value:: -1
Applicable socket types:: all
ZMQ_RECONNECT_IVL: Set reconnect period for connection-based transports
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_RECONNECT' option shall be set to specify how long it takes for a
disconnected underlying connection to attempt to reconnect. The interval
can be randomised to some extent by 0MQ to prevent reconnection storms.
[horizontal]
Option value type:: int
Option value unit:: milliseconds
Default value:: 100
Applicable socket types:: all
RETURN VALUE
------------
The _zmq_setsockopt()_ function shall return zero if successful. Otherwise it
...
...
include/zmq.h
View file @
e8e2944f
...
...
@@ -192,6 +192,7 @@ ZMQ_EXPORT int zmq_term (void *context);
#define ZMQ_EVENTS 15
#define ZMQ_TYPE 16
#define ZMQ_LINGER 17
#define ZMQ_RECONNECT_IVL 18
/* Send/recv options. */
#define ZMQ_NOBLOCK 1
...
...
src/config.hpp
View file @
e8e2944f
...
...
@@ -69,9 +69,6 @@ namespace zmq
// Maximum number of events the I/O thread can process in one go.
max_io_events
=
256
,
// How long to wait (milliseconds) till reattempting to connect.
reconnect_period
=
100
,
// Should initial connection attempts be delayed?
wait_before_connect
=
false
,
...
...
src/options.cpp
View file @
e8e2944f
...
...
@@ -35,6 +35,7 @@ zmq::options_t::options_t () :
rcvbuf
(
0
),
type
(
-
1
),
linger
(
-
1
),
reconnect_ivl
(
100
),
requires_in
(
false
),
requires_out
(
false
),
immediate_connect
(
true
)
...
...
@@ -137,33 +138,27 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
}
linger
=
*
((
int
*
)
optval_
);
return
0
;
}
case
ZMQ_RECONNECT_IVL
:
if
(
optvallen_
!=
sizeof
(
int
))
{
errno
=
EINVAL
;
return
-
1
;
}
int
zmq
::
options_t
::
getsockopt
(
int
option_
,
void
*
optval_
,
size_t
*
optvallen_
)
{
switch
(
option_
)
{
case
ZMQ_LINGER
:
if
(
*
optvallen_
<
sizeof
(
int
))
{
}
if
(
*
((
int
*
)
optval_
)
<
0
)
{
errno
=
EINVAL
;
return
-
1
;
}
*
((
int
*
)
optval_
)
=
linger
;
*
optvallen_
=
sizeof
(
int
);
reconnect_ivl
=
*
((
int
*
)
optval_
);
return
0
;
}
case
ZMQ_TYPE
:
if
(
*
optvallen_
<
sizeof
(
int
))
{
errno
=
EINVAL
;
return
-
1
;
}
*
((
int
*
)
optval_
)
=
type
;
*
optvallen_
=
sizeof
(
int
);
return
0
;
}
int
zmq
::
options_t
::
getsockopt
(
int
option_
,
void
*
optval_
,
size_t
*
optvallen_
)
{
switch
(
option_
)
{
case
ZMQ_HWM
:
if
(
*
optvallen_
<
sizeof
(
uint64_t
))
{
...
...
@@ -246,6 +241,34 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
*
((
uint64_t
*
)
optval_
)
=
rcvbuf
;
*
optvallen_
=
sizeof
(
uint64_t
);
return
0
;
case
ZMQ_TYPE
:
if
(
*
optvallen_
<
sizeof
(
int
))
{
errno
=
EINVAL
;
return
-
1
;
}
*
((
int
*
)
optval_
)
=
type
;
*
optvallen_
=
sizeof
(
int
);
return
0
;
case
ZMQ_LINGER
:
if
(
*
optvallen_
<
sizeof
(
int
))
{
errno
=
EINVAL
;
return
-
1
;
}
*
((
int
*
)
optval_
)
=
linger
;
*
optvallen_
=
sizeof
(
int
);
return
0
;
case
ZMQ_RECONNECT_IVL
:
if
(
*
optvallen_
<
sizeof
(
int
))
{
errno
=
EINVAL
;
return
-
1
;
}
*
((
int
*
)
optval_
)
=
reconnect_ivl
;
*
optvallen_
=
sizeof
(
int
);
return
0
;
}
errno
=
EINVAL
;
...
...
src/options.hpp
View file @
e8e2944f
...
...
@@ -57,6 +57,9 @@ namespace zmq
// Linger time, in milliseconds.
int
linger
;
// Interval between attempts to reconnect, in milliseconds.
int
reconnect_ivl
;
// These options are never set by the user directly. Instead they are
// provided by the specific socket type.
bool
requires_in
;
...
...
src/zmq_connecter.cpp
View file @
e8e2944f
...
...
@@ -54,20 +54,21 @@ zmq::zmq_connecter_t::~zmq_connecter_t ()
rm_fd
(
handle
);
}
int
zmq
::
zmq_connecter_t
::
get_reconnect_
period
()
int
zmq
::
zmq_connecter_t
::
get_reconnect_
ivl
()
{
#if defined ZMQ_HAVE_WINDOWS
return
(
reconnect_period
+
(((
int
)
GetCurrentProcessId
()
*
13
)
%
reconnect_period
));
return
(
options
.
reconnect_ivl
+
(((
int
)
GetCurrentProcessId
()
*
13
)
%
options
.
reconnect_ivl
));
#else
return
(
reconnect_period
+
(((
int
)
getpid
()
*
13
)
%
reconnect_period
));
return
(
options
.
reconnect_ivl
+
(((
int
)
getpid
()
*
13
)
%
options
.
reconnect_ivl
));
#endif
}
void
zmq
::
zmq_connecter_t
::
process_plug
()
{
if
(
wait
)
add_timer
(
get_reconnect_
period
(),
reconnect_timer_id
);
add_timer
(
get_reconnect_
ivl
(),
reconnect_timer_id
);
else
start_connecting
();
}
...
...
@@ -90,7 +91,7 @@ void zmq::zmq_connecter_t::out_event ()
if
(
fd
==
retired_fd
)
{
tcp_connecter
.
close
();
wait
=
true
;
add_timer
(
get_reconnect_
period
(),
reconnect_timer_id
);
add_timer
(
get_reconnect_
ivl
(),
reconnect_timer_id
);
return
;
}
...
...
@@ -139,5 +140,5 @@ void zmq::zmq_connecter_t::start_connecting ()
// Handle any other error condition by eventual reconnect.
wait
=
true
;
add_timer
(
get_reconnect_
period
(),
reconnect_timer_id
);
add_timer
(
get_reconnect_
ivl
(),
reconnect_timer_id
);
}
src/zmq_connecter.hpp
View file @
e8e2944f
...
...
@@ -56,7 +56,7 @@ namespace zmq
void
start_connecting
();
// Internal function to return the reconnect backoff delay.
int
get_reconnect_
period
();
int
get_reconnect_
ivl
();
// Actual connecting socket.
tcp_connecter_t
tcp_connecter
;
...
...
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