Re: Question about socket ext. file descriptors
| From: | Andi Gutmans | Date: | Thu, 29 Mar 2001 13:52:16 +0000 |
| Subject: | Re: Question about socket ext. file descriptors | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-50222@lists.php.net to get a copy of this message | ||
At 03:47 PM 3/29/2001 +0200, Zeev Suraski wrote:
At 15:41 29/3/2001, Andi Gutmans wrote:Well we were talking about the ext/socket extension and all functions there which create file descriptors are leaking. It's not an exception. Check open_listen_sock() and accept_connect(). You were probably looking at the fd set functions which are just emalloc()'ed memory. The happen to use resources but even if they hadn't it would be a leak which the Zend memory manager would clean up. The file descriptors is the real problem. AndiAt 03:35 PM 3/29/2001 +0200, Zeev Suraski wrote:So this function may be an exception to the rule. But generally, all of the file/socket functions use ZEND_REGISTER_RESOURCE() or zend_list_insert(), so they're fine.Note that the situation isn't as bad as you thought - it's not that it's not using the resource mechanism. It is, if it wasn't, we'd be getting loads of complaints from people running out of descriptors very quickly. It just uses old, PHP 3 style resources, of type IS_LONG. They're still destroyed when the request ends, so it's all safe and all. It simply doesn't use the PHP 4 style, of type IS_RESOURCE, which are actually destroyed when they're no longer needed. It's a good idea to update this code, but it's not very dangerous the way it is now.I think you are wrong. Look at the function accept_connect(). You are creating a new file descriptor and not saving it anywhere!