mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-03-07 14:18:15 +08:00
Restrict keepalive/nodelay setsockopt to IP streams
This commit is contained in:
parent
6ec475cd61
commit
aa5b7d4d52
@ -642,7 +642,6 @@ slapd_daemon_task(
|
|||||||
void *ptr
|
void *ptr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int rc, tmp;
|
|
||||||
int l;
|
int l;
|
||||||
time_t last_idle_check = slap_get_time();
|
time_t last_idle_check = slap_get_time();
|
||||||
time( &starttime );
|
time( &starttime );
|
||||||
@ -858,27 +857,38 @@ slapd_daemon_task(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined( SO_KEEPALIVE ) || defined( TCP_NODELAY )
|
||||||
|
#ifdef LDAP_PF_LOCAL
|
||||||
|
/* for IPv4 and IPv6 sockets only */
|
||||||
|
if ( from.sa_addr.sa_family != AF_LOCAL )
|
||||||
|
#endif /* LDAP_PF_LOCAL */
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
int tmp;
|
||||||
#ifdef SO_KEEPALIVE
|
#ifdef SO_KEEPALIVE
|
||||||
/* enable keep alives */
|
/* enable keep alives */
|
||||||
rc = setsockopt( s, SOL_SOCKET, SO_KEEPALIVE,
|
tmp = 1;
|
||||||
(char *) &tmp, sizeof(tmp) );
|
rc = setsockopt( s, SOL_SOCKET, SO_KEEPALIVE,
|
||||||
if ( rc == AC_SOCKET_ERROR ) {
|
(char *) &tmp, sizeof(tmp) );
|
||||||
int err = sock_errno();
|
if ( rc == AC_SOCKET_ERROR ) {
|
||||||
Debug( LDAP_DEBUG_ANY,
|
int err = sock_errno();
|
||||||
"slapd(%ld): setsockopt(SO_KEEPALIVE) failed "
|
Debug( LDAP_DEBUG_ANY,
|
||||||
"errno=%d (%s)\n", (long) s, err, sock_errstr(err) );
|
"slapd(%ld): setsockopt(SO_KEEPALIVE) failed "
|
||||||
}
|
"errno=%d (%s)\n", (long) s, err, sock_errstr(err) );
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef TCP_NODELAY
|
#ifdef TCP_NODELAY
|
||||||
/* enable no delay */
|
/* enable no delay */
|
||||||
tmp = 1;
|
tmp = 1;
|
||||||
rc = setsockopt( s, IPPROTO_TCP, TCP_NODELAY,
|
rc = setsockopt( s, IPPROTO_TCP, TCP_NODELAY,
|
||||||
(char *)&tmp, sizeof(tmp) );
|
(char *)&tmp, sizeof(tmp) );
|
||||||
if ( rc == AC_SOCKET_ERROR ) {
|
if ( rc == AC_SOCKET_ERROR ) {
|
||||||
int err = sock_errno();
|
int err = sock_errno();
|
||||||
Debug( LDAP_DEBUG_ANY,
|
Debug( LDAP_DEBUG_ANY,
|
||||||
"slapd(%ld): setsockopt(TCP_NODELAY) failed "
|
"slapd(%ld): setsockopt(TCP_NODELAY) failed "
|
||||||
"errno=%d (%s)\n", (long) s, err, sock_errstr(err) );
|
"errno=%d (%s)\n", (long) s, err, sock_errstr(err) );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user