httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bojan Smojver <bo...@rexursive.com>
Subject Re: worker MPM: close_worker_sockets race?
Date Fri, 30 Oct 2009 04:48:17 GMT
On Fri, 2009-10-30 at 14:59 +1100, Bojan Smojver wrote:
> +            apr_os_sock_get((apr_os_sock_t *)&csd,
> worker_data[i].socket);
> +            if (csd != -1) {
> +                shutdown(csd, SHUT_RDWR);

BTW, there is a possibility of a race condition above. Slight, but still
there.

In APR, we set the FD to -1 only if close() finished OK. This means that
there is a chance that close() already closed this FD and that another
thread already reused it, but we are still getting it from
apr_os_sock_get(). In such a case, we'd be shutting down the wrong FD.

Maybe the APR code should set the FD to -1 before close() and then
restore it back to original FD if close() was not successful in
apr_socket_close(). With that approach, this code would not attempt to
shut down that FD. Instead, there would be a good chance that close()
whacks it instead upon resume and things continue as normal.

-- 
Bojan


Mime
View raw message