Remove legacy event system.
authorGuus Sliepen <guus@tinc-vpn.org>
Thu, 17 May 2007 22:13:12 +0000 (22:13 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Thu, 17 May 2007 22:13:12 +0000 (22:13 +0000)
src/Makefile.am
src/net.c
src/net_setup.c
src/node.h
src/tevent.c [deleted file]
src/tevent.h [deleted file]

index c9c1ac9..ed204ae 100644 (file)
@@ -5,7 +5,7 @@ sbin_PROGRAMS = tincd
 
 EXTRA_DIST = linux/device.c bsd/device.c solaris/device.c cygwin/device.c mingw/device.c mingw/common.h raw_socket/device.c uml_socket/device.c
 
-tincd_SOURCES = conf.c connection.c edge.c tevent.c graph.c logger.c meta.c net.c net_packet.c net_setup.c     \
+tincd_SOURCES = conf.c connection.c edge.c graph.c logger.c meta.c net.c net_packet.c net_setup.c      \
        net_socket.c netutl.c node.c process.c protocol.c protocol_auth.c protocol_edge.c protocol_misc.c       \
        protocol_key.c protocol_subnet.c route.c subnet.c tincd.c
 
@@ -15,7 +15,7 @@ DEFAULT_INCLUDES =
 
 INCLUDES = @INCLUDES@ -I$(top_builddir) -I$(top_srcdir)/lib
 
-noinst_HEADERS = conf.h connection.h device.h edge.h tevent.h graph.h logger.h meta.h net.h netutl.h node.h process.h  \
+noinst_HEADERS = conf.h connection.h device.h edge.h graph.h logger.h meta.h net.h netutl.h node.h process.h   \
        protocol.h route.h subnet.h
 
 LIBS = @LIBS@ @LIBINTL@
index 6243bdd..f9f6bd0 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -29,7 +29,6 @@
 #include "conf.h"
 #include "connection.h"
 #include "device.h"
-#include "tevent.h"
 #include "graph.h"
 #include "logger.h"
 #include "meta.h"
@@ -346,7 +345,6 @@ int main_loop(void)
        struct timeval tv;
        int r;
        time_t last_ping_check;
-       tevent_t *event;
        struct event timeout;
        struct event sighup_event;
 
@@ -422,18 +420,11 @@ int main_loop(void)
                        }
                }
 
-
-               while((event = get_expired_tevent())) {
-                       event->handler(event->data);
-                       free_tevent(event);
-               }
-
                if(sigalrm) {
                        logger(LOG_INFO, _("Flushing event queue"));
-                       flush_tevents();
+                       // TODO: do this another way
                        sigalrm = false;
                }
-
        }
 
        signal_del(&sighup_event);
index eeea61a..8aecfcd 100644 (file)
@@ -32,7 +32,6 @@
 #include "conf.h"
 #include "connection.h"
 #include "device.h"
-#include "tevent.h"
 #include "graph.h"
 #include "logger.h"
 #include "net.h"
@@ -565,7 +564,6 @@ bool setup_network_connections(void)
 
        now = time(NULL);
 
-       init_tevents();
        init_connections();
        init_subnets();
        init_nodes();
@@ -645,7 +643,6 @@ void close_network_connections(void)
        exit_subnets();
        exit_nodes();
        exit_connections();
-       exit_tevents();
 
        execute_script("tinc-down", envp);
 
index a612e93..5b5cc25 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "avl_tree.h"
 #include "connection.h"
-#include "tevent.h"
 #include "list.h"
 #include "subnet.h"
 
diff --git a/src/tevent.c b/src/tevent.c
deleted file mode 100644 (file)
index bdda639..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
-    event.c -- event queue
-    Copyright (C) 2002-2006 Guus Sliepen <guus@tinc-vpn.org>,
-                  2002-2005 Ivo Timmermans
-
-    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
-    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
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-    $Id$
-*/
-
-#include "system.h"
-
-#include "avl_tree.h"
-#include "tevent.h"
-#include "utils.h"
-#include "xalloc.h"
-
-avl_tree_t *tevent_tree;
-extern time_t now;
-
-int id;
-
-static int tevent_compare(const tevent_t *a, const tevent_t *b)
-{
-       if(a->time > b->time)
-               return 1;
-
-       if(a->time < b->time)
-               return -1;
-
-       return a->id - b->id;
-}
-
-void init_tevents(void)
-{
-       cp();
-
-       tevent_tree = avl_alloc_tree((avl_compare_t) tevent_compare, NULL);
-}
-
-void exit_tevents(void)
-{
-       cp();
-
-       avl_delete_tree(tevent_tree);
-}
-
-void flush_tevents(void)
-{
-       avl_tree_t *to_flush;
-       tevent_t *event;
-
-       /*
-        * Events can be inserted from event handlers, so only flush events
-        * already in the priority queue.
-        */
-
-       cp();
-
-       to_flush = tevent_tree;
-       init_tevents();
-       while (to_flush->head) {
-               event = to_flush->head->data;
-               event->handler(event->data);
-               avl_delete(to_flush, event);
-       }
-       avl_delete_tree(to_flush);
-}
-
-tevent_t *new_tevent(void)
-{
-       cp();
-
-       return xmalloc_and_zero(sizeof(tevent_t));
-}
-
-void free_tevent(tevent_t *event)
-{
-       cp();
-
-       free(event);
-}
-
-void tevent_add(tevent_t *event)
-{
-       cp();
-
-       event->id = ++id;
-       avl_insert(tevent_tree, event);
-}
-
-void tevent_del(tevent_t *event)
-{
-       cp();
-
-       avl_delete(tevent_tree, event);
-}
-
-tevent_t *get_expired_tevent(void)
-{
-       tevent_t *event;
-
-       cp();
-
-       if(tevent_tree->head) {
-               event = tevent_tree->head->data;
-
-               if(event->time < now) {
-                       tevent_del(event);
-                       return event;
-               }
-       }
-
-       return NULL;
-}
diff --git a/src/tevent.h b/src/tevent.h
deleted file mode 100644 (file)
index 8f5cfd8..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-    event.h -- header for event.c
-    Copyright (C) 2002-2006 Guus Sliepen <guus@tinc-vpn.org>,
-                  2002-2005 Ivo Timmermans
-
-    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
-    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
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-    $Id$
-*/
-
-#ifndef __TINC_EVENT_H__
-#define __TINC_EVENT_H__
-
-#include "avl_tree.h"
-
-extern avl_tree_t *tevent_tree;
-
-typedef void (*event_handler_t)(void *);
-
-typedef struct {
-       time_t time;
-       int id;
-       event_handler_t handler;
-       void *data;
-} tevent_t;
-
-extern void init_tevents(void);
-extern void exit_tevents(void);
-extern void flush_tevents(void);
-extern tevent_t *new_tevent(void) __attribute__ ((__malloc__));
-extern void free_tevent(tevent_t *);
-extern void tevent_add(tevent_t *);
-extern void tevent_del(tevent_t *);
-extern tevent_t *get_expired_tevent(void);
-
-#endif                                                 /* __TINC_EVENT_H__ */