Segfault in NGINX - testcase

double nginx-forum at nginx.us
Thu Mar 25 21:08:08 MSK 2010


Just a quick note, if someone needs (for an addon) to traverse an rbtree,
here is the clean way:

static ngx_inline ngx_rbtree_node_t *
    ngx_rbtree_next(ngx_rbtree_t *rbtree, ngx_rbtree_node_t *node)
{
    ngx_rbtree_node_t *sentinel;
    sentinel = rbtree->sentinel;
    if( node->right != sentinel )
    {
        node = node->right;
        while( node->left != sentinel )
            node = node->left;
    }
    else
    {
        ngx_rbtree_node_t *root, *temp;
        root = rbtree->root;
        temp = node;
        while( temp != root && node == temp->parent->right )
            temp = node = temp->parent;
        if( temp == root )
            return sentinel;
        if( node->right != temp->parent )
            node = temp->parent;
    }
    return node;
}

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,65693,67781#msg-67781




More information about the nginx mailing list