From 0924180fa813af3767077df80e18d0ccbd947203 Mon Sep 17 00:00:00 2001 From: Ben Collins Date: Sat, 13 Mar 1999 20:34:27 +0000 Subject: [PATCH] Used new ldap_(un)lockf() functions --- servers/slapd/lock.c | 20 +++++--------------- servers/slurpd/lock.c | 18 +++--------------- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/servers/slapd/lock.c b/servers/slapd/lock.c index f634b220aa..391dd4639a 100644 --- a/servers/slapd/lock.c +++ b/servers/slapd/lock.c @@ -9,7 +9,9 @@ #include #include +#ifdef HAVE_SYS_FILE_H #include +#endif #include #include "slap.h" @@ -28,22 +30,14 @@ lock_fopen( char *fname, char *type, FILE **lfp ) } /* acquire the lock */ -#ifdef HAVE_FLOCK - while ( flock( fileno( *lfp ), LOCK_EX ) != 0 ) { -#else - while ( lockf( fileno( *lfp ), F_LOCK, 0 ) != 0 ) { -#endif + while ( ldap_lockf( *lfp ) != 0 ) { ; /* NULL */ } /* open the log file */ if ( (fp = fopen( fname, type )) == NULL ) { Debug( LDAP_DEBUG_ANY, "could not open \"%s\"\n", fname, 0, 0 ); -#ifdef HAVE_FLOCK - flock( fileno( *lfp ), LOCK_UN ); -#else - lockf( fileno( *lfp ), F_ULOCK, 0 ); -#endif + ldap_unlockf( *lfp ); fclose( *lfp ); *lfp = NULL; return( NULL ); @@ -56,11 +50,7 @@ int lock_fclose( FILE *fp, FILE *lfp ) { /* unlock */ -#ifdef HAVE_FLOCK - flock( fileno( lfp ), LOCK_UN ); -#else - lockf( fileno( lfp ), F_ULOCK, 0 ); -#endif + ldap_unlockf( lfp ); fclose( lfp ); return( fclose( fp ) ); diff --git a/servers/slurpd/lock.c b/servers/slurpd/lock.c index 726fc3c5c8..e4d7ddaffb 100644 --- a/servers/slurpd/lock.c +++ b/servers/slurpd/lock.c @@ -53,11 +53,7 @@ lock_fopen( } /* acquire the lock */ -#ifdef HAVE_FLOCK - while ( flock( fileno( *lfp ), LOCK_EX ) != 0 ) -#else - while ( lockf( fileno( *lfp ), F_LOCK, 0 ) != 0 ) -#endif + while ( ldap_lockf( *lfp ) != 0 ) { ; /* NULL */ } @@ -66,11 +62,7 @@ lock_fopen( if ( (fp = fopen( fname, type )) == NULL ) { Debug( LDAP_DEBUG_ANY, "Error: could not open \"%s\"\n", fname, 0, 0 ); -#ifdef HAVE_FLOCK - flock( fileno( *lfp ), LOCK_UN ); -#else - lockf( fileno( *lfp ), F_ULOCK, 0 ); -#endif + ldap_unlockf( *lfp ); fclose( *lfp ); *lfp = NULL; return( NULL ); @@ -88,11 +80,7 @@ lock_fclose( ) { /* unlock */ -#ifdef HAVE_FLOCK - flock( fileno( lfp ), LOCK_UN ); -#else - lockf( fileno( lfp ), F_ULOCK, 0 ); -#endif + ldap_unlockf( lfp ); fclose( lfp ); return( fclose( fp ) ); -- 2.39.5