|
From: <php...@li...> - 2008-03-13 19:05:25
|
hi, since a few days i reported a bug to apache httpd. https://issues.apache.org/bugzilla/show_bug.cgi?id=43966 after a backtrace seems this issue to be php-java-bridge related. how to repeat: install apache >=2.2.6 (i tested with 2.2.8) install php 5.2.5 as module install php-java-bridge >=4.0.1 enable php, javabridge enable the apache server-status module start apache make a webserver stress wit ab ab -c 100 -n 20000 http://yourserver/some.jpg (some.jpg is any non php file) open the server-status in your browser and reload it often. after 4-5 seconds you will see many connections in "C" Closing connetion status... (see apache bugreport) The solution: Please look at the attached patch. i dont know what this line do, but if i remove it, everything works fine. no more sticking "C" processes.. please analyze this patch. thanks, Attila Soki |
|
From: <php...@li...> - 2008-03-13 19:10:42
|
hmm.. where is the attachment...
so the patch again:
diff -Nuar php-java-bridge-5.1.2-original/bind.c
php-java-bridge-5.1.2/bind.c
--- php-java-bridge-5.1.2-original/bind.c 2008-02-10
12:22:02.000000000 +0100
+++ php-java-bridge-5.1.2/bind.c 2008-03-13 17:43:05.000000000
+0100
@@ -1225,7 +1225,7 @@
kill(EXT_GLOBAL(cfg)->cid, sig[i]);
}
- if((read(EXT_GLOBAL(cfg)->err, &err, sizeof err))!=sizeof err) err=0;
+ //if((read(EXT_GLOBAL(cfg)->err, &err, sizeof err))!=sizeof err)
err=0;
//printf("VM terminated with code: %ld\n", err);
close(EXT_GLOBAL(cfg)->err);
EXT_GLOBAL(cfg)->err=0;
On Thu, 2008-03-13 at 20:06 +0100, php...@li... wrote:
> hi,
>
> since a few days i reported a bug to apache httpd.
> https://issues.apache.org/bugzilla/show_bug.cgi?id=43966
>
> after a backtrace seems this issue to be php-java-bridge related.
>
> how to repeat:
> install apache >=2.2.6 (i tested with 2.2.8)
> install php 5.2.5 as module
> install php-java-bridge >=4.0.1
> enable php, javabridge
> enable the apache server-status module
> start apache
>
> make a webserver stress wit ab
> ab -c 100 -n 20000 http://yourserver/some.jpg
> (some.jpg is any non php file)
>
> open the server-status in your browser and reload it often.
> after 4-5 seconds you will see many connections in
> "C" Closing connetion status... (see apache bugreport)
>
> The solution:
> Please look at the attached patch.
> i dont know what this line do, but if i remove it, everything works
> fine. no more sticking "C" processes..
>
> please analyze this patch.
>
>
> thanks,
>
> Attila Soki
|
|
From: <php...@li...> - 2008-03-14 17:11:56
|
Hi,
the patch is invalid, and I doubt that this is a PHP or PHP/Java Bridge issue.
Apache, when configured to use the prefork MPM, starts one Java process from the PHP MINIT() hook
and terminates it in the PHP MSHUTDOWN() hook.
The MINIT() hook must be called *before* any worker child is spawned. And the MSHUTDOWN() hook
must be called *after* all childs have been terminated.
Any stress test, which might kill childs at various levels, must not touch the Java child spawned
from the MINIT() hook.
This means that either:
a) you have found a bug in Apache
b) this is a misconfiguration: for example java.so loaded from the PHP dl() function
c) this is a misconfiguration: for example mod_php.so running in a non PREFORK MPM.
Regards,
Jost Boekemeier
Machen Sie Yahoo! zu Ihrer Startseite. Los geht's:
http://de.yahoo.com/set
|
|
From: <php...@li...> - 2008-03-15 11:21:40
|
On Fri, 2008-03-14 at 18:11 +0100,
php...@li... wrote:
> Hi,
>
> the patch is invalid, and I doubt that this is a PHP or PHP/Java Bridge issue.
>
> Apache, when configured to use the prefork MPM, starts one Java process from the PHP MINIT() hook
> and terminates it in the PHP MSHUTDOWN() hook.
>
> The MINIT() hook must be called *before* any worker child is spawned. And the MSHUTDOWN() hook
> must be called *after* all childs have been terminated.
>
> Any stress test, which might kill childs at various levels, must not touch the Java child spawned
> from the MINIT() hook.
>
> This means that either:
>
> a) you have found a bug in Apache
>
> b) this is a misconfiguration: for example java.so loaded from the PHP dl() function
>
> c) this is a misconfiguration: for example mod_php.so running in a non PREFORK MPM.
>
>
> Regards,
> Jost Boekemeier
hi,
ok, you are right whith the patch. this is probalbe bougous..
but look this code (bind.c)
static void wait_for_daemon(void) {
....removed...
for(i=0; i<2; i++) {
struct timeval timeval = {2l, 0};
if(select(1+EXT_GLOBAL(cfg)->err, &rfds, 0, 0, &timeval) > 0)
break;
kill(EXT_GLOBAL(cfg)->cid, sig[i]);
}
if((read(EXT_GLOBAL(cfg)->err, &err, sizeof err))!=sizeof err) err=0;
//printf("VM terminated with code: %ld\n", err);
close(EXT_GLOBAL(cfg)->err);
EXT_GLOBAL(cfg)->err=0;
#else
s_kill(0); /* always -9 on windows */
#endif
}
what if select returns an error? you exit from loop and go ahead to
read, and this blocks if there are nothing to read. or?
anyway, i will make some test with debugging enabled...
some info:
java.so is loaded from php.ini with extension=java.so
i have only prefork mpm compiled, the apache configuration is a default
config with the following changes:
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
Include conf/extra/httpd-info.conf is switched on with ExtendedStatus On
Attaching to program: `/usr/local/bin/httpd', process 58895.
Reading symbols for shared libraries +++++++++.................... done
0x00007fff82976384 in read ()
(gdb) whe
#0 0x00007fff82976384 in read ()
#1 0x00000001006e90d6 in java_shutdown_library ()
#2 0x00000001006de925 in zm_shutdown_java ()
#3 0x000000010128abfb in module_destructor ()
#4 0x0000000101292621 in zend_hash_apply_deleter ()
#5 0x0000000101292778 in zend_hash_graceful_reverse_destroy ()
#6 0x0000000101287397 in zend_shutdown ()
#7 0x0000000101241fdf in php_module_shutdown ()
#8 0x0000000101242089 in php_module_shutdown_wrapper ()
#9 0x000000010131e7f1 in php_apache_child_shutdown ()
#10 0x000000010022d299 in apr_pool_destroy ()
#11 0x0000000100057eb6 in clean_child_exit ()
#12 0x00000001000584d2 in child_main ()
#13 0x000000010005869a in make_child ()
#14 0x000000010005874b in startup_children ()
#15 0x0000000100059900 in ap_mpm_run ()
#16 0x0000000100007b68 in main ()
Server version: Apache/2.2.8 (Unix)
Server built: Mar 11 2008 16:13:40
Server's Module Magic Number: 20051115:11
Server loaded: APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture: 64-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_FLOCK_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/usr/local"
-D SUEXEC_BIN="/usr/local/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
Loaded Modules:
core_module (static)
authn_file_module (static)
authn_default_module (static)
authz_host_module (static)
authz_groupfile_module (static)
authz_user_module (static)
authz_default_module (static)
auth_basic_module (static)
include_module (static)
filter_module (static)
log_config_module (static)
env_module (static)
unique_id_module (static)
setenvif_module (static)
ssl_module (static)
mpm_prefork_module (static)
http_module (static)
mime_module (static)
status_module (static)
autoindex_module (static)
asis_module (static)
cgi_module (static)
negotiation_module (static)
dir_module (static)
actions_module (static)
userdir_module (static)
alias_module (static)
so_module (static)
info_module (shared)
php5_module (shared)
php 5.2.5 configuration:
'./configure' '--prefix=/usr/local'
'--with-apxs2=/usr/local/bin/apxs'
'--with-pgsql=/usr/local'
'--enable-ftp'
'--with-zlib'
'--enable-mbstring'
'--enable-sockets'
'--with-iconv'
Best regards,
Attila Soki
|
|
From: <php...@li...> - 2008-03-15 12:54:10
|
Hi,
I was able to reproduce this problem with Apache .2.8 (.2.6 doesn't have this problem).
Since Apache 2.2.8 the PHP MINIT() is called exactly once and the MSHUTDOWN() function is called
more than once, violating the PHP module contract.
In other words: PHP does not work anymore with Apache 2.2.8. Please use some other HTTP server or
some other SAPI, for example FastCGI.
I have the gut feeling that this is a long-time PHP bug; they've probably implemented the wrong
callback. PHP's MSHUTDOWN() shouldn't be called for each child, it should be called when the whole
HTTP server terminates.
A quick workaround is to store the PID in the MINIT() function (see java.c) and ignore any
MSHUTDOWN() where getpid() != pid. Something like this:
In java.c:
int pid;
MINIT()
{
pid = getpid();
...
}
MSHUTDOWN()
{
if (getpid() != pid) return SUCCESS; // work around for a Apache 2.2.8 or PHP bug.
...
}
Note that all PHP modules have the same problem, so I suggest to file a bug report to either the
PHP or the Apache team.
Regards,
Jost Boekemeier
E-Mails jetzt auf Ihrem Handy.
www.yahoo.de/go
|