aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorAndreas Eversberg <Andreas.Eversberg@versatel.de>2010-01-23 10:52:38 +0100
committerHarald Welte <laforge@gnumonks.org>2010-01-23 10:52:38 +0100
commit1e1c6aa5a3db4680d1f8088ef6f7c0cb1117d032 (patch)
tree6158536b6aa590826b3b40ba157b89e8b498f284 /openbsc
parent604d851b89d2d62f024223d333c833ebebd42060 (diff)
Make sure select() callbacks are not called multiple times
the unix select function returns a set of file descriptors to be handled. the result-loop (the loop after the select()) is called again, if more than one descriptor is removed by the callback funtion. this may lead to a another call to the callback function, because the bits of the FD_SETs do not change and still set. i think we must clear these bits, if they are handled, so the handler will not be called twice in case of a "restart" of that loop.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/src/select.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/openbsc/src/select.c b/openbsc/src/select.c
index c11f3a511..bed96498c 100644
--- a/openbsc/src/select.c
+++ b/openbsc/src/select.c
@@ -95,14 +95,20 @@ restart:
llist_for_each_entry_safe(ufd, tmp, &bsc_fds, list) {
int flags = 0;
- if (FD_ISSET(ufd->fd, &readset))
+ if (FD_ISSET(ufd->fd, &readset)) {
flags |= BSC_FD_READ;
+ FD_CLR(ufd->fd, &readset);
+ }
- if (FD_ISSET(ufd->fd, &writeset))
+ if (FD_ISSET(ufd->fd, &writeset)) {
flags |= BSC_FD_WRITE;
+ FD_CLR(ufd->fd, &writeset);
+ }
- if (FD_ISSET(ufd->fd, &exceptset))
+ if (FD_ISSET(ufd->fd, &exceptset)) {
flags |= BSC_FD_EXCEPT;
+ FD_CLR(ufd->fd, &exceptset);
+ }
if (flags) {
work = 1;