Skip to content

Commit 3d7d5ad

Browse files
committed
added on pool in internal ctx purpose
1 parent 07d7282 commit 3d7d5ad

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ngx_feature_incs="#include <ngx_http_c_func_module.h>"
2424
ngx_feature_path=
2525
ngx_feature_libs=
2626
# ngx_feature_exit_if_not_found=yes
27-
ngx_feature_test="int ngx_http_c_func_module_current_version_=ngx_http_c_func_module_version_6;"
27+
ngx_feature_test="int ngx_http_c_func_module_current_version_=ngx_http_c_func_module_version_7;"
2828
. auto/feature
2929

3030
if [ $ngx_found != yes ]; then

src/ngx_http_c_func_module.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ ngx_http_c_func_proceed_init_calls(ngx_cycle_t* cycle, ngx_http_c_func_srv_conf
453453
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "application initializing");
454454
/*** Init the apps ***/
455455
ngx_http_c_func_ctx_t new_ctx; //config request
456+
new_ctx.__pl__ = cycle->pool;
456457
new_ctx.__log__ = cycle->log;
457458
new_ctx.shared_mem = (void*)mcf->shm_ctx->shared_mem;
458459
func(&new_ctx);
@@ -502,7 +503,7 @@ ngx_http_c_func_post_configuration(ngx_conf_t *cf) {
502503
static ngx_int_t
503504
ngx_http_c_func_pre_configuration(ngx_conf_t *cf) {
504505

505-
#ifndef ngx_http_c_func_module_version_6
506+
#ifndef ngx_http_c_func_module_version_7
506507
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%s", "the latest ngx_http_c_func_module.h not found in the c header path, \
507508
please copy latest ngx_http_c_func_module.h to your /usr/include or /usr/local/include or relavent header search path \
508509
with read and write permission.");
@@ -655,6 +656,7 @@ ngx_http_c_func_process_exit(ngx_cycle_t *cycle) {
655656
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, "Error function call %s", error);
656657
} else {
657658
ngx_http_c_func_ctx_t new_ctx; //config request
659+
new_ctx.__pl__ = cycle->pool;
658660
new_ctx.__log__ = cycle->log;
659661
new_ctx.shared_mem = (void*)mcf->shm_ctx->shared_mem;
660662
func(&new_ctx);
@@ -848,6 +850,7 @@ ngx_http_c_func_content_handler(ngx_http_request_t *r) {
848850

849851
ngx_http_c_func_ctx_t new_ctx;
850852
new_ctx.__r__ = r;
853+
new_ctx.__pl__ = r->pool;
851854
new_ctx.__log__ = r->connection->log;
852855
new_ctx.shared_mem = (void*)mcf->shm_ctx->shared_mem;
853856

@@ -1118,12 +1121,12 @@ ngx_http_c_func_get_query_param(ngx_http_c_func_ctx_t *ctx, const char *key) {
11181121

11191122
void*
11201123
ngx_http_c_func_palloc(ngx_http_c_func_ctx_t *ctx, size_t size) {
1121-
return ngx_palloc( ((ngx_http_request_t*)ctx->__r__)->pool, size );
1124+
return ngx_palloc( (ngx_pool_t*)ctx->__pl__, size );
11221125
}
11231126

11241127
void*
11251128
ngx_http_c_func_pcalloc(ngx_http_c_func_ctx_t *ctx, size_t size) {
1126-
return ngx_pcalloc( ((ngx_http_request_t*)ctx->__r__)->pool, size );
1129+
return ngx_pcalloc( (ngx_pool_t*)ctx->__pl__, size );
11271130
}
11281131

11291132
uintptr_t
@@ -1228,7 +1231,7 @@ ngx_http_c_func_cache_new(void *shared_mem, const char* key, size_t size) {
12281231
str_key->data = (u_char*) ngx_slab_alloc_locked(_cache->shpool, sizeof(u_char) * (str_key->len + 1) );
12291232
ngx_memcpy(str_key->data, key, str_key->len);
12301233
str_key->data[str_key->len] = 0;
1231-
1234+
12321235
uint32_t hash = ngx_crc32_long(str_key->data, str_key->len);
12331236

12341237
cvnt->value = ngx_slab_alloc_locked(_cache->shpool, size);

src/ngx_http_c_func_module.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include <stdlib.h>
3636
#include <stdint.h>
3737

38-
#define ngx_http_c_func_module_version_6 6
38+
#define ngx_http_c_func_module_version_7 7
3939

4040

4141
#define ngx_http_c_func_content_type_plaintext "text/plain"
@@ -53,6 +53,7 @@ typedef struct {
5353

5454
/* internal */
5555
void* __r__;
56+
void* __pl__;
5657
void* __log__;
5758
intptr_t __rc__;
5859
} ngx_http_c_func_ctx_t;

0 commit comments

Comments
 (0)