proc_mutex.c (apr-1.6.5.tar.bz2) | : | proc_mutex.c (apr-1.7.0.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 46 | skipping to change at line 46 | |||
} | } | |||
APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, | APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, | |||
const char *fname, | const char *fname, | |||
apr_lockmech_e mech, | apr_lockmech_e mech, | |||
apr_pool_t *pool) | apr_pool_t *pool) | |||
{ | { | |||
HANDLE hMutex; | HANDLE hMutex; | |||
void *mutexkey; | void *mutexkey; | |||
if (mech != APR_LOCK_DEFAULT) { | if (mech != APR_LOCK_DEFAULT && mech != APR_LOCK_DEFAULT_TIMED) { | |||
return APR_ENOTIMPL; | return APR_ENOTIMPL; | |||
} | } | |||
/* res_name_from_filename turns fname into a pseduo-name | /* res_name_from_filename turns fname into a pseduo-name | |||
* without slashes or backslashes, and prepends the \global | * without slashes or backslashes, and prepends the \global | |||
* prefix on Win2K and later | * prefix on Win2K and later | |||
*/ | */ | |||
if (fname) { | if (fname) { | |||
mutexkey = res_name_from_filename(fname, 1, pool); | mutexkey = res_name_from_filename(fname, 1, pool); | |||
} | } | |||
skipping to change at line 167 | skipping to change at line 167 | |||
if (rv == WAIT_OBJECT_0 || rv == WAIT_ABANDONED) { | if (rv == WAIT_OBJECT_0 || rv == WAIT_ABANDONED) { | |||
return APR_SUCCESS; | return APR_SUCCESS; | |||
} | } | |||
else if (rv == WAIT_TIMEOUT) { | else if (rv == WAIT_TIMEOUT) { | |||
return APR_EBUSY; | return APR_EBUSY; | |||
} | } | |||
return apr_get_os_error(); | return apr_get_os_error(); | |||
} | } | |||
APR_DECLARE(apr_status_t) apr_proc_mutex_timedlock(apr_proc_mutex_t *mutex, | ||||
apr_interval_time_t timeout) | ||||
{ | ||||
DWORD rv, timeout_ms = 0; | ||||
apr_interval_time_t t = timeout; | ||||
do { | ||||
if (t > 0) { | ||||
/* Given timeout is 64bit usecs whereas Windows timeouts are | ||||
* 32bit msecs and below INFINITE (2^32 - 1), so we may need | ||||
* multiple timed out waits... | ||||
*/ | ||||
if (t > apr_time_from_msec(INFINITE - 1)) { | ||||
timeout_ms = INFINITE - 1; | ||||
t -= apr_time_from_msec(INFINITE - 1); | ||||
} | ||||
else { | ||||
timeout_ms = (DWORD)apr_time_as_msec(t); | ||||
t = 0; | ||||
} | ||||
} | ||||
rv = WaitForSingleObject(mutex->handle, timeout_ms); | ||||
} while (rv == WAIT_TIMEOUT && t > 0); | ||||
if (rv == WAIT_TIMEOUT) { | ||||
return APR_TIMEUP; | ||||
} | ||||
if (rv == WAIT_OBJECT_0 || rv == WAIT_ABANDONED) { | ||||
return APR_SUCCESS; | ||||
} | ||||
return apr_get_os_error(); | ||||
} | ||||
APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex) | APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex) | |||
{ | { | |||
if (ReleaseMutex(mutex->handle) == 0) { | if (ReleaseMutex(mutex->handle) == 0) { | |||
return apr_get_os_error(); | return apr_get_os_error(); | |||
} | } | |||
return APR_SUCCESS; | return APR_SUCCESS; | |||
} | } | |||
APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) | APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) | |||
{ | { | |||
skipping to change at line 243 | skipping to change at line 276 | |||
APR_DECLARE(apr_status_t) apr_os_proc_mutex_put_ex(apr_proc_mutex_t **pmutex, | APR_DECLARE(apr_status_t) apr_os_proc_mutex_put_ex(apr_proc_mutex_t **pmutex, | |||
apr_os_proc_mutex_t *ospmutex, | apr_os_proc_mutex_t *ospmutex, | |||
apr_lockmech_e mech, | apr_lockmech_e mech, | |||
int register_cleanup, | int register_cleanup, | |||
apr_pool_t *pool) | apr_pool_t *pool) | |||
{ | { | |||
if (pool == NULL) { | if (pool == NULL) { | |||
return APR_ENOPOOL; | return APR_ENOPOOL; | |||
} | } | |||
if (mech != APR_LOCK_DEFAULT) { | if (mech != APR_LOCK_DEFAULT && mech != APR_LOCK_DEFAULT_TIMED) { | |||
return APR_ENOTIMPL; | return APR_ENOTIMPL; | |||
} | } | |||
if ((*pmutex) == NULL) { | if ((*pmutex) == NULL) { | |||
(*pmutex) = (apr_proc_mutex_t *)apr_palloc(pool, | (*pmutex) = (apr_proc_mutex_t *)apr_palloc(pool, | |||
sizeof(apr_proc_mutex_t)); | sizeof(apr_proc_mutex_t)); | |||
(*pmutex)->pool = pool; | (*pmutex)->pool = pool; | |||
} | } | |||
(*pmutex)->handle = *ospmutex; | (*pmutex)->handle = *ospmutex; | |||
End of changes. 3 change blocks. | ||||
2 lines changed or deleted | 35 lines changed or added |