Changeset 1603 for trunk/server/common


Ignore:
Timestamp:
Aug 26, 2010, 4:28:41 PM (14 years ago)
Author:
gdb
Message:
Deep clone server_rec using ap_fixup_virtual_host

This patch is largely a refactoring.  However, we effectively are now
doing a deep clone, as opposed to the somewhat-deep clone we used to
have using memcpy.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/common/oursrc/httpdmods/mod_vhost_ldap.c

    r1589 r1603  
    436436static int mod_vhost_ldap_translate_name(request_rec *r)
    437437{
     438    server_rec *server;
     439    const char *error;
    438440    mod_vhost_ldap_request_t *reqc;
    439441    int failures = 0;
     
    442444    mod_vhost_ldap_config_t *conf =
    443445        (mod_vhost_ldap_config_t *)ap_get_module_config(r->server->module_config, &vhost_ldap_module);
    444     core_server_config *core =
    445         (core_server_config *)ap_get_module_config(r->server->module_config, &core_module);
     446    core_server_config *core;
    446447    util_ldap_connection_t *ldc = NULL;
    447448    int result = 0;
     
    455456    struct berval hostnamebv, shostnamebv;
    456457    int ret = DECLINED;
     458
     459    if ((error = ap_init_virtual_host(r->pool, "", r->server, &server)) != NULL) {
     460        ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
     461                      "[mod_vhost_ldap.c]: Could not initialize a new VirtualHost: %s",
     462                      error);
     463        return HTTP_INTERNAL_SERVER_ERROR;
     464    }
     465
     466    core = core_module.create_server_config(r->pool, server);
     467    ap_set_module_config(server->module_config, &core_module, core);
    457468
    458469    reqc =
     
    659670    }
    660671
    661     if ((r->server = apr_pmemdup(r->pool, r->server, sizeof(*r->server))) == NULL) {
    662         ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
    663                       "[mod_vhost_ldap.c] translate: "
    664                       "translate failed; Unable to copy r->server structure");
    665         return HTTP_INTERNAL_SERVER_ERROR;
    666     }
    667 
    668     r->server->server_hostname = reqc->name;
     672    server->server_hostname = reqc->name;
    669673
    670674    if (reqc->admin) {
    671         r->server->server_admin = reqc->admin;
    672     }
    673 
    674     if ((r->server->module_config = apr_pmemdup(r->pool, r->server->module_config,
    675                                                 sizeof(void *) *
    676                                                 (total_modules + DYNAMIC_MODULE_LIMIT))) == NULL) {
    677         ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
    678                       "[mod_vhost_ldap.c] translate: "
    679                       "translate failed; Unable to copy r->server->module_config structure");
    680         return HTTP_INTERNAL_SERVER_ERROR;
    681     }
    682 
    683     if ((core = apr_pmemdup(r->pool, core, sizeof(*core))) == NULL) {
    684         ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
    685                       "[mod_vhost_ldap.c] translate: "
    686                       "translate failed; Unable to copy r->core structure");
    687         return HTTP_INTERNAL_SERVER_ERROR;
    688     }
    689     ap_set_module_config(r->server->module_config, &core_module, core);
     675        server->server_admin = reqc->admin;
     676    }
    690677
    691678    /* Stolen from server/core.c */
     
    711698        core->ap_document_root = reqc->docroot;
    712699    }
     700
     701    ap_fixup_virtual_host(r->pool, r->server, server);
     702    r->server = server;
    713703
    714704    /* Hack to allow post-processing by other modules (mod_rewrite, mod_alias) */
Note: See TracChangeset for help on using the changeset viewer.