Skip to content
This repository was archived by the owner on Jun 6, 2021. It is now read-only.

Commit

Permalink
Switch to using libmowgli-2 timers.
Browse files Browse the repository at this point in the history
This is a first step into splitting the atheme-specific parts of the eventloop from the
more generic parts of the eventloop.
  • Loading branch information
kaniini committed Nov 26, 2011
1 parent 2a1eb57 commit 0655145
Show file tree
Hide file tree
Showing 25 changed files with 145 additions and 299 deletions.
1 change: 0 additions & 1 deletion include/atheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "i18n.h"
#include "common.h"
#include "object.h"
#include "event.h"
#include "connection.h"
#include "res.h"
#include "hook.h"
Expand Down
1 change: 0 additions & 1 deletion include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
/* D E F I N E S */
#define BUFSIZE 1024 /* maximum size of a buffer */
#define MAXMODES 4
#define MAX_EVENTS 1024 /* that's enough events, really! */
#define MAX_IRC_OUTPUT_LINES 2000

/* lengths of buffers (string length is 1 less) */
Expand Down
42 changes: 0 additions & 42 deletions include/event.h

This file was deleted.

1 change: 1 addition & 0 deletions include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ E void unmark_all_illegal(void);
E void remove_illegals(void);

/* atheme.c */
E mowgli_eventloop_t *base_eventloop;
E bool cold_start;
E bool readonly;
E char *config_file;
Expand Down
1 change: 0 additions & 1 deletion libathemecore/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ BASE_SRCS = \
database_backend.c \
datastream.c \
entity.c \
event.c \
flags.c \
function.c \
help.c \
Expand Down
19 changes: 11 additions & 8 deletions libathemecore/atheme.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ nicksvs_t nicksvs;

mowgli_list_t taint_list = { NULL, NULL, 0 };

mowgli_eventloop_t *base_eventloop = NULL;

me_t me;
struct cnt cnt;

Expand Down Expand Up @@ -227,7 +229,7 @@ int atheme_main(int argc, char *argv[])
umask(077);
#endif

event_init();
base_eventloop = mowgli_eventloop_create();
hooks_init();
init_socket_queues();
db_init();
Expand Down Expand Up @@ -347,21 +349,21 @@ int atheme_main(int argc, char *argv[])

/* DB commit interval is configurable */
if (db_save && !readonly)
event_add("db_save", db_save, NULL, config_options.commit_interval);
mowgli_timer_add(base_eventloop, "db_save", db_save, NULL, config_options.commit_interval);

/* check expires every hour */
event_add("expire_check", expire_check, NULL, 3600);
mowgli_timer_add(base_eventloop, "expire_check", expire_check, NULL, 3600);

/* check k/x/q line expires every minute */
event_add("kline_expire", kline_expire, NULL, 60);
event_add("xline_expire", xline_expire, NULL, 60);
event_add("qline_expire", qline_expire, NULL, 60);
mowgli_timer_add(base_eventloop, "kline_expire", kline_expire, NULL, 60);
mowgli_timer_add(base_eventloop, "xline_expire", xline_expire, NULL, 60);
mowgli_timer_add(base_eventloop, "qline_expire", qline_expire, NULL, 60);

/* check authcookie expires every ten minutes */
event_add("authcookie_expire", authcookie_expire, NULL, 600);
mowgli_timer_add(base_eventloop, "authcookie_expire", authcookie_expire, NULL, 600);

/* reseed rng a little every five minutes */
event_add("rng_reseed", rng_reseed, NULL, 293);
mowgli_timer_add(base_eventloop, "rng_reseed", rng_reseed, NULL, 293);

me.connected = false;
uplink_connect();
Expand Down Expand Up @@ -395,6 +397,7 @@ int atheme_main(int argc, char *argv[])

slog(LG_INFO, "main(): shutting down");

mowgli_eventloop_destroy(base_eventloop);
log_shutdown();

return 0;
Expand Down
10 changes: 5 additions & 5 deletions libathemecore/cmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ static struct modestackdata {
int totallen;
int paramcount;

unsigned int event;
mowgli_eventloop_timer_t *event;
} modestackdata;

static void modestack_calclen(struct modestackdata *md);
Expand Down Expand Up @@ -710,7 +710,7 @@ void modestack_mode_simple_real(const char *source, channel_t *channel, int dir,
md = modestack_init(source, channel);
modestack_add_simple(md, dir, flags);
if (!md->event)
md->event = event_add_once("flush_cmode_callback", modestack_flush_callback, md, 0);
md->event = mowgli_timer_add_once(base_eventloop, "flush_cmode_callback", modestack_flush_callback, md, 0);
}
void (*modestack_mode_simple)(const char *source, channel_t *channel, int dir, int flags) = modestack_mode_simple_real;

Expand All @@ -722,7 +722,7 @@ void modestack_mode_limit_real(const char *source, channel_t *channel, int dir,
md = modestack_init(source, channel);
modestack_add_limit(md, dir, limit);
if (!md->event)
md->event = event_add_once("flush_cmode_callback", modestack_flush_callback, md, 0);
md->event = mowgli_timer_add_once(base_eventloop, "flush_cmode_callback", modestack_flush_callback, md, 0);
}
void (*modestack_mode_limit)(const char *source, channel_t *channel, int dir, unsigned int limit) = modestack_mode_limit_real;

Expand All @@ -740,7 +740,7 @@ void modestack_mode_ext_real(const char *source, channel_t *channel, int dir, un
}
modestack_add_ext(md, dir, i, value);
if (!md->event)
md->event = event_add_once("flush_cmode_callback", modestack_flush_callback, md, 0);
md->event = mowgli_timer_add_once(base_eventloop, "flush_cmode_callback", modestack_flush_callback, md, 0);
}
void (*modestack_mode_ext)(const char *source, channel_t *channel, int dir, unsigned int i, const char *value) = modestack_mode_ext_real;

Expand All @@ -752,7 +752,7 @@ void modestack_mode_param_real(const char *source, channel_t *channel, int dir,
md = modestack_init(source, channel);
modestack_add_param(md, dir, type, value);
if (!md->event)
md->event = event_add_once("flush_cmode_callback", modestack_flush_callback, md, 0);
md->event = mowgli_timer_add_once(base_eventloop, "flush_cmode_callback", modestack_flush_callback, md, 0);
}
void (*modestack_mode_param)(const char *source, channel_t *channel, int dir, char type, const char *value) = modestack_mode_param_real;

Expand Down
170 changes: 0 additions & 170 deletions libathemecore/event.c

This file was deleted.

14 changes: 11 additions & 3 deletions libathemecore/packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
struct timeval burstime;
#endif

mowgli_eventloop_timer_t *ping_uplink_timer = NULL;

static void irc_recvq_handler(connection_t *cptr)
{
bool wasnonl;
Expand Down Expand Up @@ -77,7 +79,10 @@ static void ping_uplink(void *arg)
}

if (!me.connected)
event_delete(ping_uplink, NULL);
{
mowgli_timer_destroy(base_eventloop, ping_uplink_timer);
ping_uplink_timer = NULL;
}
}

void irc_handle_connect(connection_t *cptr)
Expand All @@ -104,8 +109,11 @@ void irc_handle_connect(connection_t *cptr)
ping_sts();

/* ping our uplink every 5 minutes */
event_delete(ping_uplink, NULL);
event_add("ping_uplink", ping_uplink, NULL, 300);
if (ping_uplink_timer != NULL)
mowgli_timer_destroy(base_eventloop, ping_uplink_timer);

ping_uplink_timer = mowgli_timer_add(base_eventloop, "ping_uplink", ping_uplink, NULL, 300);

me.uplinkpong = time(NULL);
}
}
Expand Down
Loading

0 comments on commit 0655145

Please sign in to comment.