for (i=0; i<dtblsize; i++) slap_daemon.sd_index[i] = -1; \
} while (0)
+#define SLAP_SOCK_SET_DESTROY do { \
+ if ( slap_daemon.sd_epolls != NULL ) { \
+ ch_free( slap_daemon.sd_epolls ); \
+ slap_daemon.sd_epolls = NULL; \
+ ch_free( slap_daemon.sd_index ); \
+ slap_daemon.sd_index = NULL; \
+ close( slap_daemon.sd_epfd ); \
+ } \
+} while ( 0 )
+
# define SLAP_EVENT_DECL struct epoll_event *revents
# define SLAP_EVENT_INIT do { \
FD_ZERO(&slap_daemon.sd_writers); \
} while (0)
+#define SLAP_SOCK_SET_DESTROY
+
# define SLAP_SOCK_IS_ACTIVE(fd) FD_ISSET((fd), &slap_daemon.sd_actives)
# define SLAP_SOCK_IS_READ(fd) FD_ISSET((fd), &slap_daemon.sd_readers)
# define SLAP_SOCK_IS_WRITE(fd) FD_ISSET((fd), &slap_daemon.sd_writers)
static char** slapd_srvurls = NULL;
static SLPHandle slapd_hslp = 0;
int slapd_register_slp = 0;
-char *slapd_slp_attrs = NULL;
+const char *slapd_slp_attrs = NULL;
static SLPError slapd_slp_cookie;
*/
void slapd_remove(
ber_socket_t s,
+ Sockbuf *sb,
int wasactive,
int wake,
int locked )
SLAP_DEL_SOCK(s);
+ if ( sb )
+ ber_sockbuf_free(sb);
+
/* If we ran out of file descriptors, we dropped a listener from
* the select() loop. Now that we're removing a session from our
* control, we can try to resume a dropped listener to use.
sap[i]->sa_family = AF_INET;
((struct sockaddr_in *)sap[i])->sin_port = htons(port);
AC_MEMCPY( &((struct sockaddr_in *)sap[i])->sin_addr,
- he ? he->h_addr_list[i] : &in, sizeof(struct in_addr) );
+ he ? (struct in_addr *)he->h_addr_list[i] : &in,
+ sizeof(struct in_addr) );
}
sap[i] = NULL;
#endif
Listener *lr = slap_listeners[l];
if ( lr->sl_sd != AC_SOCKET_INVALID ) {
- if ( remove ) slapd_remove( lr->sl_sd, 0, 0, 0 );
+ if ( remove ) slapd_remove( lr->sl_sd, NULL, 0, 0, 0 );
#ifdef LDAP_PF_LOCAL
if ( lr->sl_sa.sa_addr.sa_family == AF_LOCAL ) {
#endif
for (i=0; i<ns; i++) {
- int rc = 1, fd, waswrite = 0;
+ int rc = 1, fd;
if ( SLAP_EVENT_IS_LISTENER(i) ) {
#ifdef SLAP_LIGHTWEIGHT_DISPATCHER
"daemon: write active on %d\n",
fd, 0, 0 );
- waswrite = 1;
+ SLAP_EVENT_CLR_WRITE( i );
/*
* NOTE: it is possible that the connection was closed
continue;
}
}
- /* If event is a read or an error */
- if( SLAP_EVENT_IS_READ( i ) || !waswrite ) {
+ /* If event is a read */
+ if( SLAP_EVENT_IS_READ( i )) {
Debug( LDAP_DEBUG_CONNS,
"daemon: read active on %d\n",
fd, 0, 0 );
+ SLAP_EVENT_CLR_READ( i );
#ifdef SLAP_LIGHTWEIGHT_DISPATCHER
connection_read_activate( fd );
#else
*/
connection_read( fd );
#endif
+ } else {
+ Debug( LDAP_DEBUG_CONNS,
+ "daemon: hangup on %d\n", fd, 0, 0 );
}
}
}
#if defined( HAVE_WINSOCK2 ) || defined( HAVE_WINSOCK )
WSACleanup();
#endif
+ SLAP_SOCK_SET_DESTROY;
+
return 0;
}