rem: chunk_put(chunk);
add: chunk->offset += res; chunk->size -= res; chunk->res -= res; } sem_post(&chunk->ready); chunk_put_locked(chunk);
context: static int wait_chunk(struct read_chunk *chunk, char *buf){    int res;    sem_wait(&chunk->ready);    res = chunk->res;    if (res > 0)        buf_get_mem(&chunk->data, buf, res);    chunk_put(chunk);    return res;}