Module: kamailio Branch: 6.0 Commit: ccd5708cb02cdc3e6cf76224417c7d04ba30f6e9 URL: https://github.com/kamailio/kamailio/commit/ccd5708cb02cdc3e6cf76224417c7d04ba30f6e9
Author: Daniel-Constantin Mierla <mico...@gmail.com> Committer: Daniel-Constantin Mierla <mico...@gmail.com> Date: 2025-01-29T08:07:12+01:00 dspatcher: return the new ds dest for add_dest2list() - easier to access the fields of the new record afterwards (cherry picked from commit cff6f9fd7051f4b8ac6e4fc59257c239cb32f21d) --- Modified: src/modules/dispatcher/dispatch.c --- Diff: https://github.com/kamailio/kamailio/commit/ccd5708cb02cdc3e6cf76224417c7d04ba30f6e9.diff Patch: https://github.com/kamailio/kamailio/commit/ccd5708cb02cdc3e6cf76224417c7d04ba30f6e9.patch --- diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c index 1d85c34203e..b404ede384b 100644 --- a/src/modules/dispatcher/dispatch.c +++ b/src/modules/dispatcher/dispatch.c @@ -713,7 +713,7 @@ ds_dest_t *pack_dest(str iuri, int flags, int priority, str *attrs, int dload) /** * */ -int add_dest2list(int id, str uri, int flags, int priority, str *attrs, +ds_dest_t *add_dest2list(int id, str uri, int flags, int priority, str *attrs, int list_idx, int *setn, int dload, ds_latency_stats_t *latency_stats) { ds_dest_t *dp = NULL; @@ -722,8 +722,9 @@ int add_dest2list(int id, str uri, int flags, int priority, str *attrs, ds_dest_t *dp1 = NULL; dp = pack_dest(uri, flags, priority, attrs, dload); - if(!dp) - goto err; + if(!dp) { + goto error; + } if(latency_stats != NULL) { dp->latency_stats.stdev = latency_stats->stdev; @@ -739,7 +740,7 @@ int add_dest2list(int id, str uri, int flags, int priority, str *attrs, sp = ds_avl_insert(&ds_lists[list_idx], id, setn); if(!sp) { LM_ERR("no more memory.\n"); - goto err; + goto error; } sp->nr++; @@ -766,8 +767,8 @@ int add_dest2list(int id, str uri, int flags, int priority, str *attrs, LM_DBG("dest [%d/%d] <%.*s>\n", sp->id, sp->nr, dp->uri.len, dp->uri.s); - return 0; -err: + return dp; +error: if(dp != NULL) { if(dp->uri.s != NULL) shm_free(dp->uri.s); @@ -776,7 +777,7 @@ int add_dest2list(int id, str uri, int flags, int priority, str *attrs, shm_free(dp); } - return -1; + return NULL; } @@ -1112,7 +1113,7 @@ int ds_load_list(char *lfile) } if(add_dest2list(id, uri, flags, priority, &attrs, *ds_next_idx, &setn, 0, latency_stats) - != 0) { + == NULL) { LM_WARN("unable to add destination %.*s to set %d -- skipping\n", uri.len, uri.s, id); if(ds_load_mode == 1) { @@ -1372,7 +1373,7 @@ int ds_load_db(void) } if(add_dest2list(id, uri, flags, priority, &attrs, *ds_next_idx, &setn, 0, latency_stats) - != 0) { + == NULL) { dest_errs++; LM_WARN("unable to add destination %.*s to set %d -- skipping\n", uri.len, uri.s, id); @@ -2870,7 +2871,7 @@ void ds_add_dest_cb(ds_set_t *node, int i, void *arg) node->dlist[i].priority, &node->dlist[i].attrs.body, *ds_next_idx, &setn, node->dlist[i].dload, &node->dlist[i].latency_stats) - != 0) { + == NULL) { LM_WARN("failed to add destination in group %d - %.*s\n", node->id, node->dlist[i].uri.len, node->dlist[i].uri.s); } @@ -2893,7 +2894,7 @@ int ds_add_dst(int group, str *address, int flags, int priority, str *attrs) // add new destination if(add_dest2list(group, *address, flags, priority, attrs, *ds_next_idx, &setn, 0, NULL) - != 0) { + == NULL) { LM_WARN("unable to add destination %.*s to set %d", address->len, address->s, group); if(ds_load_mode == 1) { @@ -2934,7 +2935,7 @@ void ds_filter_dest_cb(ds_set_t *node, int i, void *arg) node->dlist[i].priority, &node->dlist[i].attrs.body, *ds_next_idx, filter_arg->setn, node->dlist[i].dload, &node->dlist[i].latency_stats) - != 0) { + == NULL) { LM_WARN("failed to add destination in group %d - %.*s\n", node->id, node->dlist[i].uri.len, node->dlist[i].uri.s); } _______________________________________________ Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org To unsubscribe send an email to sr-dev-le...@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!