@@ -152,10 +152,12 @@ void ngx_http_c_func_shmtx_lock(void *shared_mem);
152152void ngx_http_c_func_shmtx_unlock (void * shared_mem );
153153void * ngx_http_c_func_shm_alloc (void * shared_mem , size_t size );
154154void ngx_http_c_func_shm_free (void * shared_mem , void * ptr );
155+ void * ngx_http_c_func_shm_alloc_locked (void * shared_mem , size_t size );
156+ void ngx_http_c_func_shm_free_locked (void * shared_mem , void * ptr );
155157void * ngx_http_c_func_cache_get (void * shared_mem , const char * key );
156158void * ngx_http_c_func_cache_put (void * shared_mem , const char * key , void * value );
157159void * ngx_http_c_func_cache_new (void * shared_mem , const char * key , size_t size );
158- void ngx_http_c_func_cache_remove (void * shared_mem , const char * key );
160+ void * ngx_http_c_func_cache_remove (void * shared_mem , const char * key );
159161
160162void ngx_http_c_func_write_resp (
161163 ngx_http_c_func_ctx_t * ctx ,
@@ -499,7 +501,7 @@ ngx_http_c_func_post_configuration(ngx_conf_t *cf) {
499501static ngx_int_t
500502ngx_http_c_func_pre_configuration (ngx_conf_t * cf ) {
501503
502- #ifndef ngx_http_c_func_module_version_4
504+ #ifndef ngx_http_c_func_module_version_5
503505 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, \
504506 please copy latest ngx_http_c_func_module.h to your /usr/include or /usr/local/include or relavent header search path \
505507 with read and write permission." );
@@ -1137,13 +1139,22 @@ ngx_http_c_func_shmtx_unlock(void *shared_mem) {
11371139
11381140void *
11391141ngx_http_c_func_shm_alloc (void * shared_mem , size_t size ) {
1140- return ngx_slab_alloc_locked (((ngx_http_c_func_http_shm_t * )shared_mem )-> shpool , size );
1142+ return ngx_slab_alloc (((ngx_http_c_func_http_shm_t * )shared_mem )-> shpool , size );
11411143}
11421144
11431145void
11441146ngx_http_c_func_shm_free (void * shared_mem , void * ptr ) {
1147+ ngx_slab_free (((ngx_http_c_func_http_shm_t * )shared_mem )-> shpool , ptr );
1148+ }
1149+
1150+ void *
1151+ ngx_http_c_func_shm_alloc_locked (void * shared_mem , size_t size ) {
1152+ return ngx_slab_alloc_locked (((ngx_http_c_func_http_shm_t * )shared_mem )-> shpool , size );
1153+ }
1154+
1155+ void
1156+ ngx_http_c_func_shm_free_locked (void * shared_mem , void * ptr ) {
11451157 ngx_slab_free_locked (((ngx_http_c_func_http_shm_t * )shared_mem )-> shpool , ptr );
1146- // ngx_spinlock((ngx_atomic_t*) ctx->__shm_t__->multi_processes_lock, 1, 2048);
11471158}
11481159
11491160void *
@@ -1210,16 +1221,22 @@ ngx_http_c_func_cache_new(void *shared_mem, const char* key, size_t size) {
12101221 return cvnt -> value ;
12111222}
12121223
1213- void
1224+ void *
12141225ngx_http_c_func_cache_remove (void * shared_mem , const char * key ) {
1226+ void * old_value ;
12151227 ngx_str_t str_key = ngx_string (key );
12161228 uint32_t hash = ngx_crc32_long (str_key .data , str_key .len );
12171229 ngx_http_c_func_http_shm_t * _cache = (ngx_http_c_func_http_shm_t * )shared_mem ;
12181230 ngx_http_c_func_http_cache_value_node_t * cvnt = (ngx_http_c_func_http_cache_value_node_t * )
12191231 ngx_str_rbtree_lookup (& _cache -> rbtree , & str_key , hash );
12201232
1221- if (cvnt )
1233+ if (cvnt ) {
1234+ old_value = cvnt -> value ;
12221235 ngx_rbtree_delete (& _cache -> rbtree , & cvnt -> sn .node );
1236+ return old_value ;
1237+ }
1238+
1239+ return NULL ;
12231240}
12241241
12251242void
0 commit comments