| 706 | } |
| 707 | |
| 708 | static int mi_script_async_func(struct sip_msg *msg, async_ctx *ctx, |
| 709 | str *m, pv_spec_p r, pv_spec_p p, pv_spec_p v) |
| 710 | { |
| 711 | struct mi_cmd *cmd = NULL; |
| 712 | struct mi_script_async_job *job; |
| 713 | mi_request_t *req; |
| 714 | str method, params; |
| 715 | int fd; |
| 716 | pv_value_t val; |
| 717 | char *err = "unknown error"; |
| 718 | |
| 719 | mi_script_get_method(m, &method, ¶ms); |
| 720 | |
| 721 | cmd = lookup_mi_cmd(method.s, method.len); |
| 722 | if (!cmd) |
| 723 | return -1; |
| 724 | |
| 725 | req = mi_script_parse_request(&method, ¶ms, p, v, 1); |
| 726 | if (!req) { |
| 727 | err = "could not parse parameters"; |
| 728 | goto error; |
| 729 | } |
| 730 | fd = eventfd(0, 0); |
| 731 | if (fd < 0) { |
| 732 | err = "could not create event descriptor"; |
| 733 | goto error; |
| 734 | } |
| 735 | job = shm_malloc(sizeof *job); |
| 736 | if (!job) { |
| 737 | err = "could not create new job"; |
| 738 | goto error; |
| 739 | } |
| 740 | memset(job, 0, sizeof *job); |
| 741 | |
| 742 | async_status = fd; |
| 743 | ASYNC_SET_RESUME_F(ctx, mi_script_async_resume); |
| 744 | ctx->resume_param = job; |
| 745 | |
| 746 | job->ret = r; |
| 747 | job->fd = fd; |
| 748 | job->cmd = cmd; |
| 749 | job->req = req; |
| 750 | job->process_no = process_no; |
| 751 | |
| 752 | if (ipc_dispatch_rpc(mi_script_async_start_job, job) < 0) { |
| 753 | err = "could not dispatch job"; |
| 754 | shm_free(job); |
| 755 | goto close; |
| 756 | } |
| 757 | return 1; |
| 758 | |
| 759 | close: |
| 760 | close(fd); |
| 761 | error: |
| 762 | LM_ERR("%s!\n", err); |
| 763 | if (r) { |
| 764 | init_str(&val.rs, err); |
| 765 | val.flags = PV_VAL_STR; |
nothing calls this directly
no test coverage detected