The attached patch fixes up some clashes when mod_mono is used with vhosts. The XXGLOBAL server socket file must be prefixed with the vhost name because it is created per-vhost. The patch prefixes every alias in a socket file name with the vhost name. (As a matter of code cleanliness, it also now uses a more ugly socket file name that includes the string XXGLOBAL..)
Let me know if it's ok. -- - Joshua Tauberer http://razor.occams.info "Strike up the klezmer and start acting like a man. You're about to have a truth-mitzvah." -- The Colbert Report
Index: src/mod_mono.c =================================================================== --- src/mod_mono.c (revision 65551) +++ src/mod_mono.c (working copy) @@ -53,6 +53,7 @@ typedef struct xsp_data { char is_default; + char *vhost; char *alias; char *filename; char *run_xsp; @@ -72,7 +73,6 @@ char *env_vars; char status; /* One of the FORK_* in the enum above. * Don't care if run_xsp is "false" */ - char is_virtual; /* is the server virtual? */ } xsp_data; typedef struct { @@ -87,16 +87,35 @@ char *client_block_buffer; } request_data; +static char * get_default_socket_name (apr_pool_t *pool, xsp_data *xsp, const char *base); + + /* */ static int -search_for_alias (const char *alias, module_cfg *config) +search_for_alias (const char *alias, module_cfg *config, server_rec *server) { /* 'alias' may be NULL to search for the default XSP */ int i; xsp_data *xsp; + DEBUG_PRINT (2, "searching for alias '%s' in server '%s'", + alias == NULL ? "<default alias>" : alias, + !server->is_virtual || server->server_hostname == NULL ? "<main server>" : server->server_hostname); + for (i = 0; i < config->nservers; i++) { xsp = &config->servers [i]; + + DEBUG_PRINT (2, " found alias '%s' in server '%s'", + xsp->alias == NULL ? "<default alias>" : xsp->alias, + xsp->vhost == NULL ? "<main server>" : xsp->vhost); + + if (!server->is_virtual || server->server_hostname == NULL) { + if (xsp->vhost != NULL) continue; + } else { + if (xsp->vhost == NULL) continue; + if (strcmp(server->server_hostname, xsp->vhost)) continue; + } + if ((alias == NULL || !strcmp (alias, "default")) && xsp->is_default) return i; @@ -115,7 +134,7 @@ sconfig = ap_get_module_config (cmd->server->module_config, &mono_module); config->alias = (char *) alias; - if (search_for_alias (alias, sconfig) == -1) { + if (search_for_alias (alias, sconfig, cmd->server) == -1) { char *err = apr_pstrcat (cmd->pool, "Server alias '", alias, ", not found.", NULL); return err; } @@ -149,19 +168,23 @@ } static int -add_xsp_server (apr_pool_t *pool, const char *alias, module_cfg *config, int is_default, int is_virtual) +add_xsp_server (apr_pool_t *pool, const char *alias, module_cfg *config, int is_default, server_rec *servercfg) { xsp_data *server; xsp_data *servers; int nservers; int i; - i = search_for_alias (alias, config); + i = search_for_alias (alias, config, servercfg); if (i >= 0) return i; server = apr_pcalloc (pool, sizeof (xsp_data)); server->is_default = is_default; + if (!servercfg->is_virtual || servercfg->server_hostname == NULL) + server->vhost = NULL; + else + server->vhost = apr_pstrdup(pool, servercfg->server_hostname); server->alias = apr_pstrdup (pool, alias); server->filename = NULL; server->run_xsp = "True"; @@ -182,7 +205,6 @@ server->debug = NULL; server->env_vars = NULL; server->status = FORK_NONE; - server->is_virtual = is_virtual; nservers = config->nservers + 1; servers = config->servers; @@ -214,7 +236,7 @@ config = ap_get_module_config (cmd->server->module_config, &mono_module); if (second == NULL) { if (config->auto_app) { - idx = search_for_alias ("XXGLOBAL", config); + idx = search_for_alias ("XXGLOBAL", config, cmd->server); ptr = (char *) &config->servers [idx]; ptr += offset; value = first; @@ -233,8 +255,6 @@ return NULL; } alias = "default"; - if (cmd->server->is_virtual) - alias = cmd->server->server_hostname; value = first; is_default = 1; } else { @@ -249,9 +269,9 @@ if (!config->auto_app_set) config->auto_app = FALSE; - idx = search_for_alias (alias, config); + idx = search_for_alias (alias, config, cmd->server); if (idx == -1) - idx = add_xsp_server (cmd->pool, alias, config, is_default, cmd->server->is_virtual); + idx = add_xsp_server (cmd->pool, alias, config, is_default, cmd->server); ptr = (char *) &config->servers [idx]; ptr += offset; @@ -310,12 +330,6 @@ return cfg; } -static char * -get_default_global_socket_name (apr_pool_t *pool, const char *base) -{ - return apr_pstrcat (pool, base, "_", "global", NULL); -} - static void * create_mono_server_config (apr_pool_t *p, server_rec *s) { @@ -324,8 +338,8 @@ server = apr_pcalloc (p, sizeof (module_cfg)); server->auto_app = TRUE; server->auto_app_set = FALSE; - add_xsp_server (p, "XXGLOBAL", server, FALSE, FALSE); - server->servers [0].filename = get_default_global_socket_name (p, SOCKET_FILE); + add_xsp_server (p, "XXGLOBAL", server, FALSE, s); + server->servers [0].filename = get_default_socket_name (p, &server->servers[0], SOCKET_FILE); return server; } @@ -838,9 +852,13 @@ #endif static char * -get_default_socket_name (apr_pool_t *pool, const char *alias, const char *base) +get_default_socket_name (apr_pool_t *pool, xsp_data *xsp, const char *base) { - return apr_pstrcat (pool, base, "_", alias == NULL ? "default" : alias, NULL); + return apr_pstrcat (pool, base, "_", + xsp->vhost == NULL ? "" : xsp->vhost, + "_", + xsp->alias == NULL ? "default" : xsp->alias, + NULL); } static apr_status_t @@ -861,7 +879,7 @@ if (conf->filename != NULL) fn = conf->filename; else - fn = get_default_socket_name (pool, conf->alias, SOCKET_FILE); + fn = get_default_socket_name (pool, conf, SOCKET_FILE); DEBUG_PRINT (1, "Socket file name %s", fn); memcpy (unix_address.sun_path, fn, strlen (fn) + 1); @@ -1149,7 +1167,7 @@ fn = config->filename; if (fn == NULL) - fn = get_default_socket_name (pool, config->alias, SOCKET_FILE); + fn = get_default_socket_name (pool, config, SOCKET_FILE); argv [argi++] = "--filename"; argv [argi++] = fn; @@ -1396,6 +1414,7 @@ module_cfg *config; per_dir_config *dir_config = NULL; int idx; + char *alias; config = ap_get_module_config (r->server->module_config, &mono_module); DEBUG_PRINT (2, "config = %d", (int) config); @@ -1404,16 +1423,19 @@ DEBUG_PRINT (2, "dir_config = %d", (int) dir_config); if (dir_config != NULL && dir_config->alias != NULL) - idx = search_for_alias (dir_config->alias, config); + alias = dir_config->alias; else - idx = search_for_alias (NULL, config); + alias = NULL; - DEBUG_PRINT (2, "idx = %d", idx); + idx = search_for_alias (alias, config, r->server); - if (idx < 0) { - DEBUG_PRINT (2, "Alias not found. Checking for auto-applications."); + if (idx >= 0) { + DEBUG_PRINT (2, "idx = %d", idx); + } else { + DEBUG_PRINT (2, "Alias \"%s\" not found. Checking for auto-applications.", + alias == NULL ? "<default server>" : alias); if (config->auto_app) - idx = search_for_alias ("XXGLOBAL", config); + idx = search_for_alias ("XXGLOBAL", config, r->server); if (idx == -1) { DEBUG_PRINT (2, "Global config not found. Finishing request."); @@ -1631,7 +1653,7 @@ char *fn = xsp->filename; if (fn == NULL) - fn = get_default_socket_name (pconf, xsp->alias, SOCKET_FILE); + fn = get_default_socket_name (pconf, xsp, SOCKET_FILE); remove (fn); /* Don't bother checking error */ } Index: ChangeLog =================================================================== --- ChangeLog (revision 65551) +++ ChangeLog (working copy) @@ -1,3 +1,8 @@ +2006-09-17 Joshua Tauberer <[EMAIL PROTECTED]> + + * src/mod_mono.c: Prefix every alias with the name of the vhost. + XXGLOBALs between vhosts were getting mixed up. + 2006-08-31 Gonzalo Paniagua Javier <[EMAIL PROTECTED]> * src/mod_mono.c: Fix problem in Solaris 9 due to alignment. Patch by
_______________________________________________ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list