summaryrefslogtreecommitdiffstats
path: root/openbsc/src/select.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2009-07-28 18:37:07 +0200
committerHarald Welte <laforge@gnumonks.org>2009-07-28 18:37:07 +0200
commite211da49b98162cbf9653da7b80e30634f2b1637 (patch)
treeeb8d9954ccc3aac8436442e2c6bbb4a1564110e2 /openbsc/src/select.c
parente51b2eaa0b9b5bfaaa3adb3c0f7ae0e567d5be10 (diff)
parentf4e79f24fcdabdfd81be5d3842b4bf4c05465db4 (diff)
Merge branch 'master' into proxy
Diffstat (limited to 'openbsc/src/select.c')
-rw-r--r--openbsc/src/select.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/openbsc/src/select.c b/openbsc/src/select.c
index 11b7e6b49..7f45426d0 100644
--- a/openbsc/src/select.c
+++ b/openbsc/src/select.c
@@ -25,6 +25,7 @@
static int maxfd = 0;
static LLIST_HEAD(bsc_fds);
+static int unregistered_count;
int bsc_register_fd(struct bsc_fd *fd)
{
@@ -50,6 +51,7 @@ int bsc_register_fd(struct bsc_fd *fd)
void bsc_unregister_fd(struct bsc_fd *fd)
{
+ unregistered_count++;
llist_del(&fd->list);
}
@@ -86,6 +88,8 @@ int bsc_select_main(int polling)
bsc_update_timers();
/* call registered callback functions */
+restart:
+ unregistered_count = 0;
llist_for_each_entry_safe(ufd, tmp, &bsc_fds, list) {
int flags = 0;
@@ -102,6 +106,11 @@ int bsc_select_main(int polling)
work = 1;
ufd->cb(ufd, flags);
}
+ /* ugly, ugly hack. If more than one filedescriptors were
+ * unregistered, they might have been consecutive and
+ * llist_for_each_entry_safe() is no longer safe */
+ if (unregistered_count > 1)
+ goto restart;
}
return work;
}