apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ronen Mizrahi <ro...@tversity.com>
Subject Possible bug in proc_mutex.c on Win32
Date Sat, 10 Sep 2005 05:13:42 GMT
Hi,

The function apr_proc_mutex_trylock(apr_proc_mutex_t *mutex) is supposed 
to return APR_EBUSY if the mutex is already locked, however it never 
does that. The following is taken from the SVN head:

*APR_DECLARE*(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex)
{
    DWORD rv;

    rv = WaitForSingleObject(mutex->handle, 0);

    *if* (rv == WAIT_OBJECT_0 || rv == WAIT_ABANDONED) {
        *return* APR_SUCCESS;
    }
    *return* apr_get_os_error();
}


I suggest modifying it to (based on apr_thread_mutex_trylock()):

APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex)
{
    DWORD rv;

    rv = WaitForSingleObject(mutex->handle, 0);

    if (rv == WAIT_OBJECT_0 || rv == WAIT_ABANDONED) {
        return APR_SUCCESS;
    }
   return (rv == WAIT_TIMEOUT) ? APR_EBUSY : apr_get_os_error();
}

Please let me know if this is ok,

Ronen

Mime
View raw message