diff options
author | sam <sam@FreeBSD.org> | 2006-03-07 05:47:04 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2006-03-07 05:47:04 +0000 |
commit | 8d55057fb42bf9070fd379acbcb6fc4ef793d2a7 (patch) | |
tree | dacc7977efdefefb8b105113edeb5215c0e01234 /contrib/hostapd/eloop.c | |
parent | d1a1fd4aa94cd9c5cb443c4c1337f91c8c46fde0 (diff) | |
download | FreeBSD-src-8d55057fb42bf9070fd379acbcb6fc4ef793d2a7.zip FreeBSD-src-8d55057fb42bf9070fd379acbcb6fc4ef793d2a7.tar.gz |
Import of hostapd 0.4.8
Diffstat (limited to 'contrib/hostapd/eloop.c')
-rw-r--r-- | contrib/hostapd/eloop.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/contrib/hostapd/eloop.c b/contrib/hostapd/eloop.c index 6071508..39fccb8 100644 --- a/contrib/hostapd/eloop.c +++ b/contrib/hostapd/eloop.c @@ -1,5 +1,5 @@ /* - * Event loop + * Event loop based on select() loop * Copyright (c) 2002-2005, Jouni Malinen <jkmaline@cc.hut.fi> * * This program is free software; you can redistribute it and/or modify @@ -294,10 +294,16 @@ int eloop_register_signal(int sig, void eloop_run(void) { - fd_set rfds; + fd_set *rfds; int i, res; struct timeval tv, now; + rfds = malloc(sizeof(*rfds)); + if (rfds == NULL) { + printf("eloop_run - malloc failed\n"); + return; + } + while (!eloop.terminate && (eloop.timeout || eloop.reader_count > 0)) { if (eloop.timeout) { @@ -312,13 +318,14 @@ void eloop_run(void) #endif } - FD_ZERO(&rfds); + FD_ZERO(rfds); for (i = 0; i < eloop.reader_count; i++) - FD_SET(eloop.readers[i].sock, &rfds); - res = select(eloop.max_sock + 1, &rfds, NULL, NULL, + FD_SET(eloop.readers[i].sock, rfds); + res = select(eloop.max_sock + 1, rfds, NULL, NULL, eloop.timeout ? &tv : NULL); if (res < 0 && errno != EINTR) { perror("select"); + free(rfds); return; } eloop_process_pending_signals(); @@ -342,7 +349,7 @@ void eloop_run(void) continue; for (i = 0; i < eloop.reader_count; i++) { - if (FD_ISSET(eloop.readers[i].sock, &rfds)) { + if (FD_ISSET(eloop.readers[i].sock, rfds)) { eloop.readers[i].handler( eloop.readers[i].sock, eloop.readers[i].eloop_data, @@ -350,6 +357,8 @@ void eloop_run(void) } } } + + free(rfds); } |