1、调试core,首先发现core的原因是释放slab内存块时,重复释放了一块内存,ngx_slab_free_locked(shpool,f->k);关键问题是在释放f->k时,没有保护f->k为NULL的场景。但是问题是,为什么会重复释放?其他那个地方已经释放了这块内存,为什么还会走到这块逻辑,或者说这块内存一直为NULL? 2、调用释放共享内存的函数的...
//free memory for a message.staticngx_inlinevoidngx_http_push_free_message_locked(ngx_http_push_msg_t*msg,ngx_slab_pool_t*shpool){if(msg->buf->file!=NULL) {// i'd like to release the shpool lock here while i do stuff to this file, but that// might unlock during channel rbtre...
ngx_rbtree_delete(&ctx->sh->rbtree, node); ngx_slab_free_locked(ctx->shpool, node); } } 开发者ID:amumu,项目名称:limit_req2_nginx_module,代码行数:58,代码来源:ngx_http_limit_req2_module.c 示例5: ngx_worker_thread ▲点赞 1▼ staticngx_thread_value_t__stdcallngx_worker_thread(vo...
在后面的模块中,我们可以使用ngc_slab_alloc_locked以及ngx_slab_free_locked,对共享内存进行分配和释放. staticngx_int_t ngx_http_limit_req_handler(ngx_http_request_t*r) {* * *//在共享内存中创建一个结点node = ngx_slab_alloc_locked(ctx->shpool, n);if(node ==NULL) {//共享内存空间不足,...
((u_char *) sd -offsetof(ngx_rbtree_node_t, color));ngx_rbtree_delete(&ctx->sh->rbtree, node);ngx_slab_free_locked(ctx->shpool, node);/* 没有找到,则直接新添该key */insert:ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ctx->log,0,"lua shared dict incr: creating a new entry"); ...
ngx_rbtree_delete(&ctx->sh->rbtree, node);ngx_slab_free_locked(ctx->shpool, node); } }static ngx_int_t ngx_http_limit_req_init_zone(ngx_shm_zone_t *shm_zone, void *data) { ngx_http_limit_req_ctx_t *octx = data;size_t len; ngx_http_limit_req_ctx_t *ctx;...
// * ngx_slab_alloc_locked // * ngx_slab_alloc_pages // * ngx_slab_free_locked // * ngx_slab_free_pages /* * Copyright (C) Igor Sysoev * Copyright (C) Nginx, Inc.*/ #include <ngx_config.h> #include <ngx_core.h> // 内存页的标记,即二进制11 ...
(&ctx->sh->rbtree, node); ngx_slab_free_locked(ctx->shpool, node); freed++; } return freed; } void ngx_http_lua_inject_shdict_api(ngx_http_lua_main_conf_t *lmcf, lua_State *L) { ngx_http_lua_shdict_ctx_t *ctx; ngx_uint_t i; ngx_shm_zone_t **zon...
sh->status = ngx_slab_alloc_locked(shpool, sizeof(ngx_dyups_status_t) * ccf->worker_processes); if (sh->status == NULL) { ngx_shmtx_unlock(&shpool->mutex); return NGX_ERROR; } ngx_memzero(sh->status, sizeof(ngx_dyups_status_t) * ccf->worker_processes); ...
sh->status = ngx_slab_alloc_locked(shpool, sizeof(ngx_dyups_status_t) * ccf->worker_processes); if (sh->status == NULL) { ngx_shmtx_unlock(&shpool->mutex); return NGX_ERROR; } ngx_memzero(sh->status, sizeof(ngx_dyups_status_t) * ccf->worker_processes); ...