ngx_str_rbtree_lookup() always return NULL

Donatas Abraitis donatas.abraitis at gmail.com
Thu Aug 28 21:37:24 UTC 2014


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20140829/8f5f9f31/attachment.html>


More information about the nginx-devel mailing list