From 9207979a8607acdb9e28a37aea0b74eed676f94b Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 28 Apr 2006 20:13:34 +0000 Subject: [PATCH] Use recursive mutex to avoid deadlocks --- servers/slapd/overlays/accesslog.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/servers/slapd/overlays/accesslog.c b/servers/slapd/overlays/accesslog.c index c0454cf200..59fb6821d0 100644 --- a/servers/slapd/overlays/accesslog.c +++ b/servers/slapd/overlays/accesslog.c @@ -60,7 +60,7 @@ typedef struct log_info { Filter *li_oldf; Entry *li_old; int li_success; - ldap_pvt_thread_mutex_t li_op_mutex; + ldap_pvt_thread_rmutex_t li_op_rmutex; ldap_pvt_thread_mutex_t li_log_mutex; } log_info; @@ -872,7 +872,7 @@ static int accesslog_response(Operation *op, SlapReply *rs) { ldap_pvt_thread_mutex_lock( &li->li_log_mutex ); old = li->li_old; li->li_old = NULL; - ldap_pvt_thread_mutex_unlock( &li->li_op_mutex ); + ldap_pvt_thread_rmutex_unlock( &li->li_op_rmutex ); } if ( li->li_success && rs->sr_err != LDAP_SUCCESS ) @@ -1184,10 +1184,7 @@ accesslog_op_mod( Operation *op, SlapReply *rs ) log_info *li = on->on_bi.bi_private; if ( li->li_ops & LOG_OP_WRITES ) { - /* FIXME: this needs to be a recursive mutex to allow - * overlays like refint to keep working. - */ - ldap_pvt_thread_mutex_lock( &li->li_op_mutex ); + ldap_pvt_thread_rmutex_lock( &li->li_op_rmutex ); if ( li->li_oldf && ( op->o_tag == LDAP_REQ_DELETE || op->o_tag == LDAP_REQ_MODIFY )) { int rc; @@ -1291,7 +1288,7 @@ accesslog_db_init( log_info *li = ch_calloc(1, sizeof(log_info)); on->on_bi.bi_private = li; - ldap_pvt_thread_mutex_init( &li->li_op_mutex ); + ldap_pvt_thread_rmutex_init( &li->li_op_rmutex ); ldap_pvt_thread_mutex_init( &li->li_log_mutex ); return 0; } @@ -1305,7 +1302,7 @@ accesslog_db_destroy( log_info *li = on->on_bi.bi_private; ldap_pvt_thread_mutex_destroy( &li->li_log_mutex ); - ldap_pvt_thread_mutex_destroy( &li->li_op_mutex ); + ldap_pvt_thread_rmutex_destroy( &li->li_op_rmutex ); free( li ); return LDAP_SUCCESS; } -- 2.39.5