static void observe_callback(lcb_t instance, const void *cookie, lcb_error_t err, const lcb_observe_resp_t *resp) { int rv; pycbc_ObserveInfo *oi; pycbc_Connection *conn; pycbc_ValueResult *vres; pycbc_MultiResult *mres; if (!resp->v.v0.key) { mres = (pycbc_MultiResult*)cookie;; maybe_breakout(mres->parent); return; } rv = get_common_objects((PyObject*)cookie, resp->v.v0.key, resp->v.v0.nkey, err, &conn, (pycbc_Result**)&vres, RESTYPE_VALUE|RESTYPE_EXISTS_OK|RESTYPE_VARCOUNT, &mres); if (rv < 0) { goto GT_DONE; } if (err != LCB_SUCCESS) { maybe_push_operr(mres, (pycbc_Result*)vres, err, 0); goto GT_DONE; } if (!vres->value) { vres->value = PyList_New(0); } oi = pycbc_observeinfo_new(conn); if (oi == NULL) { push_fatal_error(mres); goto GT_DONE; } oi->from_master = resp->v.v0.from_master; oi->flags = resp->v.v0.status; oi->cas = resp->v.v0.cas; PyList_Append(vres->value, (PyObject*)oi); Py_DECREF(oi); GT_DONE: CB_THR_BEGIN(conn); (void)instance; }
static void observe_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *resp_base) { int rv; pycbc_ObserveInfo *oi; pycbc_Bucket *conn; pycbc_ValueResult *vres; pycbc_MultiResult *mres; const lcb_RESPOBSERVE *oresp = (const lcb_RESPOBSERVE *)resp_base; if (resp_base->rflags & LCB_RESP_F_FINAL) { mres = (pycbc_MultiResult*)resp_base->cookie; operation_completed(mres->parent, mres); return; } rv = get_common_objects(resp_base, &conn, (pycbc_Result**)&vres, RESTYPE_VALUE|RESTYPE_EXISTS_OK|RESTYPE_VARCOUNT, &mres); if (rv < 0) { goto GT_DONE; } if (resp_base->rc != LCB_SUCCESS) { maybe_push_operr(mres, (pycbc_Result*)vres, resp_base->rc, 0); goto GT_DONE; } if (!vres->value) { vres->value = PyList_New(0); } oi = pycbc_observeinfo_new(conn); if (oi == NULL) { pycbc_multiresult_adderr(mres); goto GT_DONE; } oi->from_master = oresp->ismaster; oi->flags = oresp->status; oi->cas = oresp->cas; PyList_Append(vres->value, (PyObject*)oi); Py_DECREF(oi); GT_DONE: CB_THR_BEGIN(conn); (void)instance; (void)cbtype; }