remove_dead_res(agooCon c) {
    agooRes	res;
    bool	empty;

    pthread_mutex_lock(&c->res_lock);
    while (NULL != (res = c->res_head)) {
	if (NULL == agoo_res_message_peek(c->res_head) && !c->res_head->close && !c->res_head->ping) {
	    break;
	}
	c->res_head = res->next;
	if (res == c->res_tail) {
	    c->res_tail = NULL;
	}
	agoo_res_destroy(res);
    }
    empty = NULL == c->res_head;
    pthread_mutex_unlock(&c->res_lock);

    return empty;
}
remove_dead_res(agooCon c) {
    agooRes	res;
    bool	empty;

    pthread_mutex_lock(&c->res_lock);
    while (NULL != (res = c->res_head)) {
	if (NULL == agoo_res_message_peek(c->res_head) && !c->res_head->close && !c->res_head->ping) {
	    break;
	}
	c->res_head = res->next;
	if (res == c->res_tail) {
	    c->res_tail = NULL;
	}
	agoo_res_destroy(res);
    }
    empty = NULL == c->res_head;
    pthread_mutex_unlock(&c->res_lock);

    return empty;
}