apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bojan Smojver <bo...@rexursive.com>
Subject Re: apr_file_close()/apr_socket_close()
Date Fri, 30 Oct 2009 06:22:14 GMT
On Fri, 2009-10-30 at 17:13 +1100, Bojan Smojver wrote:
> It gets worse - they may get an FD which was reused by yet another
> thread. Quite dangerous.

What I am getting at here is a particular situation where the thread
closing of our file has been suspended (say, got a signal and is now in
sigsuspend() within the signal handler, waiting for another signal to be
woken up).

If it so happens that close() just successfully finished and
file->filedes was not set to -1 yet, there is a possibility that the FD
returned by apr_file_os_get() may be an FD reused already by another
thread (or at least, it will be closed).

If we set file->filedes to -1 early, we can at least defend against that
use case.


View raw message