note 84803 added to function.fgets
| From: | soapergem at gmail dot com | Date: | Wed, 30 Jul 2008 18:49:12 +0000 |
| Subject: | note 84803 added to function.fgets | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-142952@lists.php.net to get a copy of this message | ||
I ran into an issue that took me forever to finally figure out today, and I wanted to post my
findings here in case anyone else ever runs into the same thing. I had tried to open a connection
using fsockopen to my own server, send some data with fwrite, and then read the response with fgets.
The data I sent over included the session ID, which was to be loaded by the page receiving it. Keep
in mind that both the sender and receiver URLs were on my same server, and both tried to use the
same session ID.
I found that I could do the fwrite part just fine, but that fgets would lock up indefinitely,
ignoring any timeout I had set with fsockopen (but thankfully still obeying the max_execution_time
limit).
The problem was that while the sending page was trying to do the fgets, it still had the session
open. But the receiving page needed session data before it was willing to output anything, thereby
creating a deadlock.
The solution I found was to call session_write_close() just prior to sending the request in the
sender page, thereby granting access for the receiver to open up the session variables it needed.
----
Server IP: 208.69.120.35
Probable Submitter: 66.170.10.66
----
Manual Page -- http://www.php.net/manual/en/function.fgets.php
Edit -- https://master.php.net/note/edit/84803
Del: integrated -- https://master.php.net/note/delete/84803/integrated
Del: useless -- https://master.php.net/note/delete/84803/useless
Del: bad code -- https://master.php.net/note/delete/84803/bad+code
Del: spam -- https://master.php.net/note/delete/84803/spam
Del: non-english -- https://master.php.net/note/delete/84803/non-english
Del: in docs -- https://master.php.net/note/delete/84803/in+docs
Del: other reasons-- https://master.php.net/note/delete/84803
Reject -- https://master.php.net/note/reject/84803
Search -- https://master.php.net/manage/user-notes.php