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.
This commit is contained in:
Hallvard Furuseth 1998-11-11 19:17:25 +00:00
parent f165bb2b96
commit f0688d71a1
6 changed files with 11 additions and 5 deletions

View file

@ -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 );
}

View file

@ -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 );
}

View file

@ -68,6 +68,8 @@ lock_fopen(
#else
lockf( fileno( *lfp ), F_ULOCK, 0 );
#endif
fclose( *lfp );
*lfp = NULL;
return( NULL );
}

View file

@ -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 );

View file

@ -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 */

View file

@ -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 ) {