httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ohad Lutzky" <o...@lutzky.net>
Subject [flood] Critical section for flood_report_relative_times.c
Date Wed, 03 Sep 2008 09:28:35 GMT
>From flood_report_relative_times.c (SVN):

    /* FIXME: this call may need to be in a critical section */
#if APR_HAS_THREADS
    apr_file_printf(local_stdout, "%s %ld %s\n", buf,
apr_os_thread_current(), req->uri);
#else
    apr_file_printf(local_stdout, "%s %d %s\n", buf, getpid(), req->uri);
#endif

The comment is right - it does need to be in a critical section. For
the case of multiple processes, flock can be used. However, for the
case of a single process, this doesn't work, and a mutex would be in
order. What would be the correct way to go about organizing such a
per-process mutex? Note that apr_file_printf indirectly calls
apr_file_write, which is thread-safe - however, it call it multiple
times, which can (and does) lead to interlacing in output.

-- 
Man is the only animal that laughs and weeps, for he is the only
animal that is struck with the difference between what things are and
what they ought to be.
 - William Hazlitt

Ohad Lutzky

Mime
View raw message