diff options
-rw-r--r-- | include/openbsc/select.h | 2 | ||||
-rw-r--r-- | src/bs11_config.c | 2 | ||||
-rw-r--r-- | src/bsc_hack.c | 2 | ||||
-rw-r--r-- | src/ipaccess-config.c | 2 | ||||
-rw-r--r-- | src/ipaccess-find.c | 2 | ||||
-rw-r--r-- | src/select.c | 20 | ||||
-rw-r--r-- | tests/timer/timer_test.c | 2 |
7 files changed, 18 insertions, 14 deletions
diff --git a/include/openbsc/select.h b/include/openbsc/select.h index b677162e6..c2af1d787 100644 --- a/include/openbsc/select.h +++ b/include/openbsc/select.h @@ -18,5 +18,5 @@ struct bsc_fd { int bsc_register_fd(struct bsc_fd *fd); void bsc_unregister_fd(struct bsc_fd *fd); -int bsc_select_main(void); +int bsc_select_main(int polling); #endif /* _BSC_SELECT_H */ diff --git a/src/bs11_config.c b/src/bs11_config.c index 3da0c528d..57ed9023e 100644 --- a/src/bs11_config.c +++ b/src/bs11_config.c @@ -790,7 +790,7 @@ int main(int argc, char **argv) status_timer.cb = status_timer_cb; while (1) { - bsc_select_main(); + bsc_select_main(0); } abis_nm_bs11_factory_logon(g_bts, 0); diff --git a/src/bsc_hack.c b/src/bsc_hack.c index cd3ca4144..797c62783 100644 --- a/src/bsc_hack.c +++ b/src/bsc_hack.c @@ -1123,6 +1123,6 @@ int main(int argc, char **argv) signal(SIGABRT, &signal_handler); while (1) { - bsc_select_main(); + bsc_select_main(0); } } diff --git a/src/ipaccess-config.c b/src/ipaccess-config.c index 964d6186c..b74e46e89 100644 --- a/src/ipaccess-config.c +++ b/src/ipaccess-config.c @@ -188,7 +188,7 @@ int main(int argc, char **argv) } while (1) { - rc = bsc_select_main(); + rc = bsc_select_main(0); if (rc < 0) exit(3); } diff --git a/src/ipaccess-find.c b/src/ipaccess-find.c index 32f42e904..b3e9814a9 100644 --- a/src/ipaccess-find.c +++ b/src/ipaccess-find.c @@ -170,7 +170,7 @@ int main(int argc, char **argv) printf("Trying to find ip.access BTS by broadcast UDP...\n"); while (1) { - rc = bsc_select_main(); + rc = bsc_select_main(0); if (rc < 0) exit(3); } diff --git a/src/select.c b/src/select.c index 157e23500..11b7e6b49 100644 --- a/src/select.c +++ b/src/select.c @@ -53,11 +53,12 @@ void bsc_unregister_fd(struct bsc_fd *fd) llist_del(&fd->list); } -int bsc_select_main() +int bsc_select_main(int polling) { struct bsc_fd *ufd, *tmp; fd_set readset, writeset, exceptset; - int i; + int work = 0, rc; + struct timeval no_time = {0, 0}; FD_ZERO(&readset); FD_ZERO(&writeset); @@ -75,10 +76,11 @@ int bsc_select_main() FD_SET(ufd->fd, &exceptset); } - bsc_prepare_timers(); - i = select(maxfd+1, &readset, &writeset, &exceptset, bsc_nearest_timer()); - if (i < 0) - return i; + if (!polling) + bsc_prepare_timers(); + rc = select(maxfd+1, &readset, &writeset, &exceptset, polling ? &no_time : bsc_nearest_timer()); + if (rc < 0) + return 0; /* fire timers */ bsc_update_timers(); @@ -96,8 +98,10 @@ int bsc_select_main() if (FD_ISSET(ufd->fd, &exceptset)) flags |= BSC_FD_EXCEPT; - if (flags) + if (flags) { + work = 1; ufd->cb(ufd, flags); + } } - return i; + return work; } diff --git a/tests/timer/timer_test.c b/tests/timer/timer_test.c index 339404e4b..26fcbc938 100644 --- a/tests/timer/timer_test.c +++ b/tests/timer/timer_test.c @@ -65,6 +65,6 @@ int main(int argc, char** argv) bsc_schedule_timer(&timer_three, 4, 0); while (1) { - bsc_select_main(); + bsc_select_main(0); } } |