My reply seems to be lost in the ether ... try again. Begin forwarded message:
> On 16 Apr 2010, at 20:51, Some Guy wrote: > >> Hi all, >> >> I would like to develop a module that periodically needs to fetch a file >> from a remote site and update some data used by the child processes. Is it >> safe to create this thread in the post config hook? I would like to do >> something like: >> >> Global thread fetches a file, and loads content >> Thread signals that it has new data >> A separate thread in each of the child processes gets the signal and updates >> the cache in the child process. The cache is only updated by this thread >> and owned by the child process, so I lock it with a rwlock. The cache is >> read by request handlers, so I don't want to use a global lock since the >> documentation implied it could be a performance issue. >> >> Is this doable and which hooks / threading issues will I run into with this >> approach? It would be nice for the threads in the child process to be able >> to concurrently read the data from the global thread after the global thread >> has signaled new data is ready. I did not see any type of global rw lock. > > It's doable, with some reservations (and re your last sentence, > see apr_global_mutex). The hardest part will be to avoid leaking > memory in the fetch. > > However, it might be over-complicated. Instead of your own thread > in the parent process, why not use ap_hook_monitor? And the mtime > of the fetched file should work nicely as the signal to the children. > > -- > Nick Kew