dexter has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmocore/+/32579 )
Change subject: select: speed up osmo_fd_is_registered
......................................................................
select: speed up osmo_fd_is_registered
osmo_fd_is_registered works by iterating the osmo_fds list and comparing
the supplied fd to all fds in that list until it finds a match. This can
be costly, so lets first check if the fd is even registered in any list
at all before moving on.
Unfortunately we still have to do the list iteration since the list in
which the fd is registered might not necessarly be the osmo_fds list.
Related: OS#5983
Change-Id: I1ce894da39e3f2329c88666a5dda594b8bce4228
---
M src/core/select.c
1 file changed, 22 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/79/32579/1
diff --git a/src/core/select.c b/src/core/select.c
index 69fa763..c2c78c2 100644
--- a/src/core/select.c
+++ b/src/core/select.c
@@ -139,6 +139,10 @@
bool osmo_fd_is_registered(struct osmo_fd *fd)
{
struct osmo_fd *entry;
+
+ if (!fd->list.next || fd->list.next == LLIST_POISON1)
+ return false;
+
llist_for_each_entry(entry, &osmo_fds, list) {
if (entry == fd) {
return true;
--
To view, visit
https://gerrit.osmocom.org/c/libosmocore/+/32579
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I1ce894da39e3f2329c88666a5dda594b8bce4228
Gerrit-Change-Number: 32579
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newchange