use linked_list_iterator to address #400

This commit is contained in:
matthias.ringwald 2014-06-16 21:34:42 +00:00
parent 2412778b77
commit 4c46246592

View File

@ -120,17 +120,20 @@ static void posix_dump_timer(void){
*/ */
static void posix_execute(void) { static void posix_execute(void) {
fd_set descriptors; fd_set descriptors;
data_source_t *ds;
timer_source_t *ts; timer_source_t *ts;
struct timeval current_tv; struct timeval current_tv;
struct timeval next_tv; struct timeval next_tv;
struct timeval *timeout; struct timeval *timeout;
linked_list_iterator_t it;
while (1) { while (1) {
// collect FDs // collect FDs
FD_ZERO(&descriptors); FD_ZERO(&descriptors);
int highest_fd = 0; int highest_fd = 0;
for (ds = (data_source_t *) data_sources; ds ; ds = (data_source_t *) ds->item.next){ linked_list_iterator_init(&it, &data_sources);
while (linked_list_iterator_has_next(&it)){
data_source_t *ds = (data_source_t*) linked_list_iterator_next(&it);
if (ds->fd >= 0) { if (ds->fd >= 0) {
FD_SET(ds->fd, &descriptors); FD_SET(ds->fd, &descriptors);
if (ds->fd > highest_fd) { if (ds->fd > highest_fd) {
@ -166,7 +169,9 @@ static void posix_execute(void) {
// log_info("posix_execute: before ds check\n"); // log_info("posix_execute: before ds check\n");
data_sources_modified = 0; data_sources_modified = 0;
for (ds = (data_source_t *) data_sources; !data_sources_modified && ds != NULL; ds = (data_source_t *) ds->item.next){ linked_list_iterator_init(&it, &data_sources);
while (linked_list_iterator_has_next(&it) && !data_sources_modified){
data_source_t *ds = (data_source_t*) linked_list_iterator_next(&it);
// log_info("posix_execute: check %x with fd %u\n", (int) ds, ds->fd); // log_info("posix_execute: check %x with fd %u\n", (int) ds, ds->fd);
if (FD_ISSET(ds->fd, &descriptors)) { if (FD_ISSET(ds->fd, &descriptors)) {
// log_info("posix_execute: process %x with fd %u\n", (int) ds, ds->fd); // log_info("posix_execute: process %x with fd %u\n", (int) ds, ds->fd);