summaryrefslogtreecommitdiffstats
path: root/src/poll.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-11-10 20:55:47 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-11-10 20:55:47 +0100
commitc5aeb0dc4228c6396f35395194e0ec9cc91519c4 (patch)
treeff8a08aadad6c84d9042ffcc1ead169977216c01 /src/poll.c
parent598a8acfc1c1aaefb3c7407e517cc1e0f87b753a (diff)
downloadfastd-c5aeb0dc4228c6396f35395194e0ec9cc91519c4.tar
fastd-c5aeb0dc4228c6396f35395194e0ec9cc91519c4.zip
Implement generic task queue to handle handshakes and maintenance
Diffstat (limited to 'src/poll.c')
-rw-r--r--src/poll.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/poll.c b/src/poll.c
index 0c4dfa9..fed7001 100644
--- a/src/poll.c
+++ b/src/poll.c
@@ -51,12 +51,13 @@
#endif
-/** Returns the time to the next handshake or -1 */
-static inline int handshake_timeout(void) {
- if (!ctx.handshake_queue)
+/** Returns the time to the next task or -1 */
+static inline int task_timeout(void) {
+ fastd_timeout_t timeout;
+ if (!fastd_task_timeout(&timeout))
return -1;
- int diff_msec = ctx.handshake_queue->value - ctx.now;
+ int diff_msec = timeout - ctx.now;
if (diff_msec < 0)
return 0;
else
@@ -221,14 +222,7 @@ bool fastd_poll_fd_close(fastd_poll_fd_t *fd) {
void fastd_poll_handle(void) {
size_t i;
- int maintenance_timeout = ctx.next_maintenance - ctx.now;
-
- if (maintenance_timeout < 0)
- maintenance_timeout = 0;
-
- int timeout = handshake_timeout();
- if (timeout < 0 || timeout > maintenance_timeout)
- timeout = maintenance_timeout;
+ int timeout = task_timeout();
if (!VECTOR_LEN(ctx.pollfds)) {
for (i = 0; i < VECTOR_LEN(ctx.fds); i++) {