Req #78555 [PATCH]: Disable dblink cleanup
Edit report at https://bugs.php.net/bug.php?id=78555&edit=1
ID: 78555
Patch added by: erik@coretech.se
Reported by: erik at coretech dot se
Summary: Disable dblink cleanup
Status: Open
Type: Feature/Change Request
Package: MySQLi related
PHP Version: 7.3.9
Block user comment: N
Private report: N
New Comment:
The following patch has been added/updated:
Patch Name: mysqli_dbo_cleanup
Revision: 1568741061
URL: https://bugs.php.net/patch-display.php?bug=78555&patch=mysqli_dbo_cleanup&revision=1568741061
Previous Comments:
------------------------------------------------------------------------
[2019-09-17 17:20:28] erik at coretech dot se
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 this bug report at https://bugs.php.net/bug.php?id=78555&edit=1
Thread (3 messages)