From: Hallvard Furuseth Date: Wed, 11 Nov 1998 19:17:25 +0000 (+0000) Subject: Locks were not always released, in particular if something went wrong. X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~1135 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f0688d71a1e176fd17ffe2d70e2f9556b9967ab2;p=openldap Locks were not always released, in particular if something went wrong. Fixed in slurpd and the slapd main dir. Slapd clients were not examined. It also "felt right" to swap the order of closing dfp and rfp in slurpd copy_replog(), so the last acquired lock is unlocked first. --- diff --git a/servers/slapd/lock.c b/servers/slapd/lock.c index 47f09cf546..ad80443eb9 100644 --- a/servers/slapd/lock.c +++ b/servers/slapd/lock.c @@ -43,6 +43,8 @@ lock_fopen( char *fname, char *type, FILE **lfp ) #else lockf( fileno( *lfp ), F_ULOCK, 0 ); #endif + fclose( *lfp ); + *lfp = NULL; return( NULL ); } diff --git a/servers/slurpd/fm.c b/servers/slurpd/fm.c index 2aed9e602e..602f8cd8a6 100644 --- a/servers/slurpd/fm.c +++ b/servers/slurpd/fm.c @@ -210,8 +210,7 @@ populate_queue( Debug( LDAP_DEBUG_ANY, "error: can't seek to offset %ld in file \"%s\"\n", sglob->srpos, f, 0 ); - return; - } + } else { while (( p = get_record( fp )) != NULL ) { if ( sglob->rq->rq_add( sglob->rq, p ) < 0 ) { char *t; @@ -227,6 +226,7 @@ populate_queue( pthread_yield(); } sglob->srpos = ftell( fp ); + } (void) relinquish_lock( f, fp, lfp ); } diff --git a/servers/slurpd/lock.c b/servers/slurpd/lock.c index 17bc995efa..3e41854eb0 100644 --- a/servers/slurpd/lock.c +++ b/servers/slurpd/lock.c @@ -68,6 +68,8 @@ lock_fopen( #else lockf( fileno( *lfp ), F_ULOCK, 0 ); #endif + fclose( *lfp ); + *lfp = NULL; return( NULL ); } diff --git a/servers/slurpd/replog.c b/servers/slurpd/replog.c index 5573215cc5..732f3cf520 100644 --- a/servers/slurpd/replog.c +++ b/servers/slurpd/replog.c @@ -117,7 +117,7 @@ copy_replog( Debug( LDAP_DEBUG_ANY, "Error: copy_replog: Can't lock replog \"%s\" for write: %s\n", src, sys_errlist[ errno ], 0 ); - lock_fclose( rfp ); + lock_fclose( rfp, lfp ); return( 1 ); } @@ -133,12 +133,12 @@ copy_replog( truncate( src, (off_t) 0 ); } - if ( lock_fclose( rfp, lfp ) == EOF ) { + if ( lock_fclose( dfp, dlfp ) == EOF ) { Debug( LDAP_DEBUG_ANY, "Error: copy_replog: Error closing \"%s\"\n", src, 0, 0 ); } - if ( lock_fclose( dfp, dlfp ) == EOF ) { + if ( lock_fclose( rfp, lfp ) == EOF ) { Debug( LDAP_DEBUG_ANY, "Error: copy_replog: Error closing \"%s\"\n", src, 0, 0 ); diff --git a/servers/slurpd/ri.c b/servers/slurpd/ri.c index af7a846e45..964410235a 100644 --- a/servers/slurpd/ri.c +++ b/servers/slurpd/ri.c @@ -124,6 +124,7 @@ Ri_process( while ( !sglob->slurpd_shutdown && ((new_re = re->re_getnext( re )) == NULL )) { if ( sglob->one_shot_mode ) { + rq->rq_unlock( rq ); return 0; } /* No work - wait on condition variable */ diff --git a/servers/slurpd/st.c b/servers/slurpd/st.c index d18f5381fd..db5035a1f4 100644 --- a/servers/slurpd/st.c +++ b/servers/slurpd/st.c @@ -181,6 +181,7 @@ St_read( return 0; } if (( rc = acquire_lock( sglob->slurpd_status_file, &fp, &lfp)) < 0 ) { + pthread_mutex_unlock( &(st->st_mutex )); return 0; } while ( fgets( buf, sizeof( buf ), fp ) != NULL ) {