Changeset 10977

Show
Ignore:
Timestamp:
06/16/07 12:03:21 (2 years ago)
Author:
piotras
Message:

Free list from uri clear way. Set language and sitegroup for associated connection.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midgard/httpd/apache2/midgard-apache2.c

    r10949 r10977  
    537537                } 
    538538                 
     539                GHashTable *hash_cache = NULL; 
     540 
    539541                while(cnfnames[i] != NULL) { 
    540542                 
     
    555557                        GError *err = NULL; 
    556558 
    557                         if(mgd && scfg->config) 
     559                        if(mgd && scfg->config)  
    558560                                connected =  
    559                                         midgard_connection_struct_open_config(mgd, scfg->config, err); 
     561                                        midgard_connection_struct_open_config(mgd,  
     562                                                        scfg->config, &hash_cache, err); 
     563 
    560564 
    561565                        if(err != NULL); 
     
    584588                } 
    585589 
     590                if(hash_cache) g_hash_table_destroy(hash_cache); 
    586591                g_strfreev(cnfnames); 
    587592                 
     
    630635} 
    631636 
     637static void __list_string_free(GList *l) 
     638{ 
     639        if(l == NULL) 
     640                return; 
     641 
     642        for ( l ; l != NULL; l = l->next ) { 
     643                 
     644                if(l->data != NULL) 
     645                        g_free(l->data); 
     646 
     647                l->data = NULL; 
     648        } 
     649 
     650        g_list_free(l); 
     651        l = NULL; 
     652 
     653        return; 
     654} 
     655 
    632656/* ap_hook_translate_name */ 
    633657static int 
     
    636660        midgard_http_server_config *scfg; 
    637661        midgard_http_dir_config *dcfg; 
    638         MidgardRequest *rcfg; 
    639662        midgard_http_req_result result = MIDGARD_HTTP_FOUND_NONE; 
    640663        int auth_res; 
    641         /* request_rec *subreq; */ 
    642  
    643         /* we don't do subrequests */ 
     664 
     665        /* need to be freed */ 
     666        MidgardRequest *rcfg = NULL; 
     667        GList *r_pages = NULL; 
     668        GList *r_argv = NULL; 
     669        gchar *uri_prefix = NULL; 
     670        gchar *host_prefix = NULL; 
     671        GList *list = NULL; 
     672 
    644673        if (r->main != NULL) 
    645674                return DECLINED; 
     
    719748 
    720749        /* Find prefix, splits uri */ 
    721         gchar *uri_prefix = NULL; 
    722         GList *list = midgard_http_uri2list(r->uri);     
     750        list = midgard_http_uri2list(r->uri);    
    723751 
    724752        if(list) { 
     
    732760                        ap_get_server_name (r), ap_get_server_port (r), uri_prefix); 
    733761        if (!host) { 
    734                 /* FIXME, free list returned from midgard_http_uri2list and uri_prefix */ 
     762                __list_string_free(list); 
     763                g_free(uri_prefix); 
    735764                ap_log_rerror(APLOG_MARK, APLOG_WARNING | APLOG_NOERRNO, 0, r, 
    736765                                "Midgard: host record for %s:%d not found", 
    737766                                ap_get_server_name (r), ap_get_server_port (r)); 
    738                 return DECLINED; 
     767                 result = MIDGARD_HTTP_FOUND_NONE; 
     768                 goto MIDGARD_TH_FREE_DATA; 
    739769        } 
    740770 
    741771        /* TODO : host auth here ? */ 
    742  
    743         gchar *host_prefix; 
    744772        g_object_get(G_OBJECT(host), "prefix", &host_prefix, NULL); 
    745773 
    746774        if(host_prefix != NULL && g_str_equal(host_prefix, uri_prefix)){ 
    747775         
    748                 if(list) { 
    749  
    750                         g_free(list->data); 
    751                         list = g_list_remove_link(list, list);                   
    752                 } 
     776                if(list)  
     777                        list = g_list_remove(list, list->data); 
    753778 
    754779                ap_log_rerror(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r, 
    755                                 "mod_midgard: found prefixed host '%s:%d%s')", 
     780                                "mod_midgard: found host '%s:%d%s')", 
    756781                                ap_get_server_name (r), ap_get_server_port (r),  
    757                                 host_prefix);  
     782                                host_prefix == NULL ? "" : host_prefix);       
    758783        } 
    759784 
     
    797822  */ 
    798823 
    799         GList *r_styles = NULL; 
    800         GList *r_pages = NULL; 
    801         GList *r_argv = NULL; 
    802  
    803824        /* Create midgard_request object */ 
    804825        rcfg = midgard_request_new(); 
     
    814835                        NULL); 
    815836         
    816         /* TODO , enable when core supports name instead of guid 
    817          * midgard_connection_set_sitegroup(scfg->mgd, sg->guid); */ 
     837        const gchar *req_sg =  
     838                midgard_connection_get_sitegroup_from_id(scfg->mgd, sg_id); 
     839        midgard_connection_set_sitegroup(scfg->mgd, req_sg);  
    818840         
    819841        /* Set request's language */ 
     
    843865        g_value_unset(&pval); 
    844866 
     867        /* FIXME , we should handle this: free data and return */ 
    845868        if(!rootpage){ 
    846869                ap_log_rerror(APLOG_MARK, APLOG_CRIT | APLOG_NOERRNO, 0, r, 
    847870                                "mod_midgard: root page is not set for host %s:%d%s)", 
    848871                                ap_get_server_name (r), ap_get_server_port (r), uri_prefix); 
    849                 return DECLINED; 
     872                result = MIDGARD_HTTP_FOUND_NONE; 
     873                goto MIDGARD_TH_FREE_DATA; 
    850874        } 
    851875 
     
    961985                /* FIXME FIXME FIXME */ 
    962986                /* Add boolean property value check if DB supports it */ 
    963                 gchar *info_str
     987                gchar *info_str = NULL
    964988                g_object_get(G_OBJECT(rp->data), "info", &info_str, NULL); 
    965                 
    966                 if(g_str_equal(info_str, "auth")) {             
     989         
     990                if(info_str != NULL) { 
    967991                         
    968                         rcfg->auth_required = TRUE; 
     992                        if(g_str_equal(info_str, "auth"))  
     993                                rcfg->auth_required = TRUE; 
     994 
     995                        g_free(info_str); 
    969996                } 
    970                  
    971                 g_free(info_str); 
    972997        } 
    973998         
     
    10031028 
    10041029        /* Free all remaining url parts */ 
    1005         for(list; list != NULL; list = list->next) { 
    1006                 g_free(list->data); 
    1007         } 
    1008  
    1009         if(list)  
    1010                 g_list_free(list); 
     1030        __list_string_free(list); 
    10111031 
    10121032        /* Free pages list */ 
     
    10251045                case MIDGARD_HTTP_FOUND_NONE: 
    10261046 
    1027                         g_object_unref(rcfg); 
     1047                        if(rcfg != NULL) 
     1048                                g_object_unref(rcfg); 
    10281049                        rcfg = NULL; 
     1050 
    10291051                        g_object_unref(scfg->mgd); 
    10301052                        scfg->mgd = NULL; 
     
    10391061                        auth_res = _midgard_http_authenticate (r, scfg, rcfg); 
    10401062 
    1041                         g_object_unref(rcfg); 
     1063                        if(rcfg != NULL) 
     1064                                g_object_unref(rcfg); 
    10421065                        rcfg = NULL; 
     1066 
    10431067                        g_object_unref(scfg->mgd); 
    10441068                        scfg->mgd = NULL;