osmith has uploaded this change for review.

View Change

io_uring: Avoid extra reads if iofd becomes unregistered by user

The user callback (read_cb, segmentation_cb, etc.) may decide to
unregister the iofd instead of closing it. In this scenario, we should
avoid calling the callback further until the iofd is registered again.

This is a backport of master branch commit
32efc324ce0b30280effef4860bb15588ecb1010.

Change-Id: I514412ecfbb82d32cb3d9c2272795ebac42f55e9
---
M src/core/osmo_io_uring.c
1 file changed, 2 insertions(+), 2 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/65/41365/1
diff --git a/src/core/osmo_io_uring.c b/src/core/osmo_io_uring.c
index b8b240f..cfd72fd 100644
--- a/src/core/osmo_io_uring.c
+++ b/src/core/osmo_io_uring.c
@@ -189,10 +189,10 @@
if (rc > 0)
msgb_put(msg, rc);

- if (!IOFD_FLAG_ISSET(iofd, IOFD_FLAG_CLOSED))
+ if (IOFD_FLAG_ISSET(iofd, IOFD_FLAG_FD_REGISTERED))
iofd_handle_recv(iofd, msg, rc, msghdr);

- if (iofd->u.uring.read_enabled && !IOFD_FLAG_ISSET(iofd, IOFD_FLAG_CLOSED))
+ if (IOFD_FLAG_ISSET(iofd, IOFD_FLAG_FD_REGISTERED) && iofd->u.uring.read_enabled)
iofd_uring_submit_recv(iofd, msghdr->action);
else
iofd->u.uring.read_msghdr = NULL;

To view, visit change 41365. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: osmith/1.11.3
Gerrit-Change-Id: I514412ecfbb82d32cb3d9c2272795ebac42f55e9
Gerrit-Change-Number: 41365
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith@sysmocom.de>
Gerrit-CC: pespin <pespin@sysmocom.de>