This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Hoernchen gerrit-no-reply at lists.osmocom.orgHoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/25423 ) Change subject: libosmo-mgcp: do not use the default msgb talloc context ...................................................................... libosmo-mgcp: do not use the default msgb talloc context Trunk is safe, since it will not disappear sooner than the endpoints or connections. osmux still missing! Change-Id: I15b01085f31e9a10a1ad381713ca2275356ca20c --- M src/libosmo-mgcp/mgcp_e1.c M src/libosmo-mgcp/mgcp_network.c M src/libosmo-mgcp/mgcp_protocol.c 3 files changed, 21 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/23/25423/1 diff --git a/src/libosmo-mgcp/mgcp_e1.c b/src/libosmo-mgcp/mgcp_e1.c index effbe77..e88b8c5 100644 --- a/src/libosmo-mgcp/mgcp_e1.c +++ b/src/libosmo-mgcp/mgcp_e1.c @@ -192,7 +192,7 @@ { struct mgcp_endpoint *endp = user_data; struct rate_ctr_group *rate_ctrs = endp->trunk->ratectr.e1_stats; - struct msgb *msg = msgb_alloc(E1_TRAU_BITS_MSGB, "E1-I.460-IDLE-TX-TRAU-frame"); + struct msgb *msg = msgb_alloc_c(endp->trunk, E1_TRAU_BITS_MSGB, "E1-I.460-IDLE-TX-TRAU-frame"); uint8_t *ptr; const uint8_t *ptr_ft; enum osmo_trau_frame_type ft; @@ -238,9 +238,9 @@ * (the resulting frame will be prepended with an all-zero (12-byte) rtp header) */ static void sync_frame_out_cb(void *user_data, const ubit_t *bits, unsigned int num_bits) { - struct msgb *msg = msgb_alloc(RTP_BUF_SIZE, "RTP-rx-from-E1"); unsigned int rtp_hdr_len = sizeof(struct rtp_hdr); struct mgcp_endpoint *endp = user_data; + struct msgb *msg = msgb_alloc_c(endp->trunk, RTP_BUF_SIZE, "RTP-rx-from-E1"); struct rate_ctr_group *rate_ctrs = endp->trunk->ratectr.e1_stats; struct mgcp_conn *conn_dst; struct osmo_trau_frame fr; @@ -312,7 +312,7 @@ /* Function to handle outgoing E1 traffic */ static void e1_send(struct e1inp_ts *ts, struct mgcp_trunk *trunk) { - struct msgb *msg = msgb_alloc(E1_TS_BYTES, "E1-TX-timeslot-bytes"); + struct msgb *msg = msgb_alloc_c(trunk, E1_TS_BYTES, "E1-TX-timeslot-bytes"); uint8_t *ptr; /* Get E1 frame from I.460 multiplexer */ @@ -622,7 +622,7 @@ * \returns 0 on success, -1 on ERROR. */ int mgcp_e1_send_rtp(struct mgcp_endpoint *endp, struct mgcp_rtp_codec *codec, struct msgb *msg) { - struct msgb *msg_tf = msgb_alloc(E1_TRAU_BITS_MSGB, "E1-I.460-TX-TRAU-frame"); + struct msgb *msg_tf = msgb_alloc_c(endp->trunk, E1_TRAU_BITS_MSGB, "E1-I.460-TX-TRAU-frame"); struct rate_ctr_group *rate_ctrs = endp->trunk->ratectr.e1_stats; unsigned int rtp_hdr_len = sizeof(struct rtp_hdr); struct osmo_trau_frame tf; diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c index cb82137..86b0d06 100644 --- a/src/libosmo-mgcp/mgcp_network.c +++ b/src/libosmo-mgcp/mgcp_network.c @@ -1448,13 +1448,14 @@ int ret; enum rtp_proto proto; struct osmo_rtp_msg_ctx *mc; - struct msgb *msg = msgb_alloc(RTP_BUF_SIZE, "RTP-rx"); + struct msgb *msg; int rc; conn_src = (struct mgcp_conn_rtp *)fd->data; OSMO_ASSERT(conn_src); endp = conn_src->conn->endp; OSMO_ASSERT(endp); + msg = msgb_alloc_c(endp->trunk, RTP_BUF_SIZE, "RTP-rx"); proto = (fd == &conn_src->end.rtp)? MGCP_PROTO_RTP : MGCP_PROTO_RTCP; diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index ba80d7d..a8e1813 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -172,12 +172,18 @@ } /* Helper function to allocate some memory for responses and retransmissions */ -static struct msgb *mgcp_msgb_alloc(void) +static struct msgb *mgcp_msgb_alloc(void* ctx) { struct msgb *msg; - msg = msgb_alloc_headroom(4096, 128, "MGCP msg"); - if (!msg) + msg = msgb_alloc_c(ctx, 4096, "MGCP msg"); + + if (!msg) { LOGP(DLMGCP, LOGL_ERROR, "Failed to msgb for MGCP data.\n"); + return NULL; + } + + /* headroom */ + msgb_reserve(msg, 128); return msg; } @@ -185,7 +191,7 @@ /* Helper function for do_retransmission() and create_resp() */ static struct msgb *create_retransmission_response(const struct mgcp_endpoint *endp) { - struct msgb *msg = mgcp_msgb_alloc(); + struct msgb *msg = mgcp_msgb_alloc(endp->trunk); if (!msg) return NULL; @@ -203,7 +209,7 @@ int len; struct msgb *res; - res = mgcp_msgb_alloc(); + res = mgcp_msgb_alloc(endp->trunk); if (!res) return NULL; @@ -277,10 +283,13 @@ int rc; struct msgb *result; - sdp = msgb_alloc_headroom(4096, 128, "sdp record"); + sdp = msgb_alloc_c(endp->trunk, 4096, "sdp record"); if (!sdp) return NULL; + /* headroom */ + msgb_reserve(sdp, 128); + /* Attach optional endpoint name */ if (add_epname) { rc = msgb_printf(sdp, "Z: %s\r\n", endp->name); -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/25423 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: I15b01085f31e9a10a1ad381713ca2275356ca20c Gerrit-Change-Number: 25423 Gerrit-PatchSet: 1 Gerrit-Owner: Hoernchen <ewild at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210909/b3b25465/attachment.htm>