static int mark_up_to_index(struct blist *blist, uint64_t index, struct dpth *dpth) { struct blk *blk; // Mark everything that was not got, up to the given index. for(blk=blist->blk_from_champ_chooser; blk && blk->index!=index; blk=blk->next) { if(simple_deduplicate_blk(blk)) continue; if(mark_not_got(blk, dpth)) return -1; } if(!blk) { logp("Could not find index from champ chooser: %" PRIu64 "\n", index); return -1; } simple_deduplicate_blk(blk); //logp("Found index from champ chooser: %lu\n", index); //printf("index from cc: %d\n", index); blist->blk_from_champ_chooser=blk; return 0; }
static int deal_with_wrap_up_from_chfd(struct iobuf *rbuf, struct blist *blist, struct dpth *dpth) { static struct blk b; if(blk_set_from_iobuf_wrap_up(&b, rbuf)) return -1; if(mark_up_to_index(blist, b.index, dpth)) return -1; if(mark_not_got(blist->blk_from_champ_chooser, dpth)) return -1; return 0; }
static int deal_with_read_from_chfd(struct asfd *asfd, struct asfd *chfd, struct blist *blist, uint64_t *wrap_up, struct dpth *dpth) { int ret=-1; uint64_t file_no; char *save_path; // Deal with champ chooser read here. //printf("read from cc: %s\n", chfd->rbuf->buf); switch(chfd->rbuf->cmd) { case CMD_SIG: // Get these for blks that the champ chooser has found. file_no=decode_file_no_and_save_path(chfd->rbuf, &save_path); // printf("got save_path: %d %s\n", file_no, save_path); if(mark_up_to_index(blist, file_no, dpth)) goto end; mark_got(blist->blk_from_champ_chooser, save_path); // printf("after mark_got: %d\n", // blist->blk_from_champ_chooser->index); break; case CMD_WRAP_UP: file_no=decode_file_no(chfd->rbuf); // printf("mark up to: %d\n", file_no); if(mark_up_to_index(blist, file_no, dpth)) goto end; mark_not_got(blist->blk_from_champ_chooser, dpth); //printf("after mark_up: %d\n", // blist->blk_from_champ_chooser->index); break; default: iobuf_log_unexpected(chfd->rbuf, __func__); goto end; } ret=0; end: iobuf_free_content(chfd->rbuf); return ret; }