Re: Zend resources

From: Date: Mon, 12 Sep 2005 04:01:50 +0000
Subject: Re: Zend resources
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-18788@lists.php.net to get a copy of this message
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

« previous php.internals (#18788) next »