X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=src%2Fselect.c;h=adf361949120c9f3e2d489798b3063ac7b936670;hb=a9f526a1abb1d2bfa68c611f1676fea2d89bc9d9;hp=4f5d7ed95bf6c3972979c901f49d0ae88e60b36d;hpb=ec8b4501c7b0bfb286db7789635168d1b84f9105;p=osmocom-bb.git diff --git a/src/select.c b/src/select.c index 4f5d7ed..adf3619 100644 --- a/src/select.c +++ b/src/select.c @@ -5,8 +5,9 @@ * (C) 2000-2009 by Harald Welte * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,9 +20,13 @@ */ #include -#include -#include -#include +#include + +#include +#include +#include + +#include "../config.h" #ifdef HAVE_SYS_SELECT_H @@ -46,6 +51,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; @@ -119,7 +134,8 @@ restart: /* 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) + /* this seems to happen with the last element of the list as well */ + if (unregistered_count >= 1) goto restart; } return work;