static void stat_callback(lcb_t instance, const void *cookie, lcb_error_t err, const lcb_server_stat_resp_t *resp) { pycbc_MultiResultObject *mres; PyObject *value; PyObject *skey, *knodes; mres = (pycbc_MultiResultObject*)cookie; CB_THR_END(mres->parent); if (err != LCB_SUCCESS) { if (mres->errop == NULL) { pycbc_ResultBaseObject *res = (pycbc_ResultBaseObject*)pycbc_result_new(mres->parent); res->rc = err; res->key = Py_None; Py_INCREF(res->key); maybe_push_operr(mres, res, err, 0); } CB_THR_BEGIN(mres->parent); return; } if (!resp->v.v0.server_endpoint) { CB_THR_BEGIN(mres->parent); return; } skey = pycbc_SimpleStringN(resp->v.v0.key, resp->v.v0.nkey); value = pycbc_SimpleStringN(resp->v.v0.bytes, resp->v.v0.nbytes); { PyObject *intval = pycbc_maybe_convert_to_int(value); if (intval) { Py_DECREF(value); value = intval; } else { PyErr_Clear(); } } knodes = PyDict_GetItem((PyObject*)mres, skey); if (!knodes) { knodes = PyDict_New(); PyDict_SetItem((PyObject*)mres, skey, knodes); Py_DECREF(knodes); } PyDict_SetItemString(knodes, resp->v.v0.server_endpoint, value); Py_DECREF(skey); Py_DECREF(value); CB_THR_BEGIN(mres->parent); (void)instance; }
static void stats_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *resp_base) { pycbc_MultiResult *mres; PyObject *value; PyObject *skey, *knodes; PyObject *mrdict; pycbc_Bucket *parent; const lcb_RESPSTATS *resp = (const lcb_RESPSTATS *)resp_base; int do_return = 0; mres = (pycbc_MultiResult*)resp->cookie; parent = mres->parent; CB_THR_END(parent); if (resp->rc != LCB_SUCCESS) { do_return = 1; if (mres->errop == NULL) { pycbc_Result *res = (pycbc_Result*)pycbc_result_new(parent); res->rc = resp->rc; res->key = Py_None; Py_INCREF(res->key); maybe_push_operr(mres, res, resp->rc, 0); } } if (resp->rflags & LCB_RESP_F_FINAL) { /* Note this can happen in both success and error cases! */ do_return = 1; operation_completed(parent, mres); } if (do_return) { CB_THR_BEGIN(parent); return; } skey = pycbc_SimpleStringN(resp->key, resp->nkey); value = pycbc_SimpleStringN(resp->value, resp->nvalue); { PyObject *intval = pycbc_maybe_convert_to_int(value); if (intval) { Py_DECREF(value); value = intval; } else { PyErr_Clear(); } } mrdict = pycbc_multiresult_dict(mres); knodes = PyDict_GetItem(mrdict, skey); if (!knodes) { knodes = PyDict_New(); PyDict_SetItem(mrdict, skey, knodes); } PyDict_SetItemString(knodes, resp->server, value); Py_DECREF(skey); Py_DECREF(value); CB_THR_BEGIN(parent); (void)instance; }