From 28fa9c6c9f3ab304ebf67e8b55cff0c0bebb45ea Mon Sep 17 00:00:00 2001 From: Waldo Bastian Date: Wed, 28 Jun 2000 21:53:10 +0000 Subject: [PATCH] WABA: Drop flock, always use fcntl(..., F_SETLK, ...) svn path=/trunk/kdenetwork/kmail/; revision=54791 --- kmfolder.cpp | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/kmfolder.cpp b/kmfolder.cpp index c47754349..63eddf044 100644 --- a/kmfolder.cpp +++ b/kmfolder.cpp @@ -26,18 +26,13 @@ #include #endif -#if HAVE_FCNTL_H && !HAVE_FLOCK +#if HAVE_FCNTL_H #include #endif #include #include #include - -#ifndef _BSD_COMPAT -#define _BSD_COMPAT // flock is under BSD compliance oat least on IRIX -#endif - #include #include @@ -303,22 +298,16 @@ void KMFolder::close(bool aForced) int KMFolder::lock() { int rc; -#if !HAVE_FLOCK struct flock fl; fl.l_type=F_WRLCK; fl.l_whence=0; fl.l_start=0; fl.l_len=0; -#endif assert(mStream != NULL); mFilesLocked = FALSE; -#if HAVE_FLOCK - rc = flock(fileno(mStream), LOCK_NB|LOCK_EX); -#else rc = fcntl(fileno(mStream), F_SETLK, &fl); -#endif if (rc < 0) { @@ -329,23 +318,15 @@ int KMFolder::lock() if (mIndexStream) { -#if HAVE_FLOCK - rc = flock(fileno(mIndexStream), LOCK_UN); -#else rc = fcntl(fileno(mIndexStream), F_SETLK, &fl); -#endif if (rc < 0) { debug("Cannot lock index of folder `%s': %s", (const char*)location(), strerror(errno)); rc = errno; -#if HAVE_FLOCK - rc = flock(fileno(mIndexStream), LOCK_UN); -#else fl.l_type = F_UNLCK; rc = fcntl(fileno(mIndexStream), F_SETLK, &fl); -#endif return rc; } } @@ -359,24 +340,17 @@ int KMFolder::lock() int KMFolder::unlock() { int rc; -#if !HAVE_FLOCK struct flock fl; fl.l_type=F_UNLCK; fl.l_whence=0; fl.l_start=0; fl.l_len=0; -#endif assert(mStream != NULL); mFilesLocked = FALSE; -#if HAVE_FLOCK - if (mIndexStream) flock(fileno(mIndexStream), LOCK_UN); - rc = flock(fileno(mStream), LOCK_UN); -#else if (mIndexStream) fcntl(fileno(mIndexStream), F_SETLK, &fl); rc = fcntl(fileno(mStream), F_SETLK, F_UNLCK); -#endif return errno; }