php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4581 connection_status not updated in cgi
Submitted: 2000-05-24 19:50 UTC Modified: 2000-05-30 19:24 UTC
From: daniel dot braun at ercom dot fr Assigned:
Status: Closed Package: Other
PHP Version: 4.0 Release Candidate 1 OS: Solaris 2.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: daniel dot braun at ercom dot fr
New email:
PHP Version: OS:

 

 [2000-05-24 19:50 UTC] daniel dot braun at ercom dot fr
In file sapi/apache/mod_php4.c, function sapi_apache_ub_write() check return code of fwrite,
and set connection_status accordingly
But in sapi/cgi/cgi_main.c, the equivalent function
sapi_cgibin_ub_write() does not check the return
code. Indeed, in the cgi version I dont
see where connection_status is set to PHP_CONNECTION_ABORTED.
As a result, I have a script that never end, although
IgnoreUserAbort is set to Off, and connection_status()
still returns 0 though client is dead.

Changing in cgi_main.c .._ub_write() to :

static int sapi_cgibin_ub_write(const char *str, uint str_length)
{
        int ret;
        ret=fwrite(str, 1, str_length, stdout);
        if (ret != str_length) {
                PG(connection_status) = PHP_CONNECTION_ABORTED;
                if (!PG(ignore_user_abort)) {
                        zend_bailout();
                }
        }
        return ret;
}

does not solve my problem, because error (and ignored SIGPIPE) occurs in fflush(), not in fwrite()
so I had to change sapi_cgibin_flush() too.

static void sapi_cgibin_flush(void *server_context)
{
        if (fflush(stdout) <0) {
                PG(connection_status) = PHP_CONNECTION_ABORTED;
                if (!PG(ignore_user_abort)) {
                        zend_bailout();
                }
        }
}

hope this helps


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-05-30 19:24 UTC] rasmus at cvs dot php dot net
Thies fixed this one
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 11:01:34 2025 UTC