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/.
lynxis lazus gerrit-no-reply at lists.osmocom.orglynxis lazus has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/21751 ) Change subject: gprs_ns2: fr: implement a write queue ...................................................................... gprs_ns2: fr: implement a write queue Related: SYS#5228 Change-Id: Id6eba04d5fb744f791b333c168729bbbd28cabd9 --- M src/gb/gprs_ns2_fr.c 1 file changed, 19 insertions(+), 29 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c index 782e5a3..5b54b48 100644 --- a/src/gb/gprs_ns2_fr.c +++ b/src/gb/gprs_ns2_fr.c @@ -50,6 +50,7 @@ #include <osmocom/core/select.h> #include <osmocom/core/socket.h> #include <osmocom/core/talloc.h> +#include <osmocom/core/write_queue.h> #include <osmocom/gprs/gprs_ns2.h> #ifdef ENABLE_LIBMNL @@ -83,9 +84,9 @@ }; struct priv_bind { - struct osmo_fd fd; char netif[IF_NAMESIZE]; struct osmo_fr_link *link; + struct osmo_wqueue wqueue; int ifindex; bool if_running; }; @@ -142,7 +143,7 @@ OSMO_ASSERT(llist_empty(&bind->nsvc)); osmo_fr_link_free(priv->link); - osmo_fd_close(&priv->fd); + osmo_fd_close(&priv->wqueue.bfd); talloc_free(priv); } @@ -238,22 +239,9 @@ return rc; } -static int handle_netif_write(struct osmo_fd *bfd) +static int handle_netif_write(struct osmo_fd *ofd, struct msgb *msg) { - /* FIXME */ - return -EIO; -} - -static int fr_fd_cb(struct osmo_fd *bfd, unsigned int what) -{ - int rc = 0; - - if (what & OSMO_FD_READ) - rc = handle_netif_read(bfd); - if (what & OSMO_FD_WRITE) - rc = handle_netif_write(bfd); - - return rc; + return write(ofd->fd, msgb_data(msg), msgb_length(msg)); } /*! determine if given bind is for FR-GRE encapsulation. */ @@ -276,13 +264,15 @@ { struct gprs_ns2_vc_bind *bind = data; struct priv_bind *priv = bind->priv; - int rc; - /* FIXME half writes */ - rc = write(priv->fd.fd, msg->data, msg->len); - msgb_free(msg); + if (osmo_wqueue_enqueue(&priv->wqueue, msg)) { + LOGP(DLNS, LOGL_ERROR, "frame relay %s: failed to enqueue message\n", + priv->netif); + msgb_free(msg); + return -EINVAL; + } - return rc; + return 0; } static int devname2ifindex(const char *ifname) @@ -491,8 +481,6 @@ goto err_name; } - priv->fd.cb = fr_fd_cb; - priv->fd.data = bind; if (strlen(netif) > IF_NAMESIZE) { rc = -EINVAL; goto err_priv; @@ -519,12 +507,14 @@ goto err_fr; } - priv->fd.fd = rc = open_socket(priv->ifindex); + rc = open_socket(priv->ifindex); if (rc < 0) goto err_fr; - - priv->fd.when = OSMO_FD_READ; - rc = osmo_fd_register(&priv->fd); + osmo_wqueue_init(&priv->wqueue, 10); + priv->wqueue.write_cb = handle_netif_write; + priv->wqueue.read_cb = handle_netif_read; + osmo_fd_setup(&priv->wqueue.bfd, rc, OSMO_FD_READ, osmo_wqueue_bfd_cb, bind, 0); + rc = osmo_fd_register(&priv->wqueue.bfd); if (rc < 0) goto err_fd; @@ -544,7 +534,7 @@ return rc; err_fd: - close(priv->fd.fd); + close(priv->wqueue.bfd.fd); err_fr: osmo_fr_link_free(fr_link); err_priv: -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/21751 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Id6eba04d5fb744f791b333c168729bbbd28cabd9 Gerrit-Change-Number: 21751 Gerrit-PatchSet: 3 Gerrit-Owner: lynxis lazus <lynxis at fe80.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann at sysmocom.de> Gerrit-Reviewer: laforge <laforge at osmocom.org> Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu> Gerrit-Reviewer: pespin <pespin at sysmocom.de> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201221/8248b096/attachment.htm>