php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8140 persistent sockets do not work
Submitted: 2000-12-06 13:09 UTC Modified: 2005-03-31 16:13 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: jacek dot margos at freenet-ag dot de Assigned:
Status: Wont fix Package: Misbehaving function
PHP Version: 3.0.16 OS: SuSE Linux 2.2.16
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jacek dot margos at freenet-ag dot de
New email:
PHP Version: OS:

 

 [2000-12-06 13:09 UTC] jacek dot margos at freenet-ag dot de
Persistent socket connections cannot be re-used.

The first invocation of pfsockopen() works fine. But if I click on Reload button
(several times if more than one Apache process is running), the socket returned
by the function (got from a hash) cannot be used.

PHP 3.0.16 just dies without writing anything to the output (Netscape: "The
document contained no data",  telnet localhost 80: "Connection closed by foreign
host" - without any output).

Apache log:
...
[Wed Dec  6 09:20:11 2000] [notice] Apache/1.3.12 (Unix)  (SuSE/Linux) mod_fastcgi/2.2.2 balanced_by_mod_backhand/1.0.8 DAV/1.0.0 mod_perl/1.24 PHP/3.0.16 configured -- resuming normal operations
...
[Wed Dec  6 09:57:47 2000] [notice] child pid 24437 exit signal Segmentation fault (11)
...

Note: PHP 4.0.0 reports EOF on socket (function feof( $socket ) returns TRUE).
But "Segmentation faults" are being reported in the log file of Apache, too.
Note: there are several bug reports for similar problems: #6914, #7420, #7723.
 
#simple test script (/usr/local/httpd/htdocs/jacek/pfsockopen.php3):
<HTML>
<HEAD> <TITLE> test: pfsockopen </TITLE> </HEAD>
<BODY>
<?
// port = 7 is echo, works fine if using fsockopen() - not persistent
$socket = pfsockopen( "localhost", 7, $errno, $errstr, 10 );
if( ! $socket ) {
	printf( "cannot connect: %d, %s\n<BR>\n", $errno, $errstr );
} else {
	printf( "socket: %s\n<BR>\n", $socket );
	if( feof( $socket ) ) {
		printf( "EOF on socket\n<BR>\n" );
		exit;
	}
	printf( "<TABLE BORDER=1>\n<TR>\n" );
	printf( "\t<TD>Written</TD>\n\t<TD>Received</TD>\n</TR>\n" );
	for( $i = 0; $i < 10; $i ++ ) {
		$send = "i = $i\n";
		fputs( $socket, $send );
		printf( "<TR>\n\t<TD ALIGN=center>%s</TD>\n", chop( $send ) );
		$rcvd = fgets( $socket, 80 );
		printf( "\t<TD ALIGN=center>%s</TD>\n</TR>\n", chop( $rcvd ) );
	}
	printf( "</TABLE>\n" );
}
?>
</BODY>
</HTML>

Configure command (standard SuSE 7.0): ./configure
	'--with-adabas=/usr/lib/adabas'
	'--with-pgsql=/usr' '--with-mysql=yes'
	'--enable-safe-mode'
	'--enable-sysvsem'
	'--enable-sysvshm'
	'--enable-track-vars'
	'--enable-magic-quotes'
	'--enable-memory-limit'
	'--enable-debugger'
	'--enable-bcmath'
	'--with-zlib=yes'
	'--with-ttf'
	'--with-imap=yes'
	'--with-ldap=yes'
	'--with-pdflib'
	'--with-xml'
	'--with-gd=yes'
	'--with-yp'
	'--with-jpeg-dir'
	'--with-tiff-dir'
	'--with-config-file-path=/etc/httpd'
	'--with-apxs=/usr/sbin/apxs -ltiff -lnsl -lpdf -lpng'
	'--with-exec-dir=/usr/lib/apache/bin'
	'--with-apache=/usr/src/packages/BUILD/php-3.0.16/..'
	'i386-suse-linux-gnu'

php3.ini file path is set to: /etc/httpd

Apache version (standard SuSE 7.0):
Server version: Apache/1.3.12 (Unix)  (SuSE/Linux)
Server built:   Jul 30 2000 22:47:29
PHP used as module.

output from strace -p <PID of an Apache process>:
read(5, "GET /jacek/pfsockopen.php3\r\n", 4096) = 28
rt_sigaction(SIGUSR1, {SIG_IGN}, {SIG_IGN}, 8) = 0
time(NULL)                              = 976096455
stat("/usr/local/httpd/htdocs/jacek/pfsockopen.php3", {st_mode=S_IFREG|0644,
st_size=748, ...}) = 0
lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/local/httpd", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/local/httpd/htdocs", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/local/httpd/htdocs/jacek", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/local/httpd/htdocs/jacek/pfsockopen.php3", {st_mode=S_IFREG|0644, st_size=748, ...}) = 0
gettimeofday({976096455, 747885}, NULL) = 0
stat("/usr/local/httpd/htdocs/jacek/pfsockopen.php3", {st_mode=S_IFREG|0644, st_size=748, ...}) = 0
lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/local/httpd", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/local/httpd/htdocs", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/local/httpd/htdocs/jacek", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/local/httpd/htdocs/jacek/pfsockopen.php3", {st_mode=S_IFREG|0644, st_size=748, ...}) = 0
open("/usr/local/httpd/htdocs/jacek/pfsockopen.php3", O_RDONLY) = 7
fcntl(7, F_DUPFD, 15)                   = 19
close(7)                                = 0
umask(077)                              = 022
umask(022)                              = 077
chdir("/usr/local/httpd/htdocs/jacek")  = 0
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={10, 0}}, NULL) = 0
rt_sigaction(SIGPROF, {0x402ebcb0, [], SA_INTERRUPT|0x4000000}, {0x402ebcb0, [], SA_INTERRUPT|0x4000000}, 8) = 0
old_mmap(NULL, 200704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40887000
fcntl(19, F_GETFL)                      = 0 (flags O_RDONLY)
fstat64(19, {st_mode=S_IFREG|0644, st_size=748, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40015000
_llseek(19, 0, [0], SEEK_CUR)           = 0
ioctl(19, TCGETS, 0xbffff898)           = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(19, TCGETS, 0xbffff818)           = -1 ENOTTY (Inappropriate ioctl for device)
read(19, "<HTML>\n<HEAD> <TITLE> test: pfso"..., 8192) = 748
read(19, "", 4096)                      = 0
send(2433068, "i = 0\n", 6, 0)          = -1 EBADF (Bad file descriptor)
--- SIGSEGV (Segmentation fault) ---
chdir("/usr/local/httpd")               = 0
rt_sigaction(SIGSEGV, {SIG_DFL}, {SIG_DFL}, 8) = 0
getpid()                                = 8944
kill(8944, SIGSEGV)                     = 0
sigreturn()                             = ? (mask now [])
--- SIGSEGV (Segmentation fault) ---

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-31 16:13 UTC] php-bugs at lists dot php dot net
We are sorry, but we do not support PHP 3 related problems anymore.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 16:01:28 2024 UTC