Bug #70813 [NEW]: connection_status(), connection_aborted() not working

From: Date: Thu, 29 Oct 2015 14:59:57 +0000
Subject: Bug #70813 [NEW]: connection_status(), connection_aborted() not working
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196875@lists.php.net to get a copy of this message
From:             sivann at gmail dot com
Operating system: Fedora 22
PHP version:      5.6.14
Package:          Network related
Bug Type:         Bug
Bug description:connection_status(), connection_aborted() not working

Description:
------------
connection_status(), connection_aborted () never detect closed remote
connection.

After closing connection initiated from client (e.g. wget) connection
state becomes CLOSE_WAIT from ESTABLISHED, but those two functions
called in a loop never detect that, even when outputing data.

Current solution is to popen netstat, or parse /proc/net/tcp,
/proc/net/tcp6 to find if connection is established.

connection_status/connection_aborted should detect the connection loss
even without writing anything. Currently those functions do nothing.

Test script:
---------------
<?php
ignore_user_abort(false);
function fecho($str) {
    file_put_contents("conlog.txt",$str."",FILE_APPEND);
}
while (1) {
    sleep (1);
    $d=date(DATE_RFC2822);
    $remport=$_SERVER['REMOTE_PORT'];
    $remip =
$_SERVER['REMOTE_ADDR']?:($_SERVER['HTTP_X_FORWARDED_FOR']?:$_SERVER['HTTP_CLIENT_IP']);
   
file_put_contents("conlog.txt","date:$d\tip:$remip\tport:$remport\tstatus:$constatus\n",FILE_APPEND);
    echo "...\n"; 
    flush();
    if (connection_status()!= CONNECTION_NORMAL){ //never works
        file_put_contents("conlog.txt","connection
closed\n",FILE_APPEND);
        break;
    }
   
file_put_contents("conlog.txt","connection_status=".connection_status().
        "
connection_aborted():".connection_aborted()."\n",FILE_APPEND);
}
?>


Expected result:
----------------
The above writes on a file named conlog.txt. Call the above script with
wget. The script should start writing data to conlog.txt at the server.
Then press Ctrl+C to stop wget. The script should end. 



Actual result:
--------------
The script never stops running.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=70813&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=70813&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=70813&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=70813&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=70813&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=70813&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=70813&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=70813&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=70813&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=70813&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=70813&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=70813&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=70813&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=70813&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70813&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=70813&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=70813&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=70813&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70813&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=70813&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=70813&r=mysqlcfg



Thread (14 messages)

« previous php.bugs (#196875) next »