/** * Observe callback. Called internally by libcouchbase's observe handlers */ void lcb_durability_dset_update(lcb_t instance, lcb_durability_set_t *dset, lcb_error_t err, const lcb_observe_resp_t *resp) { lcb_durability_entry_t *ent; /** * So we have two counters to decrement. One is the global 'done' counter * and the other is the iteration counter. * * The iteration counter is only decremented when we receive a NULL signal * in the callback, whereas the global counter is decremented once, whenever * the entry's criteria have been satisfied */ if (resp->v.v0.key == NULL) { dset_done_waiting(dset); return; } if (dset->nentries == 1) { ent = &dset->single.ent; } else { ent = genhash_find(dset->ht, resp->v.v0.key, resp->v.v0.nkey); } if (ent->done) { /* ignore subsequent errors */ return; } if (err != LCB_SUCCESS) { RESFLD(ent, err) = err; return; } RESFLD(ent, nresponses)++; if (resp->v.v0.cas && resp->v.v0.from_master) { RESFLD(ent, cas) = resp->v.v0.cas; if (REQFLD(ent, cas) && REQFLD(ent, cas) != resp->v.v0.cas) { RESFLD(ent, err) = LCB_KEY_EEXISTS; ent_set_resdone(ent); return; } } if (DSET_OPTFLD(ent->parent, check_delete)) { check_negative_durability(ent, resp); } else { check_positive_durability(ent, resp); } if (ent_is_complete(ent)) { /* clear any transient errors */ RESFLD(ent, err) = LCB_SUCCESS; ent_set_resdone(ent); } (void)instance; }
/** * Observe callback. Called internally by libcouchbase's observe handlers */ void lcb_durability_dset_update(lcb_t instance, lcb_DURSET *dset, lcb_error_t err, const lcb_RESPOBSERVE *resp) { lcb_DURITEM *ent; /** * So we have two counters to decrement. One is the global 'done' counter * and the other is the iteration counter. * * The iteration counter is only decremented when we receive a NULL signal * in the callback, whereas the global counter is decremented once, whenever * the entry's criteria have been satisfied */ if (resp->key == NULL) { dset_done_waiting(dset); return; } if (dset->nentries == 1) { ent = &dset->single.ent; } else { ent = genhash_find(dset->ht, resp->key, resp->nkey); } if (ent->done) { /* ignore subsequent errors */ return; } if (err != LCB_SUCCESS) { RESFLD(ent, rc) = err; /* If it's a non-scheduling error then the item will be retried in the * next iteration */ if (err == LCB_SCHEDFAIL_INTERNAL) { ent_set_resdone(ent); } return; } RESFLD(ent, nresponses)++; if (resp->cas && resp->ismaster) { RESFLD(ent, cas) = resp->cas; if (ent->reqcas && ent->reqcas != resp->cas) { RESFLD(ent, rc) = LCB_KEY_EEXISTS; ent_set_resdone(ent); return; } } if (DSET_OPTFLD(ent->parent, check_delete)) { check_negative_durability(ent, resp); } else { check_positive_durability(ent, resp); } if (ent_is_complete(ent)) { /* clear any transient errors */ RESFLD(ent, rc) = LCB_SUCCESS; ent_set_resdone(ent); } (void)instance; }