MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / handle_cmd_reply

Function handle_cmd_reply

modules/event_stream/stream_send.c:442–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

440}
441
442static int handle_cmd_reply(struct stream_con *con, cJSON *reply)
443{
444 struct jsonrpc_cmd *cmd;
445 struct list_head *it, *tmp;
446 cJSON *aux;
447 int id;
448 int ret;
449
450 /* check if it has a proper id */
451 aux = cJSON_GetObjectItem(reply, "id");
452 if (!aux) {
453 LM_ERR("reply does not have an ID!\n");
454 return -1;
455 }
456 if (aux->type != cJSON_Number) {
457 LM_ERR("json does not have an integer id!\n");
458 return -1;
459 }
460 id = aux->valueint;
461
462 /* now check if there is an error */
463 aux = cJSON_GetObjectItem(reply, "error");
464 ret = (aux ? EVI_STATUS_FAIL : EVI_STATUS_SUCCESS);
465
466 /* XXX: should we check the version too?! */
467
468 /* in sync mode, we need to send back error */
469 list_for_each_safe(it, tmp, &con->cmds) {
470 cmd = list_entry(it, struct jsonrpc_cmd, list);
471 if (id != cmd->job->id)
472 continue;
473 if (cmd->job->async_ctx.status_cb)
474 stream_dispatch_status_cb(&cmd->job->async_ctx, ret);
475 list_del(&cmd->list);
476 jsonrpc_cmd_free(cmd);
477 /* all good */
478 return 0;
479 }
480
481 LM_INFO("no pending queries with id %d found!\n", id);
482 return 0;
483}
484
485static void handle_reply_jsonrpc(struct stream_con *con)
486{

Callers 1

handle_reply_jsonrpcFunction · 0.85

Calls 6

list_for_each_safeFunction · 0.85
list_delFunction · 0.85
jsonrpc_cmd_freeFunction · 0.85
cJSON_GetObjectItemFunction · 0.50
list_entryClass · 0.50

Tested by

no test coverage detected