From eb16636abe2dd2b810d155c49dd21de988f8e311 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 17 Oct 2006 19:37:10 +0000 Subject: [PATCH] Tweak prev commit, add more notes (re ITS#4667) --- servers/slapd/connection.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index ebdac9bcf4..3643713cc8 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -831,6 +831,10 @@ void connection_closing( Connection *c, const char *why ) /* wake write blocked operations */ if ( c->c_writewaiter ) { ldap_pvt_thread_cond_signal( &c->c_write_cv ); + /* ITS#4667 this may allow another thread to drop into + * connection_resched / connection_close before we + * finish, but that's OK. + */ ldap_pvt_thread_mutex_unlock( &c->c_mutex ); slapd_clr_write( sd, 1 ); ldap_pvt_thread_mutex_lock( &c->c_write_mutex ); @@ -854,10 +858,12 @@ connection_close( Connection *c ) assert( connections != NULL ); assert( c != NULL ); - if ( c->c_conn_state != SLAP_C_CLOSING ) + /* ITS#4667 we may have gotten here twice */ + if ( c->c_conn_state == SLAP_C_INVALID ) return; assert( c->c_struct_state == SLAP_C_USED ); + assert( c->c_struct_state == SLAP_C_CLOSING ); /* NOTE: c_mutex should be locked by caller */ -- 2.39.5