]> git.meshlink.io Git - meshlink/blobdiff - src/event.c
Remove everything GPL that is not copyright Guus Sliepen, update copyright statements.
[meshlink] / src / event.c
index 44a1f878a55a392a299c46f9efe115bb02f68fc6..e4917589750a53e48cf8a563502b7563ed90a86a 100644 (file)
@@ -1,6 +1,6 @@
 /*
     event.c -- I/O, timeout and signal event handling
-    Copyright (C) 2012 Guus Sliepen <guus@tinc-vpn.org>
+    Copyright (C) 2014 Guus Sliepen <guus@meshlink.io>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
 
 #include "system.h"
 
+#include "dropin.h"
 #include "event.h"
 #include "net.h"
 #include "utils.h"
@@ -51,13 +52,8 @@ static int timeout_compare(const timeout_t *a, const timeout_t *b) {
        return 0;
 }
 
-static int signal_compare(const signal_t *a, const signal_t *b) {
-       return a->signum - b->signum;
-}
-
 static splay_tree_t io_tree = {.compare = (splay_compare_t)io_compare};
 static splay_tree_t timeout_tree = {.compare = (splay_compare_t)timeout_compare};
-static splay_tree_t signal_tree = {.compare = (splay_compare_t)signal_compare};
 
 void io_add(io_t *io, io_cb_t cb, void *data, int fd, int flags) {
        if(io->cb)
@@ -129,8 +125,13 @@ void timeout_del(timeout_t *timeout) {
 }
 
 #ifndef HAVE_MINGW
+static int signal_compare(const signal_t *a, const signal_t *b) {
+       return a->signum - b->signum;
+}
+
 static io_t signalio;
 static int pipefd[2] = {-1, -1};
+static splay_tree_t signal_tree = {.compare = (splay_compare_t)signal_compare};
 
 static void signal_handler(int signum) {
        unsigned char num = signum;
@@ -244,6 +245,12 @@ bool event_loop(void) {
        return true;
 }
 
+void event_flush_output(void) {
+       for splay_each(io_t, io, &io_tree)
+               if(FD_ISSET(io->fd, &writefds))
+                       io->cb(io->data, IO_WRITE);
+}
+
 void event_exit(void) {
        running = false;
 }