Req #78555 [NEW]: Disable dblink cleanup

From: Date: Tue, 17 Sep 2019 17:20:29 +0000
Subject: Req #78555 [NEW]: Disable dblink cleanup
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222790@lists.php.net to get a copy of this message
From:             erik at coretech dot se
Operating system: 
PHP version:      7.3.9
Package:          MySQLi related
Bug Type:         Feature/Change Request
Bug description:Disable dblink cleanup

Description:
------------
When building daemon processes with php that requires the parent process
to create a persistent database connection. The cleanup of the child
process closes the parents database connection. A way to disable this
cleanup on a object basis would make php better for daemon projects.
This problem applies to other file descriptors aswell but the most
problematic is the mysqli dblink resource.

Test script:
---------------
<?php

function query_db($dbo) {

        if(!mysqli_real_query($dbo, "SELECT 1"))
                die("Unable to query database: " . mysqli_error($dbo) .
" (" . mysqli_errno($dbo) . ")\n");

        if(($res = mysqli_store_result($dbo)) === FALSE)
                die("Unable to store result: " . mysqli_error($dbo) . "
(" . mysqli_errno($dbo) . ")\n");

        echo "Successful query\n";
}

$dbo = mysqli_init();
if (!mysqli_real_connect($dbo, 'dbserver', 'dbuser', 'dbpwd')) {
        die("Unable to connect to the database\n");
}

query_db($dbo);

$pid = pcntl_fork();
if ($pid == -1) {
        die("Could not fork\n");
} else if($pid) {
        // Parent
        pcntl_wait($status);
        query_db($dbo);
} else {
        // Child
        // mysqli_disable_cleanup($dbo, TRUE);
        exit(0);
}



Expected result:
----------------
Successful query
Successful query

Actual result:
--------------
Successful query
PHP Warning:  mysqli_real_query(): MySQL server has gone away in
/tmp/test.php on line 5
PHP Warning:  mysqli_real_query(): Error reading result set's header in
/tmp/test.php on line 5
Unable to query database: MySQL server has gone away (2006)


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


Thread (3 messages)

« previous php.bugs (#222790) next »