Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_API.c

From: Date: Wed, 12 May 2004 15:02:42 +0000
Subject: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_API.c
References: 1 2 3  Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-2633@lists.php.net to get a copy of this message
Yeah, I think you should give this a try. But please revert before you do so, so that it's clear what you're changing and it'll be easier to review the patch. Thanks, Andi At 10:37 AM 5/2/2004 +0200, Marcus Boerger wrote:
Hello Andi, we could probably reduce the code amount by moving all code from zend_startup_module() to zend_startup_module_ex() with an additional MODULE_XXXXXX parameter or even better move the startup code into zend_reguster_module. The latter may even give the opportunity to do your early zend_hash_add trick. Should i give it a try? marcus Sunday, May 2, 2004, 1:02:15 AM, you wrote: Why is this bloat needed? In any case, isn't it possible to do this patch much nicer my performing the zend_hash_add() earlier and checking it's return value? Andi At 08:34 PM 5/1/2004 +0000, Marcus Boerger wrote:
helly           Sat May  1 16:34:07 2004 EDT
Modified files:
    /ZendEngine2        zend_API.c
Log: Don't load modules twice http://cvs.php.net/diff.php/ZendEngine2/zend_API.c?r1=1.249&r2=1.250&ty=u Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.249 ZendEngine2/zend_API.c:1.250
--- ZendEngine2/zend_API.c:1.249        Tue Mar 30 13:36:53 2004
+++ ZendEngine2/zend_API.c      Sat May  1 16:34:06 2004
@@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.c,v 1.249 2004/03/30 18:36:53 helly Exp $ */ +/* $Id: zend_API.c,v 1.250 2004/05/01 20:34:06 helly Exp $ */ #include "zend.h" #include "zend_execute.h" @@ -1161,10 +1161,20 @@ ZEND_API int zend_startup_module(zend_module_entry *module) {
        if (module) {
+               int name_len;
+               char *lcname;
+               TSRMLS_FETCH();
+
+               name_len = strlen(module->name);
+               lcname = zend_str_tolower_dup(module->name, name_len);
+               if (zend_hash_exists(&module_registry, lcname, 
name_len+1)) {
+ efree(lcname); + zend_error(E_CORE_WARNING, "Module '%s' already loaded", module->name);
+                       return FAILURE;
+               }
+               efree(lcname);
                module->module_number = zend_next_free_module();
                if (module->module_startup_func) {
-                       TSRMLS_FETCH();
-
                        EG(current_module) = module;
                        if
(module->module_startup_func(MODULE_PERSISTENT, module->module_number TSRMLS_CC)==FAILURE) {
                                zend_error(E_CORE_ERROR,"Unable to start
%s module", module->name); @@ -1360,17 +1370,26 @@
        int retval, name_len;
        char *lcname;
        TSRMLS_FETCH();
- + #if 0
        zend_printf("%s:  Registering module %d\n", module->name,
module->module_number); #endif
+       name_len = strlen(module->name);
+       lcname = zend_str_tolower_dup(module->name, name_len);
+
+       if (zend_hash_exists(&module_registry, lcname, name_len+1)) {
+               efree(lcname);
+               zend_error(E_CORE_WARNING, "Module '%s' already loaded",
module->name);
+               return FAILURE;
+       }
+
        if (module->functions && zend_register_functions(NULL,
module->functions, NULL, module->type TSRMLS_CC)==FAILURE) {
                zend_error(E_CORE_WARNING,"%s:  Unable to register
functions, unable to load", module->name);
+               efree(lcname);
                return FAILURE;
        }
        module->module_started=1;
-       name_len = strlen(module->name);
-       lcname = zend_str_tolower_dup(module->name, name_len);
+
        retval = zend_hash_add(&module_registry, lcname, name_len+1,
(void *)module, sizeof(zend_module_entry), NULL);
        efree(lcname);
        return retval;
-- Zend Engine CVS Mailing List (http://cvs.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- Best regards,
 Marcus                            mailto:helly@php.net
-- Zend Engine CVS Mailing List (http://cvs.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.zend-engine.cvs (#2633) next »