diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-07-22 15:00:52 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-07-22 15:00:52 +0200 |
commit | cb6ad70994dc7686f1c89d803fcca1081b5ef32b (patch) | |
tree | 2cca0df46b85af353b579cf8335d586fb03e9147 /openbsc/src | |
parent | 34a1976d5d3791501ee57404629a849dce181b0b (diff) |
mgcp: Change API to remove memory management from the name
Jacob pointed out that "free_endp" refers to the memory of
the endpoint being freed. What we want is actually a way to
release an endpoint (and the resource it allocated) or in
the case of the testcase/testapp initialize the data structure
correctly. Introduce two names for that.
Diffstat (limited to 'openbsc/src')
-rw-r--r-- | openbsc/src/libmgcp/mgcp_protocol.c | 17 | ||||
-rw-r--r-- | openbsc/src/libmgcp/mgcp_vty.c | 2 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc_mgcp/mgcp_main.c | 2 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c | 6 |
4 files changed, 16 insertions, 11 deletions
diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c index f25c1faa9..1198c24a6 100644 --- a/openbsc/src/libmgcp/mgcp_protocol.c +++ b/openbsc/src/libmgcp/mgcp_protocol.c @@ -940,7 +940,7 @@ mgcp_header_done: if (tcfg->force_realloc) { LOGP(DMGCP, LOGL_NOTICE, "Endpoint 0x%x already allocated. Forcing realloc.\n", ENDPOINT_NUMBER(endp)); - mgcp_free_endp(endp); + mgcp_release_endp(endp); if (p->cfg->realloc_cb) p->cfg->realloc_cb(tcfg, ENDPOINT_NUMBER(endp)); } else { @@ -1006,7 +1006,7 @@ mgcp_header_done: case MGCP_POLICY_REJECT: LOGP(DMGCP, LOGL_NOTICE, "CRCX rejected by policy on 0x%x\n", ENDPOINT_NUMBER(endp)); - mgcp_free_endp(endp); + mgcp_release_endp(endp); return create_err_response(endp, 400, "CRCX", p->trans); break; case MGCP_POLICY_DEFER: @@ -1033,7 +1033,7 @@ mgcp_header_done: create_transcoder(endp); return create_response_with_sdp(endp, "CRCX", p->trans); error2: - mgcp_free_endp(endp); + mgcp_release_endp(endp); LOGP(DMGCP, LOGL_NOTICE, "Resource error on 0x%x\n", ENDPOINT_NUMBER(endp)); return create_err_response(endp, error_code, "CRCX", p->trans); } @@ -1248,7 +1248,7 @@ static struct msgb *handle_delete_con(struct mgcp_parse_data *p) mgcp_format_stats(endp, stats, sizeof(stats)); delete_transcoder(endp); - mgcp_free_endp(endp); + mgcp_release_endp(endp); if (p->cfg->change_cb) p->cfg->change_cb(endp->tcfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_DLCX); @@ -1488,9 +1488,9 @@ int mgcp_endpoints_allocate(struct mgcp_trunk_config *tcfg) return 0; } -void mgcp_free_endp(struct mgcp_endpoint *endp) +void mgcp_release_endp(struct mgcp_endpoint *endp) { - LOGP(DMGCP, LOGL_DEBUG, "Deleting endpoint on: 0x%x\n", ENDPOINT_NUMBER(endp)); + LOGP(DMGCP, LOGL_DEBUG, "Releasing endpoint on: 0x%x\n", ENDPOINT_NUMBER(endp)); endp->ci = CI_UNUSED; endp->allocated = 0; @@ -1516,6 +1516,11 @@ void mgcp_free_endp(struct mgcp_endpoint *endp) memset(&endp->taps, 0, sizeof(endp->taps)); } +void mgcp_initialize_endp(struct mgcp_endpoint *endp) +{ + return mgcp_release_endp(endp); +} + static int send_trans(struct mgcp_config *cfg, const char *buf, int len) { struct sockaddr_in addr; diff --git a/openbsc/src/libmgcp/mgcp_vty.c b/openbsc/src/libmgcp/mgcp_vty.c index 42d99e784..86336680c 100644 --- a/openbsc/src/libmgcp/mgcp_vty.c +++ b/openbsc/src/libmgcp/mgcp_vty.c @@ -1047,7 +1047,7 @@ DEFUN(free_endp, free_endp_cmd, } endp = &trunk->endpoints[endp_no]; - mgcp_free_endp(endp); + mgcp_release_endp(endp); return CMD_SUCCESS; } diff --git a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c index 8c3808a28..16fb72231 100644 --- a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c +++ b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c @@ -181,7 +181,7 @@ static int read_call_agent(struct osmo_fd *fd, unsigned int what) /* is checking in_addr.s_addr == INADDR_LOOPBACK making it more secure? */ for (i = 1; i < reset_trunk->number_endpoints; ++i) - mgcp_free_endp(&reset_trunk->endpoints[i]); + mgcp_release_endp(&reset_trunk->endpoints[i]); } return 0; diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c index e13827b0b..4a0aaffd7 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c @@ -251,7 +251,7 @@ void bsc_mgcp_free_endpoints(struct bsc_nat *nat) for (i = 1; i < nat->mgcp_cfg->trunk.number_endpoints; ++i){ bsc_mgcp_free_endpoint(nat, i); - mgcp_free_endp(&nat->mgcp_cfg->trunk.endpoints[i]); + mgcp_release_endp(&nat->mgcp_cfg->trunk.endpoints[i]); } } @@ -621,7 +621,7 @@ static void free_chan_downstream(struct mgcp_endpoint *endp, struct bsc_endpoint } bsc_mgcp_free_endpoint(bsc->nat, ENDPOINT_NUMBER(endp)); - mgcp_free_endp(endp); + mgcp_release_endp(endp); } /* @@ -1065,6 +1065,6 @@ void bsc_mgcp_clear_endpoints_for(struct bsc_connection *bsc) rate_ctr_inc(ctr); bsc_mgcp_free_endpoint(bsc->nat, i); - mgcp_free_endp(&bsc->nat->mgcp_cfg->trunk.endpoints[i]); + mgcp_release_endp(&bsc->nat->mgcp_cfg->trunk.endpoints[i]); } } |