]> code.citadel.org Git - citadel.git/blobdiff - citadel/event_client.h
libev migration - timeouts seem to be working.
[citadel.git] / citadel / event_client.h
index 39a9c11bebc57294fce34681e22484c6755a25aa..c5761ffae482c27ceee0cc73e04f09f329b1b981 100644 (file)
@@ -16,7 +16,7 @@ typedef enum _eNextState {
 }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);
@@ -30,12 +30,16 @@ struct AsyncIO {
        struct addrinfo *curr_ai;
 
        /* connection related */
+       int IP6;
+       struct hostent *HEnt;
        int sock;
-       int active_event;
+       unsigned short dport;
                eNextState NextState;
+
+       ev_timer conn_fail, 
+               conn_timeout;
        ev_io recv_event, 
-               send_event, 
-               conn_event;
+               send_event;
        StrBuf *ErrMsg; /* if we fail to connect, or lookup, error goes here. */
 
        /* read/send related... */
@@ -48,15 +52,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;
@@ -83,8 +92,12 @@ void InitEventIO(AsyncIO *IO,
                 IO_CallBack Terminate, 
                 IO_CallBack Timeout, 
                 IO_CallBack ConnFail, 
-                IO_CallBack CustomDNS,
                 IO_LineReaderCallback LineReader,
+                int conn_timeout, int 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, int timeout);