Hi, Shared memory is the only way between processes to share some data.
Sent from my iPhone > On 2014 bal. 20, at 14:47, Hassan Monfared <[email protected]> wrote: > > 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 <[email protected]> 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 >>
