summaryrefslogtreecommitdiffstats
path: root/src/select.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-08-06 06:48:43 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-08-06 06:50:23 +0800
commit43558316bc4e6ddac92dd198b07a4803c21dc77b (patch)
treeabc157bc9668a4859e1b9f0c64caf507af16562b /src/select.c
parentc2b7f92a6c1ae3ad4f4865f3c2c69d4a3a5a279a (diff)
bsc_fd: Add a build option to be able to debug fd list corruption
bsc_register_fd on an already registered fd can corrupt the list in a heavy way and make the select end in an infinite loop, this code will workaround the issue and provide a way to set a breakpoint at the right position in the code.
Diffstat (limited to 'src/select.c')
-rw-r--r--src/select.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/select.c b/src/select.c
index 2f6afa7f..f52b0a0c 100644
--- a/src/select.c
+++ b/src/select.c
@@ -19,6 +19,8 @@
*/
#include <fcntl.h>
+#include <stdio.h>
+
#include <osmocore/select.h>
#include <osmocore/linuxlist.h>
#include <osmocore/timer.h>
@@ -48,6 +50,16 @@ int bsc_register_fd(struct bsc_fd *fd)
if (fd->fd > maxfd)
maxfd = fd->fd;
+#ifdef BSC_FD_CHECK
+ struct bsc_fd *entry;
+ llist_for_each_entry(entry, &bsc_fds, list) {
+ if (entry == fd) {
+ fprintf(stderr, "Adding a bsc_fd that is already in the list.\n");
+ return 0;
+ }
+ }
+#endif
+
llist_add_tail(&fd->list, &bsc_fds);
return 0;