#define SLAP_C_BINDING 0x03 /* binding */
#define SLAP_C_CLOSING 0x04 /* closing */
-void slapd_remove(int s);
static Connection* connection_get( int s );
static int connection_input( Connection *c );
if ( ber_pvt_sb_in_use(c->c_sb) ) {
int sd = ber_pvt_sb_get_desc(c->c_sb);
- slapd_remove( sd );
+ slapd_remove( sd, 0 );
ber_pvt_sb_close( c->c_sb );
Statslog( LDAP_DEBUG_STATS,
Debug( LDAP_DEBUG_ANY,
"connection_read(%d): no connection!\n",
s, 0, 0 );
+
+ slapd_remove(s, 0);
+
ldap_pvt_thread_mutex_unlock( &connections_mutex );
return -1;
}
ldap_pvt_thread_mutex_lock( &connections_mutex );
c = connection_get( s );
+
+ slapd_clr_write( s, 0);
+
if( c == NULL ) {
Debug( LDAP_DEBUG_ANY,
"connection_write(%d): no connection!\n",
s, 0, 0 );
+ slapd_remove(s, 0);
ldap_pvt_thread_mutex_unlock( &connections_mutex );
return -1;
}
/* In wsa_err.c */
char *WSAGetLastErrorString();
-#define WAKE_LISTENER \
+#define WAKE_LISTENER(w) \
do {\
- if( wake ) {\
+ if( w ) {\
ldap_pvt_thread_kill( listener_tid, LDAP_SIGUSR1 );\
hit_socket();\
}\
} while(0)
#else
-#define WAKE_LISTENER \
+#define WAKE_LISTENER(w) \
do {\
- if( wake ) {\
+ if( w ) {\
ldap_pvt_thread_kill( listener_tid, LDAP_SIGUSR1 );\
}\
} while(0)
/*
* Remove the descriptor from daemon control
*/
-void slapd_remove(int s) {
+void slapd_remove(int s, int wake) {
ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
-
- assert( FD_ISSET( s, &slap_daemon.sd_actives ));
+ WAKE_LISTENER(wake);
Debug( LDAP_DEBUG_CONNS, "daemon: removing %d%s%s\n", s,
FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
void slapd_clr_write(int s, int wake) {
ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
- WAKE_LISTENER;
+ WAKE_LISTENER(wake);
assert( FD_ISSET( (unsigned) s, &slap_daemon.sd_actives) );
FD_CLR( (unsigned) s, &slap_daemon.sd_writers );
void slapd_set_write(int s, int wake) {
ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
- WAKE_LISTENER;
+ WAKE_LISTENER(wake);
assert( FD_ISSET( s, &slap_daemon.sd_actives) );
void slapd_clr_read(int s, int wake) {
ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
- WAKE_LISTENER;
+ WAKE_LISTENER(wake);
assert( FD_ISSET( s, &slap_daemon.sd_actives) );
FD_CLR( (unsigned) s, &slap_daemon.sd_readers );
void slapd_set_read(int s, int wake) {
ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
- WAKE_LISTENER;
+ WAKE_LISTENER(wake);
assert( FD_ISSET( s, &slap_daemon.sd_actives) );
FD_SET( (unsigned) s, &slap_daemon.sd_readers );
}
static void slapd_close(int s) {
- slapd_remove(s);
-
Debug( LDAP_DEBUG_CONNS, "daemon: closing %d\n", s, 0, 0 );
tcp_close(s);
}
Debug( LDAP_DEBUG_ANY,
"daemon: %d beyond descriptor table size %d\n",
s, dtblsize, 0 );
- tcp_close(s);
+ slapd_close(s);
continue;
}
#endif
client_addr == NULL ? "unknown" : client_addr,
0, 0 );
- tcp_close(s);
+ slapd_close(s);
continue;
}
#endif /* HAVE_TCPD */
s,
client_name == NULL ? "unknown" : client_name,
client_addr == NULL ? "unknown" : client_addr);
- tcp_close(s);
+ slapd_close(s);
continue;
}
/* descriptor no longer in FD set, should be closed */
Debug( LDAP_DEBUG_CONNS,
"daemon: write %d inactive, closing.\n", wd, 0, 0 );
- tcp_close( wd );
+ slapd_close( wd );
continue;
}
- slapd_clr_write( wd, 0 );
if ( connection_write( wd ) < 0 ) {
FD_CLR( (unsigned) wd, &readfds );
slapd_close( wd );
/* descriptor no longer in FD set, should be closed */
Debug( LDAP_DEBUG_CONNS,
"daemon: read %d inactive, closing.\n", rd, 0, 0 );
- tcp_close( rd );
+ slapd_close( rd );
continue;
}
}
if( tcps >= 0 ) {
- tcp_close( tcps );
+ slapd_close( tcps );
}
/* we only implement "quick" shutdown */