[P3L-CVS] CVS: pop3lite/src misc.c,1.18.2.3,1.18.2.4
Brought to you by:
algernon
From: Gergely N. <alg...@us...> - 2001-05-31 19:33:14
|
Update of /cvsroot/pop3lite/pop3lite/src In directory usw-pr-cvs1:/tmp/cvs-serv30602 Modified Files: Tag: pop3lite-0_2_0-branch misc.c Log Message: (p3l_lock_fd, p3l_unlock_fd): use flock/fcntl too, not lockfile_create only Index: misc.c =================================================================== RCS file: /cvsroot/pop3lite/pop3lite/src/misc.c,v retrieving revision 1.18.2.3 retrieving revision 1.18.2.4 diff -u -r1.18.2.3 -r1.18.2.4 --- misc.c 2001/05/30 12:40:00 1.18.2.3 +++ misc.c 2001/05/31 19:33:12 1.18.2.4 @@ -321,25 +321,26 @@ int p3l_lock_fd ( int fd, char *fn ) { + int retcode; +#ifdef HAVE_FLOCK + retcode = flock ( fd, LOCK_EX | LOCK_NB ); +#endif + #ifdef HAVE_LOCKFILE - return ( lockfile_create ( g_strdup_printf ( "%s.lock", fn ), 1, L_PID ) == 0 ) ? 0 : -1; + retcode = ( lockfile_create ( g_strdup_printf ( "%s.lock", fn ), 1, L_PID ) == 0 ) ? 0 : -1; #else #if defined(F_SETLK) && !defined(HAVE_FLOCK) struct flock arg; #endif +#endif -#ifdef HAVE_FLOCK - return flock ( fd, LOCK_EX | LOCK_NB ); -#else -#if defined(F_SETLK) +#if !defined(HAVE_FLOCK) && defined (F_SETLK) arg.l_type = F_WRLCK; arg.l_whence = arg.l_start = arg.l_len = arg.l_pid = 0; - return fcntl ( fd, F_SETLK, &arg ); -#else - return lockf ( fd, F_TLOCK, 0 ); + retcode = fcntl ( fd, F_SETLK, &arg ); #endif /* defined(F_SETLK) */ -#endif /* HAVE_FLOCK */ -#endif /* HAVE_LOCKFILE */ + + return retcode; } /** @@ -357,7 +358,7 @@ int retcode; #ifdef HAVE_LOCKFILE - return ( lockfile_remove ( g_strdup_printf ( "%s.lock", fn ) ) == 0 ) ? 0 : -1; + retcode = ( lockfile_remove ( g_strdup_printf ( "%s.lock", fn ) ) == 0 ) ? 0 : -1; #endif #ifdef HAVE_FLOCK @@ -369,8 +370,6 @@ arg.l_type = F_UNLCK; arg.l_whence = arg.l_start = arg.l_len = arg.l_pid = 0; retcode = fcntl ( fd, F_SETLK, &arg ); -#else - retcode = lockf ( fd, F_ULOCK, 0 ); #endif /* defined(F_SETLK) */ #endif /* HAVE_FLOCK */ return retcode; |