php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43026 persistent sockets do not stay persistent
Submitted: 2007-10-18 23:20 UTC Modified: 2007-10-19 08:28 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: domino at operamail dot com Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.2.4 OS: Linux / Fedora 7
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: domino at operamail dot com
New email:
PHP Version: OS:

 

 [2007-10-18 23:20 UTC] domino at operamail dot com
Description:
------------
Socket handle as returned by pfsockopen is not preserved within the same session.

First page will open a persistent socket and store it in the SESSION array. (Yes, i have a component running on 20505).

Then, first page redirect to second page, which retrieves the stored object.

The string is retrieved OK from resumed SESSION, but socket is dead.

PS. As a test, I have reconfigured Apache to run in single thread mode. The code sample still doesnt work as expected.

Reproduce code:
---------------
socket.php:

Code:

<?php
session_start();


$_SESSION['langleySockets'] = array();
$_SESSION['langleySockets'][0] = array( 'hi' => 'bye', 'socket' => fsockopen("127.0.0.1", 20505));

$fh=fopen("/tmp/socket.xxx", "w");fwrite($fh, print_r($_SESSION['langleySockets'][0], true));fclose($fh);

session_write_close();

header("Location: socket2.php" . "?" . SID);

?>



socket2.php:
Code:

<?php

session_start();
$fh=fopen("/tmp/socket.xxx", "a");fwrite($fh, print_r($_SESSION['langleySockets'][0], true));fclose($fh);
session_write_close();

?>


Expected result:
----------------
[root@xyz db]# cat /tmp/socket.xxx
Array
(
    [hi] => bye
    [socket] => Resource id #15
)
Array
(
    [hi] => bye
    [socket] => Resource id #15
)

Actual result:
--------------
[root@xyz db]# cat /tmp/socket.xxx
Array
(
    [hi] => bye
    [socket] => Resource id #15
)
Array
(
    [hi] => bye
    [socket] => 0
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-19 08:28 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Resources can't be stored in a session, not even persistent ones. Instead the persistent connection will be reused when you reopen a connection with the same parameters. Please also see http://php.net/manual/en/features.persistent-connections.php
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Oct 14 06:01:26 2019 UTC