void lerr_opfinish_json(NEOERR *err, HDF *hdf) { if (err == STATUS_OK) { hdf_set_value(hdf, PRE_SUCCESS, "1"); return; } hdf_remove_tree(hdf, PRE_SUCCESS); char buf[1024], errname[128]; NEOERR *neede = mcs_err_valid(err); if (!neede) neede = err; snprintf(buf, sizeof(buf), "%s:%d %s", neede->file, neede->lineno, _lookup_errname(neede, errname, sizeof(errname))); /* set PRE_ERRXXX with the most recently err */ if (!hdf_get_obj(hdf, PRE_ERRMSG)) { hdf_set_value(hdf, PRE_ERRMSG, buf); } hdf_set_int_value(hdf, PRE_ERRCODE, neede->error); STRING str; string_init(&str); nerr_error_traceback(err, &str); mtc_err("%s", str.buf); hdf_set_value(hdf, PRE_ERRTRACE, str.buf); nerr_ignore(&err); string_clear(&str); }
void lerr_opfinish_json(NEOERR *err, HDF *hdf) { if (err == STATUS_OK) { hdf_set_value(hdf, PRE_SUCCESS, "1"); mcs_set_int_attr(hdf, PRE_SUCCESS, "type", CNODE_TYPE_INT); return; } hdf_remove_tree(hdf, PRE_SUCCESS); NEOERR *neede = mcs_err_valid(err); /* set PRE_ERRXXX with the most recently err */ mcs_set_int_value_with_type(hdf, PRE_ERRCODE, neede->error, CNODE_TYPE_INT); if (!hdf_get_obj(hdf, PRE_ERRMSG)) { hdf_set_valuef(hdf, "%s=%s:%d %s", PRE_ERRMSG, neede->file, neede->lineno, neede->desc); } STRING str; string_init(&str); nerr_error_traceback(err, &str); mtc_err("%s", str.buf); hdf_set_value(hdf, PRE_ERRTRACE, str.buf); nerr_ignore(&err); string_clear(&str); }
static void city_process_driver(EventEntry *entry, QueueEntry *q) { struct city_entry *e = (struct city_entry*)entry; NEOERR *err; int ret; struct city_stats *st = &(e->st); st->msg_total++; mtc_dbg("process cmd %u", q->operation); switch (q->operation) { CASE_SYS_CMD(q->operation, q, e->cd, err); case REQ_CMD_CITY_BY_IP: err = city_cmd_ip(e, q); break; case REQ_CMD_CITY_BY_ID: err = city_cmd_id(e, q); break; case REQ_CMD_CITY_BY_S: err = city_cmd_s(e, q); break; case REQ_CMD_PLACE_GET: err = place_cmd_get(e, q); break; case REQ_CMD_STATS: st->msg_stats++; err = STATUS_OK; hdf_set_int_value(q->hdfsnd, "msg_total", st->msg_total); hdf_set_int_value(q->hdfsnd, "msg_unrec", st->msg_unrec); hdf_set_int_value(q->hdfsnd, "msg_badparam", st->msg_badparam); hdf_set_int_value(q->hdfsnd, "msg_stats", st->msg_stats); hdf_set_int_value(q->hdfsnd, "proc_suc", st->proc_suc); hdf_set_int_value(q->hdfsnd, "proc_fai", st->proc_fai); break; default: st->msg_unrec++; err = nerr_raise(REP_ERR_UNKREQ, "unknown command %u", q->operation); break; } NEOERR *neede = mcs_err_valid(err); ret = neede ? neede->error : REP_OK; if (PROCESS_OK(ret)) { st->proc_suc++; } else { st->proc_fai++; if (ret == REP_ERR_BADPARAM) { st->msg_badparam++; } TRACE_ERR(q, ret, err); } if (q->req->flags & FLAGS_SYNC) { reply_trigger(q, ret); } }
static void dyn_process_driver(struct event_entry *entry, struct queue_entry *q) { struct dyn_entry *e = (struct dyn_entry*)entry; NEOERR *err; int ret; mdb_conn *db = e->db; struct cache *cd = e->cd; struct dyn_stats *st = &(e->st); st->msg_total++; mtc_dbg("process cmd %u", q->operation); switch (q->operation) { CASE_SYS_CMD(q->operation, q, e->cd, err); case REQ_CMD_ADDTRACK: err = dyn_cmd_addtrack(q, cd, db); break; case REQ_CMD_GETADMIN: err = dyn_cmd_getadmin(q, cd, db); break; case REQ_CMD_STATS: st->msg_stats++; err = STATUS_OK; hdf_set_int_value(q->hdfsnd, "msg_total", st->msg_total); hdf_set_int_value(q->hdfsnd, "msg_unrec", st->msg_unrec); hdf_set_int_value(q->hdfsnd, "msg_badparam", st->msg_badparam); hdf_set_int_value(q->hdfsnd, "msg_stats", st->msg_stats); hdf_set_int_value(q->hdfsnd, "proc_suc", st->proc_suc); hdf_set_int_value(q->hdfsnd, "proc_fai", st->proc_fai); break; default: st->msg_unrec++; err = nerr_raise(REP_ERR_UNKREQ, "unknown command %u", q->operation); break; } NEOERR *neede = mcs_err_valid(err); ret = neede ? neede->error : REP_OK; if (PROCESS_OK(ret)) { st->proc_suc++; } else { st->proc_fai++; if (ret == REP_ERR_BADPARAM) { st->msg_badparam++; } TRACE_ERR(q, ret, err); } if (q->req->flags & FLAGS_SYNC) { reply_trigger(q, ret); } }
static void aic_process_driver(struct event_entry *entry, struct queue_entry *q) { struct aic_entry *e = (struct aic_entry*)entry; NEOERR *err; int ret; mdb_conn *db = e->db; struct cache *cd = e->cd; struct aic_stats *st = &(e->st); st->msg_total++; mtc_dbg("process cmd %u", q->operation); switch (q->operation) { CASE_SYS_CMD(q->operation, q, e->cd, err); case REQ_CMD_APPINFO: err = aic_cmd_appinfo(q, cd, db); break; case REQ_CMD_APPNEW: err = aic_cmd_appnew(q, cd, db); break; case REQ_CMD_APPUP: err = aic_cmd_appup(q, cd, db); break; case REQ_CMD_APPDEL: err = aic_cmd_appdel(q, cd, db); break; case REQ_CMD_APP_GETSECY: err = aic_cmd_app_getsecy(q, cd, db); break; case REQ_CMD_APP_SETSECY: err = aic_cmd_app_setsecy(q, cd, db); break; case REQ_CMD_APPUSERS: err = aic_cmd_appusers(q, cd, db); break; case REQ_CMD_APPUSERIN: err = aic_cmd_appuserin(q, cd, db); break; case REQ_CMD_APPUSEROUT: err = aic_cmd_appuserout(q, cd, db); break; case REQ_CMD_APPUSERUP: err = aic_cmd_appuserup(q, cd, db); break; case REQ_CMD_APP_O_USERS: err = aic_cmd_appousers(q, cd, db); break; case REQ_CMD_APP_GETRLINK: err = aic_cmd_app_getrlink(q, cd, db); break; case REQ_CMD_APP_SETRLINK: err = aic_cmd_app_setrlink(q, cd, db); break; case REQ_CMD_STATS: st->msg_stats++; err = STATUS_OK; hdf_set_int_value(q->hdfsnd, "msg_total", st->msg_total); hdf_set_int_value(q->hdfsnd, "msg_unrec", st->msg_unrec); hdf_set_int_value(q->hdfsnd, "msg_badparam", st->msg_badparam); hdf_set_int_value(q->hdfsnd, "msg_stats", st->msg_stats); hdf_set_int_value(q->hdfsnd, "proc_suc", st->proc_suc); hdf_set_int_value(q->hdfsnd, "proc_fai", st->proc_fai); break; default: st->msg_unrec++; err = nerr_raise(REP_ERR_UNKREQ, "unknown command %u", q->operation); break; } NEOERR *neede = mcs_err_valid(err); ret = neede ? neede->error : REP_OK; if (PROCESS_OK(ret)) { st->proc_suc++; } else { st->proc_fai++; if (ret == REP_ERR_BADPARAM) { st->msg_badparam++; } TRACE_ERR(q, ret, err); } if (q->req->flags & FLAGS_SYNC) { reply_trigger(q, ret); } }
static void aux_process_driver(EventEntry *entry, QueueEntry *q) { struct aux_entry *e = (struct aux_entry*)entry; NEOERR *err; int ret; struct aux_stats *st = &(e->st); st->msg_total++; mtc_dbg("process cmd %u", q->operation); switch (q->operation) { CASE_SYS_CMD(q->operation, q, e->cd, err); case REQ_CMD_CMT_GET: err = aux_cmd_cmtget(e, q); break; case REQ_CMD_CMT_ADD: err = aux_cmd_cmtadd(e, q); break; case REQ_CMD_CMT_DEL: err = aux_cmd_cmtdel(e, q); break; case REQ_CMD_MEMORY_GET: err = aux_cmd_memoryget(e, q); break; case REQ_CMD_MEMORY_ADD: err = aux_cmd_memoryadd(e, q); break; case REQ_CMD_MEMORY_MOD: err = aux_cmd_memorymod(e, q); break; case REQ_CMD_AUX_EMAIL_ADD: err = aux_cmd_emailadd(e, q); break; case REQ_CMD_AUX_INBOX_ADD: err = aux_cmd_inboxadd(e, q); break; case REQ_CMD_STATS: st->msg_stats++; err = STATUS_OK; hdf_set_int_value(q->hdfsnd, "msg_total", st->msg_total); hdf_set_int_value(q->hdfsnd, "msg_unrec", st->msg_unrec); hdf_set_int_value(q->hdfsnd, "msg_badparam", st->msg_badparam); hdf_set_int_value(q->hdfsnd, "msg_stats", st->msg_stats); hdf_set_int_value(q->hdfsnd, "proc_suc", st->proc_suc); hdf_set_int_value(q->hdfsnd, "proc_fai", st->proc_fai); break; default: st->msg_unrec++; err = nerr_raise(REP_ERR_UNKREQ, "unknown command %u", q->operation); break; } NEOERR *neede = mcs_err_valid(err); ret = neede ? neede->error : REP_OK; if (PROCESS_OK(ret)) { st->proc_suc++; } else { st->proc_fai++; if (ret == REP_ERR_BADPARAM) { st->msg_badparam++; } TRACE_ERR(q, ret, err); } if (q->req->flags & FLAGS_SYNC) { reply_trigger(q, ret); } }