-static int enqueue_chunk(struct chunk_queue *cq, long unsigned chunk_num,
- size_t sent)
-{
- struct queued_chunk *qc;
- char *buf;
- size_t len;
- int ret;
-
- if (chunk_num != -1U) {
- ret = vss_get_chunk(chunk_num, &buf, &len);
- if (ret < 0)
- return ret;
- } else
- buf = vss_get_header(&len);
- if (cq->num_pending + len > MAX_BACKLOG)
- return -E_QUEUE;
- qc = para_malloc(sizeof(struct queued_chunk));
- cq->num_pending += len;
- qc->chunk_num = chunk_num;
- qc->sent = sent;
- list_add_tail(&qc->node, &cq->q);
- PARA_INFO_LOG("%lu bytes queued for q %p\n", cq->num_pending, &cq->q);
- return 1;
-}
-