/***************************************
* Use epoll infrastructure - epoll(4) *
***************************************/
-
-#undef SLAP_EVENT_ACK /* events trigger once per descriptor */
-
# define SLAP_EVENT_FNAME "epoll"
# define SLAP_EVENTS_ARE_INDEXED 0
# define SLAP_EPOLL_SOCK_IX(s) (slap_daemon.sd_index[(s)])
int rc; \
SLAP_EPOLL_SOCK_IX((s)) = slap_daemon.sd_nfds; \
SLAP_EPOLL_SOCK_EP((s)).data.ptr = (l) ? (l) : (void *)(&SLAP_EPOLL_SOCK_IX(s)); \
- SLAP_EPOLL_SOCK_EV((s)) = EPOLLIN|EPOLLET; \
+ SLAP_EPOLL_SOCK_EV((s)) = EPOLLIN; \
rc = epoll_ctl(slap_daemon.sd_epfd, EPOLL_CTL_ADD, \
(s), &SLAP_EPOLL_SOCK_EP((s))); \
if ( rc == 0 ) { \
} while (0)
#elif defined(SLAP_X_DEVPOLL) && defined(HAVE_DEVPOLL)
+
/*************************************************************
* Use Solaris' (>= 2.7) /dev/poll infrastructure - poll(7d) *
*************************************************************/
-
-#define SLAP_EVENT_ACK 1 /* events keep signalling unless we stop them */
-
# define SLAP_EVENT_FNAME "/dev/poll"
# define SLAP_EVENTS_ARE_INDEXED 0
/*
} while (0)
#else /* ! epoll && ! /dev/poll */
-
-#define SLAP_EVENT_ACK 1 /* events keep signalling unless we stop them */
-
# ifdef HAVE_WINSOCK
# define SLAP_EVENT_FNAME "WSselect"
/* Winsock provides a "select" function but its fd_sets are
slap_daemon.sd_flags = (char *)(slapd_ws_sockets + dtblsize); \
slap_daemon.sd_rflags = slap_daemon.sd_flags + dtblsize; \
memset( slapd_ws_sockets, -1, dtblsize * sizeof(SOCKET) ); \
+ memset( slap_daemon.sd_flags, 0, dtblsize ); \
slapd_ws_sockets[0] = wake_sds[0]; \
slapd_ws_sockets[1] = wake_sds[1]; \
wake_sds[0] = 0; \
WAKE_LISTENER(wake || slapd_gentle_shutdown == 2);
}
-void
-slapd_ack_write( ber_socket_t s, int wake )
-{
-#ifdef SLAP_EVENT_ACK
- ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
-
- if ( SLAP_SOCK_IS_WRITE( s )) {
- assert( SLAP_SOCK_IS_ACTIVE( s ));
-
- SLAP_SOCK_CLR_WRITE( s );
- slap_daemon.sd_nwriters--;
- }
-
- ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
-#endif
- WAKE_LISTENER(wake);
-}
-
void
slapd_clr_write( ber_socket_t s, int wake )
{
WAKE_LISTENER(wake);
}
-int
-slapd_ack_read( ber_socket_t s, int wake )
-{
-#ifdef SLAP_EVENT_ACK
- int rc = 1;
- ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
-
- if ( SLAP_SOCK_IS_ACTIVE( s )) {
- SLAP_SOCK_CLR_READ( s );
- rc = 0;
- }
- ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
- if ( !rc )
- WAKE_LISTENER(wake);
- return rc;
-#else
- return 0;
-#endif
-}
-
int
slapd_clr_read( ber_socket_t s, int wake )
{
{
connections_destroy();
#ifdef HAVE_WINSOCK
- if ( wake_sds[1] != INVALID_SOCKET && wake_sds[1] != wake_sds[0] )
+ if ( wake_sds[1] != INVALID_SOCKET &&
+ SLAP_FD2SOCK( wake_sds[1] ) != SLAP_FD2SOCK( wake_sds[0] ))
#endif /* HAVE_WINSOCK */
tcp_close( SLAP_FD2SOCK(wake_sds[1]) );
#ifdef HAVE_WINSOCK
} else if ( !w ) {
Debug( LDAP_DEBUG_CONNS,
"daemon: hangup on %d\n", fd, 0, 0 );
- connection_hangup( fd );
+ if ( SLAP_SOCK_IS_ACTIVE( fd )) {
+#ifdef HAVE_EPOLL
+ /* Don't keep reporting the hangup
+ */
+ SLAP_EPOLL_SOCK_SET( fd, EPOLLET );
+#endif
+ connection_hangup( fd );
+ }
}
}
}
RETSIGTYPE
slap_sig_shutdown( int sig )
{
+ int save_errno = errno;
+
#if 0
Debug(LDAP_DEBUG_TRACE, "slap_sig_shutdown: signal %d\n", sig, 0, 0);
#endif
/* reinstall self */
(void) SIGNAL_REINSTALL( sig, slap_sig_shutdown );
+
+ errno = save_errno;
}
RETSIGTYPE
slap_sig_wake( int sig )
{
+ int save_errno = errno;
+
WAKE_LISTENER(1);
/* reinstall self */
(void) SIGNAL_REINSTALL( sig, slap_sig_wake );
+
+ errno = save_errno;
}