Skip to content

Commit 9ac3e94

Browse files
author
Sascha Schumann
committed
Reapply configuration for each request
1 parent 08d762c commit 9ac3e94

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

sapi/aolserver/aolserver.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ int Ns_ModuleVersion = 1;
5959
#define NSG(v) (ns_context->v)
6060
#define NSLS_FETCH() ns_globals_struct *ns_context = ts_resource(ns_globals_id)
6161

62-
/* TSRM id */
63-
64-
static int ns_globals_id;
65-
6662
/* php_ns_context is per-server (thus only once at all) */
6763

6864
typedef struct {
@@ -78,6 +74,16 @@ typedef struct {
7874
size_t data_avail;
7975
} ns_globals_struct;
8076

77+
/* TSRM id */
78+
79+
static int ns_globals_id;
80+
81+
/* global context */
82+
83+
static php_ns_context *global_context;
84+
85+
static void php_ns_config(php_ns_context *ctx, char global);
86+
8187
/*
8288
* php_ns_sapi_ub_write() writes data to the client connection.
8389
*/
@@ -412,9 +418,11 @@ php_ns_module_main(NSLS_D SLS_DC)
412418
file_handle.filename = SG(request_info).path_translated;
413419
file_handle.free_filename = 0;
414420

421+
php_ns_config(global_context, 0);
415422
if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC) == FAILURE) {
416423
return NS_ERROR;
417424
}
425+
418426
php_ns_hash_environment(NSLS_C CLS_CC ELS_CC PLS_CC SLS_CC);
419427
php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC);
420428
php_request_shutdown(NULL);
@@ -510,7 +518,7 @@ php_ns_request_handler(void *context, Ns_Conn *conn)
510518
*/
511519

512520
static void
513-
php_ns_config(php_ns_context *ctx)
521+
php_ns_config(php_ns_context *ctx, char global)
514522
{
515523
int i;
516524
char *path;
@@ -519,20 +527,20 @@ php_ns_config(php_ns_context *ctx)
519527
path = Ns_ConfigGetPath(ctx->ns_server, ctx->ns_module, NULL);
520528
set = Ns_ConfigGetSection(path);
521529

522-
for(i = 0; set && i < Ns_SetSize(set); i++) {
530+
for (i = 0; set && i < Ns_SetSize(set); i++) {
523531
char *key = Ns_SetKey(set, i);
524532
char *value = Ns_SetValue(set, i);
525533

526-
if(!strcasecmp(key, "map")) {
534+
if (global && !strcasecmp(key, "map")) {
527535
Ns_Log(Notice, "Registering PHP for \"%s\"", value);
528536
Ns_RegisterRequest(ctx->ns_server, "GET", value, php_ns_request_handler, NULL, ctx, 0);
529537
Ns_RegisterRequest(ctx->ns_server, "POST", value, php_ns_request_handler, NULL, ctx, 0);
530538
Ns_RegisterRequest(ctx->ns_server, "HEAD", value, php_ns_request_handler, NULL, ctx, 0);
531-
} else if(!strcasecmp(key, "php_value")) {
539+
} else if (!global && !strcasecmp(key, "php_value")) {
532540
char *val;
533541

534542
val = strchr(value, ' ');
535-
if(val) {
543+
if (val) {
536544
char *new_key;
537545

538546
new_key = estrndup(value, val - value);
@@ -598,7 +606,9 @@ int Ns_ModuleInit(char *server, char *module)
598606
ctx->ns_module = strdup(module);
599607

600608
/* read the configuration */
601-
php_ns_config(ctx);
609+
php_ns_config(ctx, 1);
610+
611+
global_context = ctx;
602612

603613
/* register shutdown handler */
604614
Ns_RegisterServerShutdown(server, php_ns_server_shutdown, ctx);

0 commit comments

Comments
 (0)