You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by ch...@potamus.org on 2004/09/14 00:14:49 UTC

error checking for apr_thread_mutex_lock()?

According to the Apache 2.1 project plan [1], one of
the goals is to "check returns from all system calls:
read, write, etc." However, in the Apache and APR code,
I see that almost no one checks whether the thread
mutex lock functions return an error apr_status_t.

Can we safely assume that all calls to 
apr_thread_mutex_lock() will (eventually) succeed? If
so, then apr_thread_mutex_lock() could just return
void. However, I know apr_thread_mutex_lock() CAN fail
(in rare circumstances) on Win32. Microsoft's MSDN docs
for EnterCriticalSection() [2] say that this API can
raise an exception during low-memory or deadlock. So if
APR wants to be VERY careful about error-handling, then
Win32's apr_thread_mutex_lock() might want to wrap
EnterCriticalSection() in a "structured exception
handling" __try/__catch block to catch these exceptions.

Would this error-handling be too pedantic? I think
these EnterCriticalSection() errors would only happen
during high contention for locks when kernel memory is
low.

btw, I've been following APR development for a while
and it looks great! <:)


chris


[1] http://httpd.apache.org/dev/project-plan.html

[2]
http://msdn.microsoft.com/library/en-us/dllproc/base/entercriticalsection.asp