<div dir="ltr"><div>Hey,</div><div><br></div><div>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?</div>
<div><br></div><div>static int purge_from_cache(ngx_slab_pool_t *shpool, ngx_rbtree_t *rbtree, ngx_str_t ip, ngx_http_request_t *r)</div>
<div>{</div><div> uint32_t hash;</div><div> ngx_http_hostprotect_value_node_t *found;</div><div> hash = ngx_crc32_long(ip.data, ip.len);</div><div> ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "%s: Trying to purge %s (%lu)", MODULE_NAME, ip.data, (unsigned long)hash);</div>
<div><br></div><div> ngx_shmtx_lock(&shpool->mutex);</div><div> found = (ngx_http_hostprotect_value_node_t *) ngx_str_rbtree_lookup(rbtree, &ip, hash);</div><div> ngx_shmtx_unlock(&shpool->mutex);</div>
<div> if(found) {</div><div> ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "%s: Purging from active cache %s", MODULE_NAME, ip.data);</div><div> ngx_shmtx_lock(&shpool->mutex);</div><div>
ngx_rbtree_delete(rbtree, found);</div><div> ngx_slab_free_locked(shpool, found);</div><div> ngx_shmtx_unlock(&shpool->mutex);</div><div> return 1;</div><div> }</div><div> return 0;</div><div>}</div>
<div><br></div>-- <br>Donatas<br>
</div>