Welcome! Log In Create A New Profile

Advanced

ngx_str_rbtree_lookup() always return NULL

Donatas Abraitis
August 28, 2014 05:38PM
Hey,

who can explain this function's behavior? Am I using this wrong? It always
returns NULL, though I 100% ensured, there should be. Is here any way to
list all nodes in the rbtree?

static int purge_from_cache(ngx_slab_pool_t *shpool, ngx_rbtree_t *rbtree,
ngx_str_t ip, ngx_http_request_t *r)
{
uint32_t hash;
ngx_http_hostprotect_value_node_t *found;
hash = ngx_crc32_long(ip.data, ip.len);
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "%s: Trying to purge %s
(%lu)", MODULE_NAME, ip.data, (unsigned long)hash);

ngx_shmtx_lock(&shpool->mutex);
found = (ngx_http_hostprotect_value_node_t *)
ngx_str_rbtree_lookup(rbtree, &ip, hash);
ngx_shmtx_unlock(&shpool->mutex);
if(found) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "%s: Purging from
active cache %s", MODULE_NAME, ip.data);
ngx_shmtx_lock(&shpool->mutex);
ngx_rbtree_delete(rbtree, found);
ngx_slab_free_locked(shpool, found);
ngx_shmtx_unlock(&shpool->mutex);
return 1;
}
return 0;
}

--
Donatas
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

ngx_str_rbtree_lookup() always return NULL

Donatas Abraitis 719 August 28, 2014 05:38PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 211
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready