Is there any way of getting the resource id without modifying sockets?

ZEND_API int zend_fetch_list_dtor_id(char *type_name);


As an implementation:

In *your* socketi.c:

static int le_socket = -1;

PHP_RINIT(socketi)
{
   if (le_socket == -1) {
       le_socket = zend_fetch_list_dtor_id("Socket");
   }

   return (le_socket == -1) ? FAILURE : SUCCESS;
}



By doing it in RINIT you avoid the potential problem of having socketi loaded before socket (which could happen if they're both shared). Once the first request has retreived it, later requests won't have to try because it'll be persistently known from then on.

The one pitfall to this method is that *IF* another ext defines a resource named "Socket" (case-sensitive), you could pick up the wrong lde ID. Fairly left-field chance, but technically not impossible.

-Sara
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to