Bug #67596 [NEW]: mysqli connection in CLOSE_WAIT state if process is forked
| From: | christian dot p at maps-system dot com | Date: | Wed, 09 Jul 2014 14:17:20 +0000 |
| Subject: | Bug #67596 [NEW]: mysqli connection in CLOSE_WAIT state if process is forked | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186546@lists.php.net to get a copy of this message | ||
From: christian dot p at maps-system dot com
Operating system: Linux
PHP version: 5.5.14
Package: MySQLi related
Bug Type: Bug
Bug description:mysqli connection in CLOSE_WAIT state if process is forked
Description:
------------
When forking php process with exec, if a mysqli connection is already
established, the child process will retain this connection in a
CLOSE_WAIT state, even if the parent destroys it afterwards.
It will retains one more CLOSE_WAIT connection per fork, leading to a
"Unable to fork" error, when the maximum nproc in ulimit is reached.
The linked script reproduces the problem.
It's possible to avoid the problem by calling $this->disconnect();
before forking.
I can understand that the child shares resources with its parent, but is
it normal that the parent cannot close the connection properly after the
fork ?
Test script:
---------------
http://pastebin.com/5RmQutkk
Expected result:
----------------
Parent process should be able to close the mysqli connection.
Actual result:
--------------
Parent process close the mysqli connection without error, but a
connection in CLOSE_WAIT state is still present (lsof shows it).
--
Edit bug report at https://bugs.php.net/bug.php?id=67596&edit=1
--