Rename "event_t" to "tevent_t", along with associated functions.
This relieves some confusion and problems during the libevent transition. In particular, "event_add" was defined by both. (The 't' stands for 'timeout', 'tinc', 'temporary', or some such.)
This commit is contained in:
parent
54431094d9
commit
6362b12df7
9 changed files with 48 additions and 48 deletions
|
@ -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
|
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 event.c graph.c logger.c meta.c net.c net_packet.c net_setup.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 \
|
||||||
net_socket.c netutl.c node.c process.c protocol.c protocol_auth.c protocol_edge.c protocol_misc.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
|
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
|
INCLUDES = @INCLUDES@ -I$(top_builddir) -I$(top_srcdir)/lib
|
||||||
|
|
||||||
noinst_HEADERS = conf.h connection.h device.h edge.h event.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 tevent.h graph.h logger.h meta.h net.h netutl.h node.h process.h \
|
||||||
protocol.h route.h subnet.h
|
protocol.h route.h subnet.h
|
||||||
|
|
||||||
LIBS = @LIBS@ @LIBINTL@
|
LIBS = @LIBS@ @LIBINTL@
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "event.h"
|
#include "tevent.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
|
@ -355,7 +355,7 @@ int main_loop(void)
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int r, maxfd;
|
int r, maxfd;
|
||||||
time_t last_ping_check, last_config_check, last_graph_dump;
|
time_t last_ping_check, last_config_check, last_graph_dump;
|
||||||
event_t *event;
|
tevent_t *event;
|
||||||
|
|
||||||
cp();
|
cp();
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "ethernet.h"
|
#include "ethernet.h"
|
||||||
#include "event.h"
|
#include "tevent.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
@ -96,11 +96,11 @@ void send_mtu_probe(node_t *n)
|
||||||
send_udppacket(n, &packet);
|
send_udppacket(n, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
n->mtuevent = new_event();
|
n->mtuevent = new_tevent();
|
||||||
n->mtuevent->handler = (event_handler_t)send_mtu_probe;
|
n->mtuevent->handler = (event_handler_t)send_mtu_probe;
|
||||||
n->mtuevent->data = n;
|
n->mtuevent->data = n;
|
||||||
n->mtuevent->time = now + 1;
|
n->mtuevent->time = now + 1;
|
||||||
event_add(n->mtuevent);
|
tevent_add(n->mtuevent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mtu_probe_h(node_t *n, vpn_packet_t *packet) {
|
void mtu_probe_h(node_t *n, vpn_packet_t *packet) {
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "event.h"
|
#include "tevent.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "avl_tree.h"
|
#include "avl_tree.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "event.h"
|
#include "tevent.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
@ -220,7 +220,7 @@ int setup_vpn_in_socket(const sockaddr_t *sa)
|
||||||
|
|
||||||
void retry_outgoing(outgoing_t *outgoing)
|
void retry_outgoing(outgoing_t *outgoing)
|
||||||
{
|
{
|
||||||
event_t *event;
|
tevent_t *event;
|
||||||
|
|
||||||
cp();
|
cp();
|
||||||
|
|
||||||
|
@ -229,11 +229,11 @@ void retry_outgoing(outgoing_t *outgoing)
|
||||||
if(outgoing->timeout > maxtimeout)
|
if(outgoing->timeout > maxtimeout)
|
||||||
outgoing->timeout = maxtimeout;
|
outgoing->timeout = maxtimeout;
|
||||||
|
|
||||||
event = new_event();
|
event = new_tevent();
|
||||||
event->handler = (event_handler_t) setup_outgoing_connection;
|
event->handler = (event_handler_t) setup_outgoing_connection;
|
||||||
event->time = now + outgoing->timeout;
|
event->time = now + outgoing->timeout;
|
||||||
event->data = outgoing;
|
event->data = outgoing;
|
||||||
event_add(event);
|
tevent_add(event);
|
||||||
|
|
||||||
ifdebug(CONNECTIONS) logger(LOG_NOTICE,
|
ifdebug(CONNECTIONS) logger(LOG_NOTICE,
|
||||||
_("Trying to re-establish outgoing connection in %d seconds"),
|
_("Trying to re-establish outgoing connection in %d seconds"),
|
||||||
|
|
|
@ -107,7 +107,7 @@ void free_node(node_t *n)
|
||||||
EVP_CIPHER_CTX_cleanup(&n->packet_ctx);
|
EVP_CIPHER_CTX_cleanup(&n->packet_ctx);
|
||||||
|
|
||||||
if(n->mtuevent) {
|
if(n->mtuevent) {
|
||||||
event_del(n->mtuevent);
|
tevent_del(n->mtuevent);
|
||||||
free_event(n->mtuevent);
|
free_event(n->mtuevent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "avl_tree.h"
|
#include "avl_tree.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "event.h"
|
#include "tevent.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "subnet.h"
|
#include "subnet.h"
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ typedef struct node_t {
|
||||||
length_t minmtu; /* Probed minimum MTU */
|
length_t minmtu; /* Probed minimum MTU */
|
||||||
length_t maxmtu; /* Probed maximum MTU */
|
length_t maxmtu; /* Probed maximum MTU */
|
||||||
int mtuprobes; /* Number of probes */
|
int mtuprobes; /* Number of probes */
|
||||||
event_t *mtuevent; /* Probe event */
|
tevent_t *mtuevent; /* Probe event */
|
||||||
} node_t;
|
} node_t;
|
||||||
|
|
||||||
extern struct node_t *myself;
|
extern struct node_t *myself;
|
||||||
|
|
|
@ -23,16 +23,16 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#include "avl_tree.h"
|
#include "avl_tree.h"
|
||||||
#include "event.h"
|
#include "tevent.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
|
|
||||||
avl_tree_t *event_tree;
|
avl_tree_t *tevent_tree;
|
||||||
extern time_t now;
|
extern time_t now;
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
static int event_compare(const event_t *a, const event_t *b)
|
static int tevent_compare(const tevent_t *a, const tevent_t *b)
|
||||||
{
|
{
|
||||||
if(a->time > b->time)
|
if(a->time > b->time)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -43,24 +43,24 @@ static int event_compare(const event_t *a, const event_t *b)
|
||||||
return a->id - b->id;
|
return a->id - b->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_events(void)
|
void init_tevents(void)
|
||||||
{
|
{
|
||||||
cp();
|
cp();
|
||||||
|
|
||||||
event_tree = avl_alloc_tree((avl_compare_t) event_compare, NULL);
|
tevent_tree = avl_alloc_tree((avl_compare_t) tevent_compare, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_events(void)
|
void exit_tevents(void)
|
||||||
{
|
{
|
||||||
cp();
|
cp();
|
||||||
|
|
||||||
avl_delete_tree(event_tree);
|
avl_delete_tree(tevent_tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
void flush_events(void)
|
void flush_tevents(void)
|
||||||
{
|
{
|
||||||
avl_tree_t *to_flush;
|
avl_tree_t *to_flush;
|
||||||
event_t *event;
|
tevent_t *event;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Events can be inserted from event handlers, so only flush events
|
* Events can be inserted from event handlers, so only flush events
|
||||||
|
@ -69,8 +69,8 @@ void flush_events(void)
|
||||||
|
|
||||||
cp();
|
cp();
|
||||||
|
|
||||||
to_flush = event_tree;
|
to_flush = tevent_tree;
|
||||||
init_events();
|
init_tevents();
|
||||||
while (to_flush->head) {
|
while (to_flush->head) {
|
||||||
event = to_flush->head->data;
|
event = to_flush->head->data;
|
||||||
event->handler(event->data);
|
event->handler(event->data);
|
||||||
|
@ -79,46 +79,46 @@ void flush_events(void)
|
||||||
avl_delete_tree(to_flush);
|
avl_delete_tree(to_flush);
|
||||||
}
|
}
|
||||||
|
|
||||||
event_t *new_event(void)
|
tevent_t *new_tevent(void)
|
||||||
{
|
{
|
||||||
cp();
|
cp();
|
||||||
|
|
||||||
return xmalloc_and_zero(sizeof(event_t));
|
return xmalloc_and_zero(sizeof(tevent_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_event(event_t *event)
|
void free_tevent(tevent_t *event)
|
||||||
{
|
{
|
||||||
cp();
|
cp();
|
||||||
|
|
||||||
free(event);
|
free(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void event_add(event_t *event)
|
void tevent_add(tevent_t *event)
|
||||||
{
|
{
|
||||||
cp();
|
cp();
|
||||||
|
|
||||||
event->id = ++id;
|
event->id = ++id;
|
||||||
avl_insert(event_tree, event);
|
avl_insert(tevent_tree, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void event_del(event_t *event)
|
void tevent_del(tevent_t *event)
|
||||||
{
|
{
|
||||||
cp();
|
cp();
|
||||||
|
|
||||||
avl_delete(event_tree, event);
|
avl_delete(tevent_tree, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
event_t *get_expired_event(void)
|
tevent_t *get_expired_tevent(void)
|
||||||
{
|
{
|
||||||
event_t *event;
|
tevent_t *event;
|
||||||
|
|
||||||
cp();
|
cp();
|
||||||
|
|
||||||
if(event_tree->head) {
|
if(tevent_tree->head) {
|
||||||
event = event_tree->head->data;
|
event = tevent_tree->head->data;
|
||||||
|
|
||||||
if(event->time < now) {
|
if(event->time < now) {
|
||||||
event_del(event);
|
tevent_del(event);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "avl_tree.h"
|
#include "avl_tree.h"
|
||||||
|
|
||||||
extern avl_tree_t *event_tree;
|
extern avl_tree_t *tevent_tree;
|
||||||
|
|
||||||
typedef void (*event_handler_t)(void *);
|
typedef void (*event_handler_t)(void *);
|
||||||
|
|
||||||
|
@ -34,15 +34,15 @@ typedef struct {
|
||||||
int id;
|
int id;
|
||||||
event_handler_t handler;
|
event_handler_t handler;
|
||||||
void *data;
|
void *data;
|
||||||
} event_t;
|
} tevent_t;
|
||||||
|
|
||||||
extern void init_events(void);
|
extern void init_tevents(void);
|
||||||
extern void exit_events(void);
|
extern void exit_tevents(void);
|
||||||
extern void flush_events(void);
|
extern void flush_tevents(void);
|
||||||
extern event_t *new_event(void) __attribute__ ((__malloc__));
|
extern tevent_t *new_tevent(void) __attribute__ ((__malloc__));
|
||||||
extern void free_event(event_t *);
|
extern void free_tevent(tevent_t *);
|
||||||
extern void event_add(event_t *);
|
extern void tevent_add(tevent_t *);
|
||||||
extern void event_del(event_t *);
|
extern void tevent_del(tevent_t *);
|
||||||
extern event_t *get_expired_event(void);
|
extern tevent_t *get_expired_tevent(void);
|
||||||
|
|
||||||
#endif /* __TINC_EVENT_H__ */
|
#endif /* __TINC_EVENT_H__ */
|
Loading…
Reference in a new issue