summaryrefslogtreecommitdiff
path: root/file_io/win32/flock.c
diff options
context:
space:
mode:
Diffstat (limited to 'file_io/win32/flock.c')
-rw-r--r--file_io/win32/flock.c50
1 files changed, 10 insertions, 40 deletions
diff --git a/file_io/win32/flock.c b/file_io/win32/flock.c
index 708099a91..f314bdccb 100644
--- a/file_io/win32/flock.c
+++ b/file_io/win32/flock.c
@@ -24,35 +24,11 @@ APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type)
flags = ((type & APR_FLOCK_NONBLOCK) ? LOCKFILE_FAIL_IMMEDIATELY : 0)
+ (((type & APR_FLOCK_TYPEMASK) == APR_FLOCK_SHARED)
? 0 : LOCKFILE_EXCLUSIVE_LOCK);
- if (apr_os_level >= APR_WIN_NT) {
- /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
- OVERLAPPED offset;
- memset (&offset, 0, sizeof(offset));
- if (!LockFileEx(thefile->filehand, flags, 0, len, len, &offset))
- return apr_get_os_error();
- }
- else {
- /* On Win9x, LockFile() never blocks. Hack in a crufty poll.
- *
- * Note that this hack exposes threads to being unserviced forever,
- * in the situation that the given lock has low availability.
- * When implemented in the kernel, LockFile will typically use
- * FIFO or round robin distribution to ensure all threads get
- * one crack at the lock; but in this case we can't emulate that.
- *
- * However Win9x are barely maintainable anyways, if the user does
- * choose to build to them, this is the best we can do.
- */
- while (!LockFile(thefile->filehand, 0, 0, len, 0)) {
- DWORD err = GetLastError();
- if ((err == ERROR_LOCK_VIOLATION) && !(type & APR_FLOCK_NONBLOCK))
- {
- Sleep(500); /* pause for a half second */
- continue; /* ... and then poll again */
- }
- return APR_FROM_OS_ERROR(err);
- }
- }
+ /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
+ OVERLAPPED offset;
+ memset (&offset, 0, sizeof(offset));
+ if (!LockFileEx(thefile->filehand, flags, 0, len, len, &offset))
+ return apr_get_os_error();
return APR_SUCCESS;
}
@@ -61,17 +37,11 @@ APR_DECLARE(apr_status_t) apr_file_unlock(apr_file_t *thefile)
{
DWORD len = 0xffffffff;
- if (apr_os_level >= APR_WIN_NT) {
- /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
- OVERLAPPED offset;
- memset (&offset, 0, sizeof(offset));
- if (!UnlockFileEx(thefile->filehand, 0, len, len, &offset))
- return apr_get_os_error();
- }
- else {
- if (!UnlockFile(thefile->filehand, 0, 0, len, 0))
- return apr_get_os_error();
- }
+ /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
+ OVERLAPPED offset;
+ memset (&offset, 0, sizeof(offset));
+ if (!UnlockFileEx(thefile->filehand, 0, len, len, &offset))
+ return apr_get_os_error();
return APR_SUCCESS;
}