HashList *InboundEventQueue = NULL;
HashList *InboundEventQueues[2] = { NULL, NULL };
-static struct event_base *event_base;
-struct event queue_add_event;
+struct ev_loop *event_base;
+struct ev_io queue_add_event;
-static void QueueEventAddCallback(int fd, short event, void *ctx)
+static void QueueEventAddCallback(struct ev_loop *loop, ev_io *watcher, int revents)
{
char buf[10];
HashList *q;
const char *Key;
/* get the control command... */
- read(fd, buf, 1);
+ read(watcher->fd, buf, 1);
switch (buf[0]) {
case '+':
citthread_mutex_lock(&EventQueueMutex);
/// TODO: add it to QueueEvents
break;
case 'x':
- event_del(&queue_add_event);
+ /////event_del(&queue_add_event);
close(event_add_pipe[0]);
/// TODO; flush QueueEvents fd's and delete it.
- event_base_loopexit(event_base, NULL);
+ ev_io_stop(event_base, NULL);
}
/* Unblock the other side */
// read(fd, buf, 1);
{
struct rlimit LimitSet;
- event_base = event_init();
+ event_base = ev_default_loop(0);
/*
base = event_base_new();
if (!base)
citthread_mutex_init(&EventQueueMutex, NULL);
if (pipe(event_add_pipe) != 0) {
- CtdlLogPrintf(CTDL_EMERG, "Unable to create pipe for libevent queueing: %s\n", strerror(errno));
+ CtdlLogPrintf(CTDL_EMERG, "Unable to create pipe for libev queueing: %s\n", strerror(errno));
abort();
}
LimitSet.rlim_cur = 1;
InboundEventQueue = InboundEventQueues[0];
}
/*
- * this thread operates the select() etc. via libevent.
+ * this thread operates the select() etc. via libev.
*
*
*/
void *client_event_thread(void *arg)
{
struct CitContext libevent_client_CC;
+
CtdlFillSystemContext(&libevent_client_CC, "LibEvent Thread");
// citthread_setspecific(MyConKey, (void *)&smtp_queue_CC);
CtdlLogPrintf(CTDL_DEBUG, "client_event_thread() initializing\n");
-
+/*
event_set(&queue_add_event,
event_add_pipe[0],
EV_READ|EV_PERSIST,
NULL);
event_add(&queue_add_event, NULL);
+*/
+ ev_io_init(&queue_add_event, QueueEventAddCallback, event_add_pipe[0], EV_READ);
+ ev_io_start(event_base, &queue_add_event);
+
+ event_base = ev_default_loop (EVFLAG_AUTO);
+/// ev_loop(event_base, 0);
- event_dispatch();
CtdlClearSystemContext();
- event_base_free(event_base);
+ ev_default_destroy ();
citthread_mutex_destroy(&EventQueueMutex);
return(NULL);
}