Commit 3cfd58ee authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

EXPERIMENTAL: move slapd_remove to connections_read/_write as they

acquire c_mutex.
parent 34f068f1
......@@ -30,7 +30,6 @@ static long conn_nextid = 0;
#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 );
......@@ -374,7 +373,7 @@ connection_destroy( 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,
......@@ -678,6 +677,9 @@ int connection_read(int s)
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;
}
......@@ -902,10 +904,14 @@ int connection_write(int s)
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;
}
......
......@@ -29,17 +29,17 @@ void hit_socket();
/* 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)
......@@ -96,10 +96,9 @@ static void slapd_add(int s) {
/*
* 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" : "",
......@@ -114,7 +113,7 @@ void slapd_remove(int s) {
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 );
......@@ -124,7 +123,7 @@ void slapd_clr_write(int s, int wake) {
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) );
......@@ -135,7 +134,7 @@ void slapd_set_write(int s, int wake) {
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 );
......@@ -146,7 +145,7 @@ void slapd_clr_read(int s, int wake) {
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 );
......@@ -155,8 +154,6 @@ void slapd_set_read(int s, int wake) {
}
static void slapd_close(int s) {
slapd_remove(s);
Debug( LDAP_DEBUG_CONNS, "daemon: closing %d\n", s, 0, 0 );
tcp_close(s);
}
......@@ -427,7 +424,7 @@ slapd_daemon_task(
Debug( LDAP_DEBUG_ANY,
"daemon: %d beyond descriptor table size %d\n",
s, dtblsize, 0 );
tcp_close(s);
slapd_close(s);
continue;
}
#endif
......@@ -479,7 +476,7 @@ slapd_daemon_task(
client_addr == NULL ? "unknown" : client_addr,
0, 0 );
tcp_close(s);
slapd_close(s);
continue;
}
#endif /* HAVE_TCPD */
......@@ -491,7 +488,7 @@ slapd_daemon_task(
s,
client_name == NULL ? "unknown" : client_name,
client_addr == NULL ? "unknown" : client_addr);
tcp_close(s);
slapd_close(s);
continue;
}
......@@ -564,11 +561,10 @@ slapd_daemon_task(
/* 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 );
......@@ -607,7 +603,7 @@ slapd_daemon_task(
/* 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;
}
......@@ -634,7 +630,7 @@ slapd_daemon_task(
}
if( tcps >= 0 ) {
tcp_close( tcps );
slapd_close( tcps );
}
/* we only implement "quick" shutdown */
......
......@@ -340,6 +340,8 @@ extern void slapd_clr_write LDAP_P((int s, int wake));
extern void slapd_set_read LDAP_P((int s, int wake));
extern void slapd_clr_read LDAP_P((int s, int wake));
extern void slapd_remove LDAP_P((int s, int wake));
extern void slap_set_shutdown LDAP_P((int sig));
extern void slap_do_nothing LDAP_P((int sig));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment