stoddard 01/08/13 06:22:30
Modified: . CHANGES
file_io/win32 flock.c
Log:
Get apr_file_lock and apr_file_unlock working on Win9x. Not tested.
Submitted by: Mladen Turk
Reviewed by: Bill Stoddard
Revision Changes Path
1.136 +2 -0 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -r1.135 -r1.136
--- CHANGES 2001/08/13 04:20:18 1.135
+++ CHANGES 2001/08/13 13:22:30 1.136
@@ -1,4 +1,6 @@
Changes with APR b1
+ *) Get apr_lock_file and apr_unlock_file working on Windows 9x.
+ [Mladen Turk, Bill Stoddard]
*) Make all APR pools be allocated out of the permanent pool.
This brings APR pools back to a tree structure. There are
1.6 +23 -6 apr/file_io/win32/flock.c
Index: flock.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/flock.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- flock.c 2001/08/07 14:23:38 1.5
+++ flock.c 2001/08/13 13:22:30 1.6
@@ -56,6 +56,7 @@
APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type)
{
+ apr_oslevel_e level;
OVERLAPPED offset;
DWORD flags, len = 0xffffffff;
@@ -68,22 +69,38 @@
* the lock; something needs to be done so an APR app can
* recognize this as a try-again situation
*/
- /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
- if (!LockFileEx(thefile->filehand, flags, 0, len, len, &offset))
- return apr_get_os_error();
+ apr_get_oslevel(NULL, &level);
+ if (level >= APR_WIN_NT) {
+ /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
+ if (!LockFileEx(thefile->filehand, flags, 0, len, len, &offset))
+ return apr_get_os_error();
+ }
+ else {
+ if (!LockFile(thefile->filehand, 0, 0, len, 0))
+ return apr_get_os_error();
+ }
return APR_SUCCESS;
}
APR_DECLARE(apr_status_t) apr_file_unlock(apr_file_t *thefile)
{
+ apr_oslevel_e level;
OVERLAPPED offset;
DWORD len = 0xffffffff;
memset (&offset, 0, sizeof(offset));
- /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
- if (!UnlockFileEx(thefile->filehand, 0, len, len, &offset))
- return apr_get_os_error();
+
+ apr_get_oslevel(NULL, &level);
+ if (level >= APR_WIN_NT) {
+ /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
+ 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();
+ }
return APR_SUCCESS;
}