httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hassan Monfared <hmonfa...@gmail.com>
Subject Re: Writing a monitoring thread in apache filter moudle
Date Sun, 20 Apr 2014 11:47:13 GMT
Hi Nick,
Tanks for reply.
The array is a list of client IPs to be blocked.
I used apr threads and moved the thread creation  to ap_hook_child_init()
In this case the thread worked fine separately in each process.
Another question arises here.
Does the array which is initialized in the main process is copied into
child processes?

Thanks.


On Sun, Apr 20, 2014 at 2:43 PM, Nick Kew <niq@apache.org> wrote:

>
> On 20 Apr 2014, at 09:05, Hassan Monfared wrote:
>
> > Dear members,
> > I have global static array in my module
>
> What do you mean by a global static array?
>  it is a list of IP's
> In normal operation, apache runs multi-process.
> So what looks like global static is actually per-process.
> Think that through and it'll probably tell you what's wrong.
>
> > I wrote a monitoring thread with boost::thread which runs in background
> and
> > updates the list every 5 seconds.
>
> You'd probably be better off with apr threads: two separate
> threading models will add complexity and detract from
> portability and maintainability.
>
> Either run the update per-process or use shared memory.
> In the latter case, use apache's (and apr's) mechanisms
> for shared memory and timed monitoring to avoid introducing
> new complexity.
>
> --
> Nick Kew
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message