Skip to content

Commit 335bd70

Browse files
committed
[dialog] added profiling on signaling API functions
1 parent abe6e02 commit 335bd70

8 files changed

Lines changed: 24 additions & 14 deletions

File tree

modules/callops/callops.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ static mi_response_t *mi_call_blind_transfer(const mi_params_t *params,
918918
call_transfer_dlg_callback, 0, 0);
919919
}
920920

921-
if (call_dlg_api.send_indialog_request(dlg, &refer,
921+
if (run_dlg_api(&call_dlg_api, send_indialog_request, dlg, &refer,
922922
(caller?DLG_CALLER_LEG:callee_idx(dlg)), NULL, NULL, refer_hdr,
923923
mi_call_transfer_reply, async_hdl, NULL) < 0) {
924924
LM_ERR("could not send the transfer message!\n");
@@ -1063,7 +1063,7 @@ static mi_response_t *mi_call_attended_transfer(const mi_params_t *params,
10631063
call_dlg_api.register_dlgcb(dlgA, DLGCB_REQ_WITHIN,
10641064
call_transfer_dlg_callback, 0, 0);
10651065

1066-
if (call_dlg_api.send_indialog_request(dlgA, &refer,
1066+
if (run_dlg_api(&call_dlg_api, send_indialog_request, dlgA, &refer,
10671067
(callerA?DLG_CALLER_LEG:callee_idx(dlgA)), NULL, NULL, refer_hdr,
10681068
mi_call_transfer_reply, async_hdl, NULL) < 0) {
10691069
LM_ERR("could not send the transfer message!\n");
@@ -1215,7 +1215,7 @@ static int call_put_leg_onhold(struct dlg_cell *dlg, int leg, unsigned mode, str
12151215
RAISE_CALL_EVENT(HOLD, &dlg->callid, &sleg, &action, &state, NULL);
12161216

12171217
/* send it out */
1218-
ret = call_dlg_api.send_indialog_request(dlg, &invite, leg, &body, &ct,
1218+
ret = run_dlg_api(&call_dlg_api, send_indialog_request, dlg, &invite, leg, &body, &ct,
12191219
hdrs, mi_call_hold_reply, (void *)(long)param, NULL);
12201220
pkg_free(body.s);
12211221
if (ret < 0) {
@@ -1276,7 +1276,7 @@ static int call_resume_leg_onhold(struct dlg_cell *dlg, int leg, unsigned mode,
12761276
param |= mode;
12771277

12781278
RAISE_CALL_EVENT(HOLD, &dlg->callid, &sleg, &action, &state, NULL);
1279-
if (call_dlg_api.send_indialog_request(dlg, &invite, leg, &body, &ct,
1279+
if (run_dlg_api(&call_dlg_api, send_indialog_request, dlg, &invite, leg, &body, &ct,
12801280
hdrs, mi_call_hold_reply, (void *)(long)param, NULL) < 0) {
12811281
init_str(&state, "fail");
12821282
RAISE_CALL_EVENT(HOLD, &dlg->callid, &sleg, &action, &state, NULL);
@@ -1533,7 +1533,7 @@ static int w_call_blind_transfer(struct sip_msg *req, int leg, str *dst)
15331533
call_transfer_dlg_callback, 0, 0);
15341534
}
15351535

1536-
if (call_dlg_api.send_indialog_request(dlg, &refer,
1536+
if (run_dlg_api(&call_dlg_api, send_indialog_request, dlg, &refer,
15371537
(leg == DLG_CALLER_LEG?DLG_CALLER_LEG:callee_idx(dlg)), NULL, NULL,
15381538
refer_hdr, mi_call_transfer_reply, NULL, NULL) < 0) {
15391539
LM_ERR("could not send the transfer message!\n");
@@ -1620,7 +1620,7 @@ static int w_call_attended_transfer(struct sip_msg *req, int leg,
16201620
call_dlg_api.register_dlgcb(dlgA, DLGCB_REQ_WITHIN,
16211621
call_transfer_dlg_callback, 0, 0);
16221622

1623-
if (call_dlg_api.send_indialog_request(dlgA, &refer,
1623+
if (run_dlg_api(&call_dlg_api, send_indialog_request, dlgA, &refer,
16241624
(leg == DLG_CALLER_LEG?DLG_CALLER_LEG:callee_idx(dlgA)), NULL, NULL,
16251625
refer_hdr, mi_call_transfer_reply, NULL, NULL) < 0) {
16261626
LM_ERR("could not send the transfer message!\n");

modules/cgrates/cgrates_acc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ static void cgr_tmcb_func(struct cell* t, int type, struct tmcb_params *ps)
10721072
/* TODO: should we close all the started sessions now? */
10731073
terminate_str.s = "CGRateS Accounting Denied";
10741074
terminate_str.len = strlen(terminate_str.s);
1075-
if (cgr_dlgb.terminate_dlg(NULL, dlg->h_entry, dlg->h_id, &terminate_str) >= 0)
1075+
if (run_dlg_api(&cgr_dlgb, terminate_dlg, NULL, dlg->h_entry, dlg->h_id, &terminate_str) >= 0)
10761076
return;
10771077
LM_ERR("cannot terminate the dialog!\n");
10781078
unref:
@@ -1425,7 +1425,7 @@ int cgr_acc_terminate(json_object *param, json_object **ret)
14251425
terminate_str.s = terminate_str_pre.s;
14261426
terminate_str.len = terminate_str_pre.len - 2 /* skip the ': ' */;
14271427
}
1428-
if (cgr_dlgb.terminate_dlg(NULL, h_entry, h_id, &terminate_str) < 0) {
1428+
if (run_dlg_api(&cgr_dlgb, terminate_dlg, NULL, h_entry, h_id, &terminate_str) < 0) {
14291429
if (terminate_str.s != terminate_str_pre.s)
14301430
pkg_free(terminate_str.s);
14311431
err = "cannot terminate dialog";

modules/dialog/dlg_load.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "dlg_handlers.h"
2828
#include "dlg_profile.h"
2929
#include "dlg_vals.h"
30+
#include "../../profiling.h"
3031
#include "../../sr_module.h"
3132

3233
typedef struct dlg_cell *(*get_dlg_f) (void);
@@ -102,5 +103,14 @@ static inline int load_dlg_api( struct dlg_binds *dlgb )
102103
return 0;
103104
}
104105

106+
#define run_dlg_api(_dlg_api, _api_func, _args...) \
107+
({ \
108+
typeof((_dlg_api)->_api_func(_args)) _dlg_api_rc; \
109+
profiling_proc_enter(#_api_func, 0); \
110+
_dlg_api_rc = (_dlg_api)->_api_func(_args); \
111+
profiling_proc_exit(#_api_func, (int)(intptr_t)_dlg_api_rc); \
112+
_dlg_api_rc; \
113+
})
114+
105115

106116
#endif

modules/media_exchange/media_exchange.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ static int media_exchange_to_call(struct sip_msg *msg, str *callid, int leg, int
871871

872872
/* all good - send the invite to the client */
873873
MSL_REF(msl);
874-
if (media_dlg.send_indialog_request(dlg, &inv, MEDIA_SESSION_DLG_LEG(msl), &body,
874+
if (run_dlg_api(&media_dlg, send_indialog_request, dlg, &inv, MEDIA_SESSION_DLG_LEG(msl), &body,
875875
&msg->content_type->body, NULL, media_session_exchange_server_reply, mslp,
876876
media_session_exchange_server_release) < 0) {
877877
LM_ERR("could not send indialog request for callid %.*s\n", callid->len, callid->s);
@@ -1292,7 +1292,7 @@ static void handle_media_session_negative(struct media_session_leg *msl)
12921292
body = NULL;
12931293
else
12941294
body = &sbody;
1295-
if (media_dlg.send_indialog_request(msl->ms->dlg,
1295+
if (run_dlg_api(&media_dlg, send_indialog_request, msl->ms->dlg,
12961296
&inv, dlg_leg, body, &content_type_sdp, NULL,
12971297
media_session_exchange_negative_reply, msl, NULL) < 0) {
12981298
LM_ERR("could not forward INVITE!\n");

modules/media_exchange/media_sessions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ int media_session_reinvite(struct media_session_leg *msl, int leg, str *body)
329329
}
330330
}
331331
}
332-
ret = media_dlg.send_indialog_request(msl->ms->dlg, &inv, leg, body, &content_type_sdp, NULL,
332+
ret = run_dlg_api(&media_dlg, send_indialog_request, msl->ms->dlg, &inv, leg, body, &content_type_sdp, NULL,
333333
(p?media_session_reinvite_reply:NULL),p, NULL);
334334
if (p && ret < 0) {
335335
MSL_UNREF(msl);

modules/rtp_relay/rtp_relay_ctx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2379,7 +2379,7 @@ static int rtp_relay_reinvite(struct rtp_relay_tmp *tmp, int leg,
23792379
static str inv = str_init("INVITE");
23802380
static str content_type_sdp = str_init("application/sdp");
23812381

2382-
int ret = rtp_relay_dlg.send_indialog_request(tmp->dlg,
2382+
int ret = run_dlg_api(&rtp_relay_dlg, send_indialog_request, tmp->dlg,
23832383
&inv, leg, body, &content_type_sdp, NULL,
23842384
rtp_relay_reinvite_reply, tmp, NULL);
23852385
if (body && release_body)

modules/rtpengine/rtpengine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1517,7 +1517,7 @@ static mi_response_t *mi_teardown_call(const mi_params_t *params,
15171517
/* try to "resolve" the callid first through rtp_relay */
15181518
if (!rtp_relay.get_dlg_ids || rtp_relay.get_dlg_ids(&callid, &h_entry, &h_id) == 0)
15191519
pcallid = &callid; /* search for callid, if dialog was not found */
1520-
if (dlgb.terminate_dlg(pcallid, h_entry, h_id, _str("MI Termination")) < 0)
1520+
if (run_dlg_api(&dlgb, terminate_dlg, pcallid, h_entry, h_id, _str("MI Termination")) < 0)
15211521
return init_mi_error(500, MI_SSTR("Failed to terminate dialog"));
15221522

15231523
return init_mi_result_ok();

modules/rtpproxy/notification_process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static int notification_handler(str *command)
8383
LM_INFO("Timeout notification for %.*s\n", param.len, param.s);
8484
if (parse_dlg_did(&param, &h_entry, &h_id) < 0)
8585
return -1;
86-
if(dlg_api.terminate_dlg(NULL, h_entry, h_id, &terminate_reason)< 0)
86+
if(run_dlg_api(&dlg_api, terminate_dlg, NULL, h_entry, h_id, &terminate_reason)< 0)
8787
LM_ERR("Failed to terminate dialog h_entry=[%u], h_id=[%u]\n", h_entry, h_id);
8888
return 0;
8989
case 'D':

0 commit comments

Comments
 (0)