Skip to content

Commit c35be6d

Browse files
committed
update trylock method
1 parent b626ef6 commit c35be6d

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
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_5;"
27+
ngx_feature_test="int ngx_http_c_func_module_current_version_=ngx_http_c_func_module_version_6;"
2828
. auto/feature
2929

3030
if [ $ngx_found != yes ]; then

src/ngx_http_c_func_module.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ void* ngx_http_c_func_get_query_param(ngx_http_c_func_ctx_t *ctx, const char *ke
148148
void* ngx_http_c_func_palloc(ngx_http_c_func_ctx_t *ctx, size_t size);
149149
void* ngx_http_c_func_pcalloc(ngx_http_c_func_ctx_t *ctx, size_t size);
150150

151+
uintptr_t ngx_http_c_func_shmtx_trylock(void *shared_mem);
151152
void ngx_http_c_func_shmtx_lock(void *shared_mem);
152153
void ngx_http_c_func_shmtx_unlock(void *shared_mem);
153154
void* ngx_http_c_func_shm_alloc(void *shared_mem, size_t size);
@@ -501,7 +502,7 @@ ngx_http_c_func_post_configuration(ngx_conf_t *cf) {
501502
static ngx_int_t
502503
ngx_http_c_func_pre_configuration(ngx_conf_t *cf) {
503504

504-
#ifndef ngx_http_c_func_module_version_5
505+
#ifndef ngx_http_c_func_module_version_6
505506
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, \
506507
please copy latest ngx_http_c_func_module.h to your /usr/include or /usr/local/include or relavent header search path \
507508
with read and write permission.");
@@ -1125,6 +1126,11 @@ ngx_http_c_func_pcalloc(ngx_http_c_func_ctx_t *ctx, size_t size) {
11251126
return ngx_pcalloc( ((ngx_http_request_t*)ctx->__r__)->pool, size );
11261127
}
11271128

1129+
uintptr_t
1130+
ngx_http_c_func_shmtx_trylock(void *shared_mem) {
1131+
return ngx_shmtx_trylock(&((ngx_http_c_func_http_shm_t*)shared_mem)->shpool->mutex);
1132+
}
1133+
11281134
void
11291135
ngx_http_c_func_shmtx_lock(void *shared_mem) {
11301136
ngx_shmtx_lock(&((ngx_http_c_func_http_shm_t*)shared_mem)->shpool->mutex);

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_5 5
38+
#define ngx_http_c_func_module_version_6 6
3939

4040

4141
#define ngx_http_c_func_content_type_plaintext "text/plain"
@@ -82,6 +82,7 @@ extern void ngx_http_c_func_write_resp(
8282
);
8383

8484
// Shared Memory and Cache Scope
85+
extern uintptr_t ngx_http_c_func_shmtx_trylock(void *shared_mem);
8586
extern void ngx_http_c_func_shmtx_lock(void *shared_mem);
8687
extern void ngx_http_c_func_shmtx_unlock(void *shared_mem);
8788
extern void* ngx_http_c_func_shm_alloc(void *shared_mem, size_t size);

0 commit comments

Comments
 (0)