Skip to content
Snippets Groups Projects
Commit 0924180f authored by Ben Collins's avatar Ben Collins
Browse files

Used new ldap_(un)lockf() functions

parent 75d6e3f7
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,9 @@
#include <ac/time.h>
#include <ac/unistd.h>
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
#include <sys/param.h>
#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 ) );
......
......@@ -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 ) );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment