Skip to content

bugfix: Add shmtx unlock #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 26, 2022
Merged

bugfix: Add shmtx unlock #249

merged 1 commit into from
Sep 26, 2022

Conversation

u5surf
Copy link
Collaborator

@u5surf u5surf commented Sep 26, 2022

ngx_http_vhost_traffic_status_shm_add_node does not unlock if it returns from line 133 nevertheless it acquires the lock at line 107.

ngx_shmtx_lock(&shpool->mutex);
/* find node */
hash = ngx_crc32_short(key->data, key->len);
node = ngx_http_vhost_traffic_status_find_node(r, key, type, hash);
/* set common */
if (node == NULL) {
init = NGX_HTTP_VHOST_TRAFFIC_STATUS_NODE_NONE;
/* delete lru node */
lrun = ngx_http_vhost_traffic_status_find_lru(r);
if (lrun != NULL) {
ngx_rbtree_delete(ctx->rbtree, lrun);
ngx_slab_free_locked(shpool, lrun);
}
size = offsetof(ngx_rbtree_node_t, color)
+ offsetof(ngx_http_vhost_traffic_status_node_t, data)
+ key->len;
node = ngx_slab_alloc_locked(shpool, size);
if (node == NULL) {
shm_info = ngx_pcalloc(r->pool, sizeof(ngx_http_vhost_traffic_status_shm_info_t));
if (shm_info == NULL) {
return NGX_ERROR;

@u5surf u5surf requested a review from vozlt September 26, 2022 12:12
@u5surf u5surf merged commit f731137 into vozlt:master Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants