Changeset 16192

Show
Ignore:
Timestamp:
04/23/08 12:58:24 (6 months ago)
Author:
piotras
Message:

unref connection objects if needed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midgard/apis/php5/midgard.c

    r16186 r16192  
    380380} 
    381381 
     382static void __free_connections(gpointer key, gpointer val, gpointer ud) 
     383{ 
     384        MidgardConnection *cnc = MIDGARD_CONNECTION(val); 
     385        g_object_unref(cnc); 
     386} 
     387 
    382388PHP_MSHUTDOWN_FUNCTION(midgard2) 
    383389{ 
    384         /* Remove comments if you have entries in php.ini 
    385          * UNREGISTER_INI_ENTRIES(); 
    386          * */ 
     390         
     391        UNREGISTER_INI_ENTRIES(); 
    387392 
    388393        /* Free schema */ 
     
    390395                g_object_unref(midgard_global_schema); 
    391396 
    392         /* Free connection */ 
    393         MidgardConnection *mgd = mgd_handle(); 
    394         if(mgd != NULL)  
    395                 g_warning("midgard_close() not yet implemented"); 
     397        /* Free connections */ 
     398        if(all_configs != NULL) { 
     399                 
     400                g_hash_table_foreach(all_configs, __free_connections, NULL); 
     401                 
     402        } else { 
     403                 
     404                MidgardConnection *mgd = mgd_handle(); 
     405                if(mgd != NULL)  
     406                        g_object_unref(mgd); 
     407        } 
    396408 
    397409        return SUCCESS; 
     
    471483                MidgardConnection *cnc =  
    472484                        (MidgardConnection *) g_hash_table_lookup(all_configs, config); 
    473  
     485         
    474486                /* Try to connect */ 
    475487                if(cnc == NULL) { 
     
    480492 
    481493                g_debug("Found connection handler for '%s'", config); 
    482                 MGDG(mgd) = cnc; 
     494                MGDG(mgd) = midgard_connection_copy(cnc); 
     495                inherited_cnc = cnc; 
    483496        } 
    484497 
     
    528541        if(mgd != NULL){  
    529542 
    530                 /* TODO  
    531                  * unref MidgardConnection object 
    532                  * make sure person and request is also unref'ed */ 
    533543         
    534544                /* FIXME , replace with MidgardConnection API */ 
     
    552562                                midgard_connection_get_loghandler(inherited_cnc)); 
    553563 
    554                 //g_object_unref(inherited_cnc); 
     564                g_object_unref(inherited_cnc); 
    555565                inherited_cnc = NULL; 
    556566        }