From bac87c256234bb83a7d545cfb708ce75cfc4b1b6 Mon Sep 17 00:00:00 2001 From: Mark Valence Date: Sun, 4 Jun 2000 04:29:07 +0000 Subject: [PATCH] Bug fix for new sockbuf code under NT. Added mutex protection against deadlock in connection_resched. --- servers/slapd/connection.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index a519b1a85b..a1ef902c2d 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -327,16 +327,18 @@ long connection_init( c = NULL; for( i=0; i < dtblsize; i++) { - ber_socket_t sd; + ber_socket_t sd; - ber_sockbuf_ctrl( connections[i].c_sb, LBER_SB_OPT_GET_FD, &sd ); - if( connections[i].c_struct_state == SLAP_C_UNINITIALIZED ) { assert( connections[i].c_sb == 0 ); c = &connections[i]; break; } + sd = AC_SOCKET_INVALID; + if (connections[i].c_sb != NULL) + ber_sockbuf_ctrl( connections[i].c_sb, LBER_SB_OPT_GET_FD, &sd ); + if( connections[i].c_struct_state == SLAP_C_UNUSED ) { assert( sd == AC_SOCKET_INVALID ); c = &connections[i]; @@ -1064,7 +1066,9 @@ connection_resched( Connection *conn ) "connection_resched: attempting closing conn=%ld sd=%d\n", conn->c_connid, sd, 0 ); + ldap_pvt_thread_mutex_lock( &connections_mutex ); connection_close( conn ); + ldap_pvt_thread_mutex_unlock( &connections_mutex ); return 0; } -- 2.39.5