]> code.citadel.org Git - citadel.git/blobdiff - citadel/event_client.h
libev migration: reinstantiate MX-Relay; unfinished.
[citadel.git] / citadel / event_client.h
index 3aec485a164655f70f54d544549e8878ae4ad257..7fe12d1a4c9d40971c6e8e5e75e82d9b4dff4d44 100644 (file)
@@ -15,8 +15,7 @@ typedef enum _eNextState {
        eAbort
 }eNextState;
 
-typedef int (*EventContextAttach)(void *Data);
-typedef eNextState (*IO_CallBack)(void *Data);
+typedef eNextState (*IO_CallBack)(AsyncIO *IO);
 typedef eReadState (*IO_LineReaderCallback)(AsyncIO *IO);
 typedef void (*ParseDNSAnswerCb)(AsyncIO*, unsigned char*, int);
 typedef void (*FreeDNSReply)(void *DNSData);
@@ -32,9 +31,14 @@ struct AsyncIO {
        /* connection related */
        int IP6;
        struct hostent *HEnt;
+       struct sockaddr_in6 Addr;
+
        int sock;
-       int active_event;
+       unsigned short dport;
                eNextState NextState;
+
+       ev_timer conn_fail, 
+               rw_timeout;
        ev_io recv_event, 
                send_event, 
                conn_event;
@@ -50,15 +54,20 @@ struct AsyncIO {
                SendDone,     /* we may send more data */
                Terminate,    /* shutting down... */
                Timeout,      /* Timeout handler; may also be connection timeout */
-               ConnFail,     /* What to do when one connection failed? */
-               CustomDNS;    /* If the application wants to do custom dns functionality like cycle through different MX-Records */
+               ConnFail;     /* What to do when one connection failed? */
 
        IO_LineReaderCallback LineReader; /* if we have linereaders, maybe we want to read more lines before the real application logic is called? */
 
+
+       int active_dns_event;
+       ev_io dns_recv_event, 
+               dns_send_event;
        struct ares_options DNSOptions;
        ares_channel DNSChannel;
+
        ParseDNSAnswerCb DNS_CB;
        IO_CallBack PostDNS;
+
        int DNSStatus;
        void *VParsedDNSReply;
        FreeDNSReply DNSReplyFree;
@@ -69,23 +78,22 @@ struct AsyncIO {
 };
 
 typedef struct _IOAddHandler {
-       void *Ctx;
-       EventContextAttach EvAttch;
+       AsyncIO *IO;
+       IO_CallBack EvAttch;
 }IOAddHandler; 
 
 void FreeAsyncIOContents(AsyncIO *IO);
 
-int QueueEventContext(void *Ctx, AsyncIO *IO, EventContextAttach CB);
+int QueueEventContext(AsyncIO *IO, IO_CallBack CB);
 int ShutDownEventQueue(void);
 
 void InitEventIO(AsyncIO *IO, 
                 void *pData, 
-                IO_CallBack ReadDone, 
-                IO_CallBack SendDone, 
-                IO_CallBack Terminate, 
-                IO_CallBack Timeout, 
-                IO_CallBack ConnFail, 
-                IO_LineReaderCallback LineReader,
+                double conn_timeout, double first_rw_timeout,
                 int ReadFirst);
 
 int QueueQuery(ns_type Type, char *name, AsyncIO *IO, IO_CallBack PostDNS);
+
+void StopClient(AsyncIO *IO);
+
+void SetNextTimeout(AsyncIO *IO, double timeout);