wrowe 2003/06/18 15:31:08
Modified: threadproc/win32 thread.c
locks/win32 thread_rwlock.c
Log:
Clean up a style issue; apr_get_os_error() is much cleaner.
Note that the result from WaitFor{*}() calls is a rather
special case, since it has other interesting details. These
were not touched since they are clearer as-is.
Revision Changes Path
1.54 +1 -1 apr/threadproc/win32/thread.c
Index: thread.c
===================================================================
RCS file: /home/cvs/apr/threadproc/win32/thread.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- thread.c 18 Jun 2003 19:00:41 -0000 1.53
+++ thread.c 18 Jun 2003 22:31:07 -0000 1.54
@@ -175,7 +175,7 @@
return APR_SUCCESS;
}
/* Wait failed */
- return APR_FROM_OS_ERROR(GetLastError());
+ return apr_get_os_error();;
}
APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd)
1.10 +13 -13 apr/locks/win32/thread_rwlock.c
Index: thread_rwlock.c
===================================================================
RCS file: /home/cvs/apr/locks/win32/thread_rwlock.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- thread_rwlock.c 18 Jun 2003 19:13:48 -0000 1.9
+++ thread_rwlock.c 18 Jun 2003 22:31:08 -0000 1.10
@@ -74,13 +74,13 @@
if (! ((*rwlock)->read_event = CreateEvent(NULL, TRUE, FALSE, NULL))) {
*rwlock = NULL;
- return APR_FROM_OS_ERROR(GetLastError());
+ return apr_get_os_error();
}
if (! ((*rwlock)->write_mutex = CreateMutex(NULL, FALSE, NULL))) {
CloseHandle((*rwlock)->read_event);
*rwlock = NULL;
- return APR_FROM_OS_ERROR(GetLastError());
+ return apr_get_os_error();
}
apr_pool_cleanup_register(pool, *rwlock, thread_rwlock_cleanup,
@@ -104,10 +104,10 @@
InterlockedIncrement(&rwlock->readers);
if (! ResetEvent(rwlock->read_event))
- return APR_FROM_OS_ERROR(GetLastError());
+ return apr_get_os_error();
if (! ReleaseMutex(rwlock->write_mutex))
- return APR_FROM_OS_ERROR(GetLastError());
+ return apr_get_os_error();
return APR_SUCCESS;
}
@@ -145,7 +145,7 @@
if (code == WAIT_FAILED || code == WAIT_TIMEOUT) {
/* Unable to wait for readers to finish, release write lock: */
if (! ReleaseMutex(rwlock->write_mutex))
- return APR_FROM_OS_ERROR(GetLastError());
+ return apr_get_os_error();
return APR_FROM_OS_ERROR(code);
}
@@ -166,34 +166,34 @@
APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t
*rwlock)
{
- DWORD code = 0;
+ apr_status_t rv = 0;
/* First, guess that we're unlocking a writer */
if (! ReleaseMutex(rwlock->write_mutex))
- code = GetLastError();
+ rv = apr_get_os_error();
- if (code == ERROR_NOT_OWNER) {
+ if (rv == APR_FROM_OS_ERROR(ERROR_NOT_OWNER)) {
/* Nope, we must have a read lock */
if (rwlock->readers &&
! InterlockedDecrement(&rwlock->readers) &&
! SetEvent(rwlock->read_event)) {
- code = GetLastError();
+ rv = apr_get_os_error();
}
else {
- code = 0;
+ rv = 0;
}
}
- return APR_FROM_OS_ERROR(code);
+ return rv;
}
APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t
*rwlock)
{
if (! CloseHandle(rwlock->read_event))
- return APR_FROM_OS_ERROR(GetLastError());
+ return apr_get_os_error();
if (! CloseHandle(rwlock->write_mutex))
- return APR_FROM_OS_ERROR(GetLastError());
+ return apr_get_os_error();
return APR_SUCCESS;
}