Exemplo n.º 1
0
Arquivo: mbuf.c Projeto: BBGIP/corvus
void mbuf_decref(struct context *ctx, struct mbuf **bufs, int n)
{
    for (int i = 0; i < n; i++) {
        if (bufs[i] == NULL) {
            continue;
        }
        bufs[i]->refcount--;
        if (bufs[i]->refcount <= 0) {
            TAILQ_REMOVE(bufs[i]->queue, bufs[i], next);
            mbuf_recycle(ctx, bufs[i]);
            bufs[i] = NULL;
        }
    }
}
Exemplo n.º 2
0
void conn_buf_free(struct connection *conn)
{
    if (conn->info == NULL) return;
    struct conn_info *info = conn->info;
    struct buf_time *t;
    struct mbuf *buf;

    while (!STAILQ_EMPTY(&info->buf_times)) {
        t = STAILQ_FIRST(&info->buf_times);
        STAILQ_REMOVE_HEAD(&info->buf_times, next);
        buf_time_free(t);
    }
    while (!TAILQ_EMPTY(&info->data)) {
        buf = TAILQ_FIRST(&info->data);
        TAILQ_REMOVE(&info->data, buf, next);
        mbuf_recycle(conn->ctx, buf);
    }
    while (!TAILQ_EMPTY(&info->local_data)) {
        buf = TAILQ_FIRST(&info->local_data);
        TAILQ_REMOVE(&info->local_data, buf, next);
        mbuf_recycle(conn->ctx, buf);
    }
}
Exemplo n.º 3
0
Arquivo: mbuf.c Projeto: BBGIP/corvus
void mbuf_range_clear(struct context *ctx, struct buf_ptr ptr[])
{
    struct mbuf *n, *b = ptr[0].buf;

    while (b != NULL) {
        n = TAILQ_NEXT(b, next);
        b->refcount--;
        if (b->refcount <= 0 && b->pos >= b->last) {
            TAILQ_REMOVE(b->queue, b, next);
            mbuf_recycle(ctx, b);
        }
        if (b == ptr[1].buf) break;
        b = n;
    }
    memset(&ptr[0], 0, sizeof(struct buf_ptr));
    memset(&ptr[1], 0, sizeof(struct buf_ptr));
}