php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43115 Resource ID Problem?
Submitted: 2007-10-27 12:47 UTC Modified: 2007-10-27 13:19 UTC
From: charpour at yahoo dot com Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.2.4 OS: Linux (Slackware 10.1)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
37 + 23 = ?
Subscribe to this entry?

 
 [2007-10-27 12:47 UTC] charpour at yahoo dot com
Description:
------------
When I'm opening several file descriptors (resource id's) with fopen or any other resource type, the resource id keeps increasing even when I close "previous" resource id's.

For example in a server/client example with stream sockets:

Client connects to the server...stream_socket_accept();
Client fd: Resource id #1
client quits.... fclose/socket_close
Client connects to the server...stream_socket_accept();
Client fd: Resource id #2
client quits.... fclose/socket_close
...
...
...
Client connects to the server...stream_socket_accept();
Client fd: Resource id #12456

Shouldn't the resource id reset to #1 when the second client
connected ?

Reproduce code:
---------------
<?php
set_time_limit(0);
ob_implicit_flush();

while (true) {
  testit();
}
function testit() {
        $fp = fopen('test','w');
        print("Res: ".$fp."\n");
        fclose($fp);
}
?>


Expected result:
----------------
Res: Resource id #1
Res: Resource id #1
Res: Resource id #1
....
....
Res: Resource id #1

Actual result:
--------------
Res: Resource id #1
Res: Resource id #2
Res: Resource id #3
....
....
Res: Resource id #20000

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-27 13:19 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

New connection -> new Resource
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Nov 15 12:01:34 2019 UTC