[M] Change in libosmocore[master]: gsmtap_util: Simplify sink
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/34881?usp=email ) Change subject: gsmtap_util: Simplify sink .. gsmtap_util: Simplify sink - Instead of using the osmo_fd API to call read() on the socket's file descriptor each time (unused) data is received, simply open the socket and never read Related: OS#6213 Change-Id: I4025920d5f62d17133e9b5fe81cd34a88c4f20b5 --- M src/core/gsmtap_util.c 1 file changed, 21 insertions(+), 43 deletions(-) Approvals: daniel: Looks good to me, but someone else must approve laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/core/gsmtap_util.c b/src/core/gsmtap_util.c index 458d1d7..d817885 100644 --- a/src/core/gsmtap_util.c +++ b/src/core/gsmtap_util.c @@ -58,7 +58,7 @@ struct osmo_wqueue wq;/*!< the wait queue. This field member may not be changed or moved (backwards compatibility) */ struct osmo_io_fd *out; /*!< Used when osmo_io_mode is nonzero */ - struct osmo_fd sink_ofd; + int sink_fd; }; struct _gsmtap_inst_legacy { @@ -433,22 +433,6 @@ signal_dbm, snr, data, len); } -/* Callback from select layer if we can read from the sink socket */ -static int gsmtap_sink_fd_cb(struct osmo_fd *fd, unsigned int flags) -{ - int rc; - uint8_t buf[4096]; - if (!(flags & OSMO_FD_READ)) - return 0; - - rc = read(fd->fd, buf, sizeof(buf)); - if (rc < 0) - return rc; - /* simply discard any data arriving on the socket */ - - return 0; -} - /*! Add a local sink to an existing GSMTAP source and return fd * \param[in] gti existing GSMTAP source * \returns file descriptor of locally bound receive socket @@ -466,28 +450,7 @@ */ int gsmtap_source_add_sink(struct gsmtap_inst *gti) { - int fd, rc; - - fd = gsmtap_source_add_sink_fd(gsmtap_inst_fd2(gti)); - if (fd < 0) - return fd; - - if (gti->osmo_io_mode) { - struct osmo_fd *sink_ofd; - - sink_ofd = >sink_ofd; - sink_ofd->fd = fd; - sink_ofd->when = OSMO_FD_READ; - sink_ofd->cb = gsmtap_sink_fd_cb; - - rc = osmo_fd_register(sink_ofd); - if (rc < 0) { - close(fd); - return rc; - } - } - - return fd; + return gti->sink_fd = gsmtap_source_add_sink_fd(gsmtap_inst_fd2(gti)); } /* Registered in Osmo IO as a no-op to set the write callback. */ @@ -524,7 +487,7 @@ gti->osmo_io_mode = ofd_wq_mode; /* Still using the wq member for its 'fd' field only, since we are keeping it for now, anyways */ gti->wq.bfd.fd = fd; - gti->sink_ofd.fd = -1; + gti->sink_fd = -1; if (ofd_wq_mode) { gti->out = osmo_iofd_setup(gti, gti->wq.bfd.fd, "gsmtap_inst.io_fd", OSMO_IO_FD_MODE_READ_WRITE, _ops, NULL); @@ -564,10 +527,11 @@ if (gti->osmo_io_mode) { osmo_iofd_free(gti->out); - if (gti->sink_ofd.fd != -1) { - osmo_fd_unregister(>sink_ofd); - close(gti->sink_ofd.fd); + if (gti->sink_fd != -1) { + close(gti->sink_fd); + gti->sink_fd = -1; } + } talloc_free(gti); -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34881?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I4025920d5f62d17133e9b5fe81cd34a88c4f20b5 Gerrit-Change-Number: 34881 Gerrit-PatchSet: 5 Gerrit-Owner: arehbein Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: laforge Gerrit-MessageType: merged
[M] Change in libosmocore[master]: gsmtap_util: Simplify sink
Attention is currently required from: arehbein. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/34881?usp=email ) Change subject: gsmtap_util: Simplify sink .. Patch Set 5: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34881?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I4025920d5f62d17133e9b5fe81cd34a88c4f20b5 Gerrit-Change-Number: 34881 Gerrit-PatchSet: 5 Gerrit-Owner: arehbein Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: laforge Gerrit-Attention: arehbein Gerrit-Comment-Date: Wed, 15 Nov 2023 21:29:25 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmocore[master]: gsmtap_util: Simplify sink
Attention is currently required from: arehbein. daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/34881?usp=email ) Change subject: gsmtap_util: Simplify sink .. Patch Set 4: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34881?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I4025920d5f62d17133e9b5fe81cd34a88c4f20b5 Gerrit-Change-Number: 34881 Gerrit-PatchSet: 4 Gerrit-Owner: arehbein Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: laforge Gerrit-Attention: arehbein Gerrit-Comment-Date: Tue, 14 Nov 2023 10:03:22 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmocore[master]: gsmtap_util: Simplify sink
Attention is currently required from: arehbein. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/34881?usp=email ) Change subject: gsmtap_util: Simplify sink .. Patch Set 4: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34881?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I4025920d5f62d17133e9b5fe81cd34a88c4f20b5 Gerrit-Change-Number: 34881 Gerrit-PatchSet: 4 Gerrit-Owner: arehbein Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Attention: arehbein Gerrit-Comment-Date: Thu, 09 Nov 2023 12:40:13 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmocore[master]: gsmtap_util: Simplify sink
Attention is currently required from: arehbein, laforge. arehbein has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/34881?usp=email ) Change subject: gsmtap_util: Simplify sink .. Set Ready For Review -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34881?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I4025920d5f62d17133e9b5fe81cd34a88c4f20b5 Gerrit-Change-Number: 34881 Gerrit-PatchSet: 4 Gerrit-Owner: arehbein Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Attention: arehbein Gerrit-Attention: laforge Gerrit-Comment-Date: Wed, 08 Nov 2023 18:16:34 + Gerrit-HasComments: No Gerrit-Has-Labels: No Gerrit-MessageType: comment
[M] Change in libosmocore[master]: gsmtap_util: Simplify sink
arehbein has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/34881?usp=email ) Change subject: gsmtap_util: Simplify sink .. gsmtap_util: Simplify sink Related: OS#6213 Change-Id: I4025920d5f62d17133e9b5fe81cd34a88c4f20b5 --- M src/core/gsmtap_util.c 1 file changed, 17 insertions(+), 43 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/81/34881/1 diff --git a/src/core/gsmtap_util.c b/src/core/gsmtap_util.c index 67baccc..effa499 100644 --- a/src/core/gsmtap_util.c +++ b/src/core/gsmtap_util.c @@ -58,7 +58,7 @@ struct osmo_wqueue wq;/*!< the wait queue. This field member may not be changed or moved (backwards compatibility) */ struct osmo_io_fd *out; /*!< Used when osmo_io_mode is nonzero */ - struct osmo_fd sink_ofd; + int sink_fd; }; struct _gsmtap_inst_legacy { @@ -433,22 +433,6 @@ signal_dbm, snr, data, len); } -/* Callback from select layer if we can read from the sink socket */ -static int gsmtap_sink_fd_cb(struct osmo_fd *fd, unsigned int flags) -{ - int rc; - uint8_t buf[4096]; - if (!(flags & OSMO_FD_READ)) - return 0; - - rc = read(fd->fd, buf, sizeof(buf)); - if (rc < 0) - return rc; - /* simply discard any data arriving on the socket */ - - return 0; -} - /*! Add a local sink to an existing GSMTAP source and return fd * \param[in] gti existing GSMTAP source * \returns file descriptor of locally bound receive socket @@ -466,28 +450,7 @@ */ int gsmtap_source_add_sink(struct gsmtap_inst *gti) { - int fd, rc; - - fd = gsmtap_source_add_sink_fd(gsmtap_inst_fd2(gti)); - if (fd < 0) - return fd; - - if (gti->osmo_io_mode) { - struct osmo_fd *sink_ofd; - - sink_ofd = >sink_ofd; - sink_ofd->fd = fd; - sink_ofd->when = OSMO_FD_READ; - sink_ofd->cb = gsmtap_sink_fd_cb; - - rc = osmo_fd_register(sink_ofd); - if (rc < 0) { - close(fd); - return rc; - } - } - - return fd; + return gti->sink_fd = gsmtap_source_add_sink_fd(gsmtap_inst_fd2(gti)); } /* Registered in Osmo IO as a no-op to set the write callback. */ @@ -524,7 +487,7 @@ gti->osmo_io_mode = ofd_wq_mode; /* Still using the wq member for its 'fd' field only, since we are keeping it for now, anyways */ gti->wq.bfd.fd = fd; - gti->sink_ofd.fd = -1; + gti->sink_fd = -1; if (ofd_wq_mode) { gti->out = osmo_iofd_setup(gti, gti->wq.bfd.fd, "gsmtap_inst.io_fd", OSMO_IO_FD_MODE_READ_WRITE, _ops, NULL); @@ -563,10 +526,11 @@ if (gti->osmo_io_mode) { osmo_iofd_free(gti->out); - if (gti->sink_ofd.fd != -1) { - osmo_fd_unregister(>sink_ofd); - close(gti->sink_ofd.fd); + if (gti->sink_fd != -1) { + close(gti->sink_fd); + gti->sink_fd = -1; } + } talloc_free(gti); -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34881?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I4025920d5f62d17133e9b5fe81cd34a88c4f20b5 Gerrit-Change-Number: 34881 Gerrit-PatchSet: 1 Gerrit-Owner: arehbein Gerrit-MessageType: newchange