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
b65fc903
Commit
b65fc903
authored
8 years ago
by
Luca Boccassi
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1943 from hitstergtd/x-style-tunetcpkeepalives-fix
Problem: tune_tcp* related code has style issues
parents
dc81aac1
a31c5089
master
v4.3.2
v4.3.2-win
v4.3.1
v4.3.0
v4.2.5
v4.2.4
v4.2.3
v4.2.2
v4.2.1
v4.2.0
v4.2.0-rc1
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
15 deletions
+28
-15
tcp.cpp
src/tcp.cpp
+24
-13
tcp_connecter.cpp
src/tcp_connecter.cpp
+2
-1
tcp_listener.cpp
src/tcp_listener.cpp
+2
-1
No files found.
src/tcp.cpp
View file @
b65fc903
...
...
@@ -63,7 +63,7 @@ void zmq::tune_tcp_socket (fd_t s_)
#endif
#ifdef ZMQ_HAVE_OPENVMS
// Disable delayed acknowledgements as they hurt latency
is serious manner
.
// Disable delayed acknowledgements as they hurt latency
significantly
.
int
nodelack
=
1
;
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_NODELACK
,
(
char
*
)
&
nodelack
,
sizeof
(
int
));
...
...
@@ -93,7 +93,8 @@ void zmq::set_tcp_receive_buffer (fd_t sockfd_, int bufsize_)
#endif
}
void
zmq
::
tune_tcp_keepalives
(
fd_t
s_
,
int
keepalive_
,
int
keepalive_cnt_
,
int
keepalive_idle_
,
int
keepalive_intvl_
)
void
zmq
::
tune_tcp_keepalives
(
fd_t
s_
,
int
keepalive_
,
int
keepalive_cnt_
,
int
keepalive_idle_
,
int
keepalive_intvl_
)
{
// These options are used only under certain #ifdefs below.
LIBZMQ_UNUSED
(
keepalive_
);
...
...
@@ -110,34 +111,41 @@ void zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_, int
if
(
keepalive_
!=
-
1
)
{
tcp_keepalive
keepalive_opts
;
keepalive_opts
.
onoff
=
keepalive_
;
keepalive_opts
.
keepalivetime
=
keepalive_idle_
!=
-
1
?
keepalive_idle_
*
1000
:
7200000
;
keepalive_opts
.
keepaliveinterval
=
keepalive_intvl_
!=
-
1
?
keepalive_intvl_
*
1000
:
1000
;
keepalive_opts
.
keepalivetime
=
keepalive_idle_
!=
-
1
?
keepalive_idle_
*
1000
:
7200000
;
keepalive_opts
.
keepaliveinterval
=
keepalive_intvl_
!=
-
1
?
keepalive_intvl_
*
1000
:
1000
;
DWORD
num_bytes_returned
;
int
rc
=
WSAIoctl
(
s_
,
SIO_KEEPALIVE_VALS
,
&
keepalive_opts
,
sizeof
(
keepalive_opts
),
NULL
,
0
,
&
num_bytes_returned
,
NULL
,
NULL
);
int
rc
=
WSAIoctl
(
s_
,
SIO_KEEPALIVE_VALS
,
&
keepalive_opts
,
sizeof
(
keepalive_opts
),
NULL
,
0
,
&
num_bytes_returned
,
NULL
,
NULL
);
wsa_assert
(
rc
!=
SOCKET_ERROR
);
}
#else
#ifdef ZMQ_HAVE_SO_KEEPALIVE
if
(
keepalive_
!=
-
1
)
{
int
rc
=
setsockopt
(
s_
,
SOL_SOCKET
,
SO_KEEPALIVE
,
(
char
*
)
&
keepalive_
,
sizeof
(
int
));
int
rc
=
setsockopt
(
s_
,
SOL_SOCKET
,
SO_KEEPALIVE
,
(
char
*
)
&
keepalive_
,
sizeof
(
int
));
errno_assert
(
rc
==
0
);
#ifdef ZMQ_HAVE_TCP_KEEPCNT
if
(
keepalive_cnt_
!=
-
1
)
{
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPCNT
,
&
keepalive_cnt_
,
sizeof
(
int
));
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPCNT
,
&
keepalive_cnt_
,
sizeof
(
int
));
errno_assert
(
rc
==
0
);
}
#endif // ZMQ_HAVE_TCP_KEEPCNT
#ifdef ZMQ_HAVE_TCP_KEEPIDLE
if
(
keepalive_idle_
!=
-
1
)
{
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPIDLE
,
&
keepalive_idle_
,
sizeof
(
int
));
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPIDLE
,
&
keepalive_idle_
,
sizeof
(
int
));
errno_assert
(
rc
==
0
);
}
#else // ZMQ_HAVE_TCP_KEEPIDLE
#ifdef ZMQ_HAVE_TCP_KEEPALIVE
if
(
keepalive_idle_
!=
-
1
)
{
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPALIVE
,
&
keepalive_idle_
,
sizeof
(
int
));
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPALIVE
,
&
keepalive_idle_
,
sizeof
(
int
));
errno_assert
(
rc
==
0
);
}
#endif // ZMQ_HAVE_TCP_KEEPALIVE
...
...
@@ -145,7 +153,8 @@ void zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_, int
#ifdef ZMQ_HAVE_TCP_KEEPINTVL
if
(
keepalive_intvl_
!=
-
1
)
{
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPINTVL
,
&
keepalive_intvl_
,
sizeof
(
int
));
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPINTVL
,
&
keepalive_intvl_
,
sizeof
(
int
));
errno_assert
(
rc
==
0
);
}
#endif // ZMQ_HAVE_TCP_KEEPINTVL
...
...
@@ -165,7 +174,8 @@ void zmq::tune_tcp_maxrt (fd_t sockfd_, int timeout_)
int
rc
=
setsockopt
(
sockfd_
,
IPPROTO_TCP
,
TCP_MAXRT
,
(
char
*
)
&
timeout_
,
sizeof
(
timeout_
));
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#elif defined (TCP_USER_TIMEOUT) // FIXME: should be ZMQ_HAVE_TCP_USER_TIMEOUT
// FIXME: should be ZMQ_HAVE_TCP_USER_TIMEOUT
#elif defined (TCP_USER_TIMEOUT)
int
rc
=
setsockopt
(
sockfd_
,
IPPROTO_TCP
,
TCP_USER_TIMEOUT
,
&
timeout_
,
sizeof
(
timeout_
));
errno_assert
(
rc
==
0
);
...
...
@@ -195,8 +205,9 @@ void zmq::tune_tcp_maxrt (fd_t sockfd_, int timeout_)
))
return
-
1
;
// Circumvent a Windows bug; see https://support.microsoft.com/en-us/kb/201213
// and https://zeromq.jira.com/browse/LIBZMQ-195
// Circumvent a Windows bug:
// See https://support.microsoft.com/en-us/kb/201213
// See https://zeromq.jira.com/browse/LIBZMQ-195
if
(
nbytes
==
SOCKET_ERROR
&&
last_error
==
WSAENOBUFS
)
return
0
;
...
...
This diff is collapsed.
Click to expand it.
src/tcp_connecter.cpp
View file @
b65fc903
...
...
@@ -147,7 +147,8 @@ void zmq::tcp_connecter_t::out_event ()
}
tune_tcp_socket
(
fd
);
tune_tcp_keepalives
(
fd
,
options
.
tcp_keepalive
,
options
.
tcp_keepalive_cnt
,
options
.
tcp_keepalive_idle
,
options
.
tcp_keepalive_intvl
);
tune_tcp_keepalives
(
fd
,
options
.
tcp_keepalive
,
options
.
tcp_keepalive_cnt
,
options
.
tcp_keepalive_idle
,
options
.
tcp_keepalive_intvl
);
tune_tcp_maxrt
(
fd
,
options
.
tcp_maxrt
);
// remember our fd for ZMQ_SRCFD in messages
...
...
This diff is collapsed.
Click to expand it.
src/tcp_listener.cpp
View file @
b65fc903
...
...
@@ -101,7 +101,8 @@ void zmq::tcp_listener_t::in_event ()
}
tune_tcp_socket
(
fd
);
tune_tcp_keepalives
(
fd
,
options
.
tcp_keepalive
,
options
.
tcp_keepalive_cnt
,
options
.
tcp_keepalive_idle
,
options
.
tcp_keepalive_intvl
);
tune_tcp_keepalives
(
fd
,
options
.
tcp_keepalive
,
options
.
tcp_keepalive_cnt
,
options
.
tcp_keepalive_idle
,
options
.
tcp_keepalive_intvl
);
tune_tcp_maxrt
(
fd
,
options
.
tcp_maxrt
);
// remember our fd for ZMQ_SRCFD in messages
...
...
This diff is collapsed.
Click to expand it.
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