Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
David Barchiesi
OpenLDAP
Commits
dfbf25d5
Commit
dfbf25d5
authored
Jul 23, 2019
by
Ondřej Kuzník
Browse files
Honour keepalive settings for upstreams
parent
25fff30e
Changes
1
Hide whitespace changes
Inline
Side-by-side
servers/lloadd/backend.c
View file @
dfbf25d5
...
...
@@ -136,6 +136,73 @@ upstream_name_cb( int result, struct evutil_addrinfo *res, void *arg )
goto
fail
;
}
#if defined(SO_KEEPALIVE) || defined(TCP_NODELAY)
if
(
b
->
b_proto
==
LDAP_PROTO_TCP
)
{
int
dummy
=
1
;
#ifdef SO_KEEPALIVE
if
(
setsockopt
(
s
,
SOL_SOCKET
,
SO_KEEPALIVE
,
(
char
*
)
&
dummy
,
sizeof
(
dummy
)
)
==
AC_SOCKET_ERROR
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"upstream_name_cb: "
"setsockopt(%d, SO_KEEPALIVE) failed (ignored).
\n
"
,
s
);
}
if
(
bindconf
.
sb_keepalive
.
sk_idle
>
0
)
{
#ifdef TCP_KEEPIDLE
if
(
setsockopt
(
s
,
IPPROTO_TCP
,
TCP_KEEPIDLE
,
(
void
*
)
&
bindconf
.
sb_keepalive
.
sk_idle
,
sizeof
(
bindconf
.
sb_keepalive
.
sk_idle
)
)
==
AC_SOCKET_ERROR
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"upstream_name_cb: "
"setsockopt(%d, TCP_KEEPIDLE) failed (ignored).
\n
"
,
s
);
}
#else
Debug
(
LDAP_DEBUG_TRACE
,
"upstream_name_cb: "
"sockopt TCP_KEEPIDLE not supported on this system.
\n
"
);
#endif
/* TCP_KEEPIDLE */
}
if
(
bindconf
.
sb_keepalive
.
sk_probes
>
0
)
{
#ifdef TCP_KEEPCNT
if
(
setsockopt
(
s
,
IPPROTO_TCP
,
TCP_KEEPCNT
,
(
void
*
)
&
bindconf
.
sb_keepalive
.
sk_probes
,
sizeof
(
bindconf
.
sb_keepalive
.
sk_probes
)
)
==
AC_SOCKET_ERROR
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"upstream_name_cb: "
"setsockopt(%d, TCP_KEEPCNT) failed (ignored).
\n
"
,
s
);
}
#else
Debug
(
LDAP_DEBUG_TRACE
,
"upstream_name_cb: "
"sockopt TCP_KEEPCNT not supported on this system.
\n
"
);
#endif
/* TCP_KEEPCNT */
}
if
(
bindconf
.
sb_keepalive
.
sk_interval
>
0
)
{
#ifdef TCP_KEEPINTVL
if
(
setsockopt
(
s
,
IPPROTO_TCP
,
TCP_KEEPINTVL
,
(
void
*
)
&
bindconf
.
sb_keepalive
.
sk_interval
,
sizeof
(
bindconf
.
sb_keepalive
.
sk_interval
)
)
==
AC_SOCKET_ERROR
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"upstream_name_cb: "
"setsockopt(%d, TCP_KEEPINTVL) failed (ignored).
\n
"
,
s
);
}
#else
Debug
(
LDAP_DEBUG_TRACE
,
"upstream_name_cb: "
"sockopt TCP_KEEPINTVL not supported on this system.
\n
"
);
#endif
/* TCP_KEEPINTVL */
}
#endif
/* SO_KEEPALIVE */
#ifdef TCP_NODELAY
if
(
setsockopt
(
s
,
IPPROTO_TCP
,
TCP_NODELAY
,
(
char
*
)
&
dummy
,
sizeof
(
dummy
)
)
==
AC_SOCKET_ERROR
)
{
Debug
(
LDAP_DEBUG_TRACE
,
"upstream_name_cb: "
"setsockopt(%d, TCP_NODELAY) failed (ignored).
\n
"
,
s
);
}
#endif
/* TCP_NODELAY */
}
#endif
/* SO_KEEPALIVE || TCP_NODELAY */
if
(
res
->
ai_family
==
PF_INET
)
{
struct
sockaddr_in
*
ai
=
(
struct
sockaddr_in
*
)
res
->
ai_addr
;
ai
->
sin_port
=
htons
(
b
->
b_port
);
...
...
Write
Preview
Supports
Markdown
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