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/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/26365 ) Change subject: gsmtap: Add gsmtap_sendmsg_free() as alternative to gsmtap_sendmsg() ...................................................................... gsmtap: Add gsmtap_sendmsg_free() as alternative to gsmtap_sendmsg() gsmtap_sendmsg() places the burden of freeing the msgb in case of erroneous return codes on the caller. A review of existing users shows that this is overly optimistic and many calls get it wrong, opening up memory leaks. Let's add a new function gsmtap_sendmsg_free() which behaves like gsmtap_sendmsg() but always takes ownership: Either it is sent + freed, or it is just freed. Change-Id: I106b09f2a49bf24ce0e8d11fd4d4ee93e9cafdf5 Related: OS#5329 --- M include/osmocom/core/gsmtap_util.h M src/gsmtap_util.c 2 files changed, 21 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/65/26365/1 diff --git a/include/osmocom/core/gsmtap_util.h b/include/osmocom/core/gsmtap_util.h index e564326..1cc8d75 100644 --- a/include/osmocom/core/gsmtap_util.h +++ b/include/osmocom/core/gsmtap_util.h @@ -48,6 +48,7 @@ int gsmtap_source_add_sink(struct gsmtap_inst *gti); int gsmtap_sendmsg(struct gsmtap_inst *gti, struct msgb *msg); +int gsmtap_sendmsg_free(struct gsmtap_inst *gti, struct msgb *msg); int gsmtap_send_ex(struct gsmtap_inst *gti, uint8_t type, uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, uint32_t fn, diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c index 9ae06d6..cbf1e1e 100644 --- a/src/gsmtap_util.c +++ b/src/gsmtap_util.c @@ -304,9 +304,12 @@ if (!gti) return -ENODEV; - if (gti->ofd_wq_mode) - return osmo_wqueue_enqueue(>i->wq, msg); - else { + if (gti->ofd_wq_mode) { + int rc = osmo_wqueue_enqueue(>i->wq, msg); + if (rc < 0) + msgb_free(msg); + return rc; + } else { /* try immediate send and return error if any */ int rc; @@ -323,6 +326,20 @@ } } +/*! Send a \ref msgb through a GSMTAP source; free the message if tx queue full. + * \param[in] gti GSMTAP instance + * \param[in] msg message buffer + * \return 0 in case of success; negative in case of error + */ +int gsmtap_sendmsg_free(struct gsmtap_inst *gti, struct msgb *msg) +{ + int rc; + rc = gsmtap_sendmsg(gti, msg); + if (rc < 0) + msgb_free(msg); + return rc; +} + /*! send an arbitrary type through GSMTAP. * See \ref gsmtap_makemsg_ex for arguments */ -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/26365 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I106b09f2a49bf24ce0e8d11fd4d4ee93e9cafdf5 Gerrit-Change-Number: 26365 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge at osmocom.org> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211125/6658b529/attachment.htm>