Re: PHP Extension Deinitializing on Startup
On 20/04/07, Joe Lewis [EMAIL PROTECTED] wrote: Michael B Allen wrote: Hi Saju, Actually I'm not sure this is my problem. I have tested my PHP extension on numerous platforms and I have only ever seen the PHP extension initialization / deinitialization routines run once for each restart. Is the load - unload - load behavior you describe something new that Apache just started doing? Apache has been doing that for eons. But apache does it to the apache extensions, while PHP would do it to the PHP extensions. I really expect that you should be working with the PHP lists rather than here from the original posting. (See http://www.php.net/mailing-lists.php for one that might fit your needs). Saju is absolutely correct - when a module is loaded by apache, a hook called post_config() is called twice (for checking the config file first that the syntax is okay, and then for the actual configuration), but I'm not sure if the .so is free()d from memory during that process. I always thought that it did not actually reload the .so (correct me if I am wrong). mod_so loads a module using apr_dso_load() . This call registers a pool cleanup callback that is called during config pool clearing to unload the dso. Without all modules getting unloaded in a restart cycle, you would not be able to get rid of a module across restarts by commenting out it's LoadModule. -srp Forcing an extension to deinitialize in PHP because of an issue in Apache would cause every extension in PHP to deinitialize, not just one of them. I expect the issue to be in the php extension itself (or php, but that is unlikely). Joe -- Joseph Lewis http://sharktooth.org/ Divide the fire, and you will sooner put it out. - Publius Syrus
RFE -- external overload procedure
hello please consider this posting as a request for enhancement httpd knows about his overload situation. [error] server reached MaxClients setting, consider raising the MaxClients setting this overload is easily created by an external attacker. in case of an attack you have to react. best done on a lower osi-layer (iptables, pf, ...). realtime log analysis has his own odds and twists. we would prefer a call to an 'external helper procedure'. the following patch is a quick and dirty implementation. --- httpd-2.2.4/server/mpm/worker/worker.c.orig 2007-04-12 12:58:28.0 +0200 +++ httpd-2.2.4/server/mpm/worker/worker.c 2007-04-12 15:44:04.0 +0200 @@ -135,6 +135,7 @@ static fd_queue_t *worker_queue; static fd_queue_info_t *worker_queue_info; static int mpm_state = AP_MPMQ_STARTING; static int sick_child_detected; +static int reported = 0; /* The structure used to pass unique initialization info to each thread */ typedef struct { @@ -1514,7 +1515,6 @@ static void perform_idle_server_maintena /* terminate the free list */ if (free_length == 0) { /* only report this condition once */ -static int reported = 0; if (!reported) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, @@ -1522,6 +1522,10 @@ static void perform_idle_server_maintena server reached MaxClients setting, consider raising the MaxClients setting); reported = 1; +if(!fork()) { + system(/usr/local/bin/apache_overload); + exit(0); +} } idle_spawn_rate = 1; } @@ -1550,6 +1554,7 @@ static void perform_idle_server_maintena } else if (idle_spawn_rate MAX_SPAWN_RATE) { idle_spawn_rate *= 2; +reported = 0; } } } in this context we have some questions: -- do you think it makes sense to implement this feature ? -- could it be done in a module (without the overhead of going through the scoreboard for each pre_connection call) ? -- can we expect this enhancement in a future release ? btw: we hope to see separately configurable timeouts ( http://httpd.apache.org/docs/2.2/mod/core.html#timeout ) very soon. kind regards juerg -- input validation is for people who can't do forensics! internet storm center at sans.org
Re: RFE -- external overload procedure
On 4/20/07, Juerg Umhang [EMAIL PROTECTED] wrote: hello please consider this posting as a request for enhancement httpd knows about his overload situation. [error] server reached MaxClients setting, consider raising the MaxClients setting this overload is easily created by an external attacker. in case of an attack you have to react. best done on a lower osi-layer (iptables, pf, ...). realtime log analysis has his own odds and twists. we would prefer a call to an 'external helper procedure'. in this context we have some questions: -- do you think it makes sense to implement this feature ? -- could it be done in a module (without the overhead of going through the scoreboard for each pre_connection call) ? It is reasonable to me for httpd to provide a module interface (hook) so that a third-party module can take action when httpd reaches the MaxClients (Unix) or ThreadsPerChild (Windows) condition. (Maybe the hook just provides some basic statistics, and the module can determine whether the absolute limit has been reached or its own configurable threshhold has been reached.) A way that a module can do something reasonable without modifying the server is to create a separate child process that monitors the scoreboard at its own interval, and takes whatever action is appropriate. That check can be infrequent enough that the performance overhead is negligible. -- can we expect this enhancement in a future release ? Some other committer can speak for themselves, but I wouldn't expect it without a patch submitted. btw: we hope to see separately configurable timeouts ( http://httpd.apache.org/docs/2.2/mod/core.html#timeout ) very soon. I don't recall anyone here interested in fulfilling the goal expressed in that comment.
Re: multiple c file problem with apxs.
Show us the compiler error. Maybe this is just a coding issue ? -srp On 19/04/07, Jason [EMAIL PROTECTED] wrote: Ok, Im getting a error with a module im trying to compile using apxs. What we have is two source files and a header. File number one compiles fine, but once we try to run a function in the second source file, it gives a error saying that it cant find the function. We have the function defined in the header and every thing seams to be right, we can compile fine if we comment out the function call. We used this line. apxs -c -i -a -n xpx mod_force.c mod_doc.c Thanks in Advance, Jason
Re: PHP Extension Deinitializing on Startup
The apache config cycle will load - unload - load your module on startup. Infact your module gets reloaded in for every restart -srp On 20/04/07, Michael B Allen [EMAIL PROTECTED] wrote: I'm trying to track down a strange problem. I have a PHP extension that is being deinitialized immediately after it starts up. After much research I'm starting to think that only Apache would ultimately trigger such an event. Is there any reason why Apache would unload the PHP module immediately after startup? Is there any way to enable some kind of debugging to see Apache loading and unloading modules so that I might determine why PHP is being unloaded? Thanks, Mike
Re: PHP Extension Deinitializing on Startup
Hi Saju, Actually I'm not sure this is my problem. I have tested my PHP extension on numerous platforms and I have only ever seen the PHP extension initialization / deinitialization routines run once for each restart. Is the load - unload - load behavior you describe something new that Apache just started doing? If not, I think I might have a different problem. Mike On Fri, 20 Apr 2007 17:57:22 +0530 Saju Pillai [EMAIL PROTECTED] wrote: The apache config cycle will load - unload - load your module on startup. Infact your module gets reloaded in for every restart -srp On 20/04/07, Michael B Allen [EMAIL PROTECTED] wrote: I'm trying to track down a strange problem. I have a PHP extension that is being deinitialized immediately after it starts up. After much research I'm starting to think that only Apache would ultimately trigger such an event. Is there any reason why Apache would unload the PHP module immediately after startup? Is there any way to enable some kind of debugging to see Apache loading and unloading modules so that I might determine why PHP is being unloaded? Thanks, Mike
Re: PHP Extension Deinitializing on Startup
Michael B Allen wrote: Hi Saju, Actually I'm not sure this is my problem. I have tested my PHP extension on numerous platforms and I have only ever seen the PHP extension initialization / deinitialization routines run once for each restart. Is the load - unload - load behavior you describe something new that Apache just started doing? Apache has been doing that for eons. But apache does it to the apache extensions, while PHP would do it to the PHP extensions. I really expect that you should be working with the PHP lists rather than here from the original posting. (See http://www.php.net/mailing-lists.php for one that might fit your needs). Saju is absolutely correct - when a module is loaded by apache, a hook called post_config() is called twice (for checking the config file first that the syntax is okay, and then for the actual configuration), but I'm not sure if the .so is free()d from memory during that process. I always thought that it did not actually reload the .so (correct me if I am wrong). Forcing an extension to deinitialize in PHP because of an issue in Apache would cause every extension in PHP to deinitialize, not just one of them. I expect the issue to be in the php extension itself (or php, but that is unlikely). Joe -- Joseph Lewis http://sharktooth.org/ Divide the fire, and you will sooner put it out. - Publius Syrus
Re: Store data accessible by all process and threads.
This question seems more suitable for the modules list. Read Only data ? You may consider setting it up in post_config - alloc from config pool. Your data will get copied into all children. Read-Write data ? shm is ok. Any standard IPC should work. -srp On 20/04/07, moh bad [EMAIL PROTECTED] wrote: Hi, within a module, what is the best way to store data, who need to be accessible to all threads and process ? 1/ using shared memory, with apr_shm_* 2/ using the pool where is stored the module configuration. the one given when the create per-server config structure function is called. 3/ other ... thank you.