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
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: 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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Mon May 13 22:01:31 2024 UTC