EV: stop all watchers before going into other queues - so we can avoid race conditions.
[citadel.git] / citadel / event_client.h
index 9c13039914c6338c49512a456629913828333470..b136c2e670a975d1516398c235fe18c347d82967 100644 (file)
 #include <ares.h>
 #include <curl/curl.h>
 
+#ifndef __ASYNCIO__
+#define __ASYNCIO__
 typedef struct AsyncIO AsyncIO;
+#endif
+#ifndef __CIT_CONTEXT__
+#define __CIT_CONTEXT__
+typedef struct CitContext CitContext;
+#endif
+
+typedef enum __eIOState { 
+       eDBQ,
+       eQDBNext,
+       eDBAttach,
+       eDBNext,
+       eDBStop,
+       eDBX,
+       eDBTerm,
+       eIOQ,
+       eIOAttach,
+       eIOConnectSock,
+       eIOAbort,
+       eIOTimeout,
+       eIOConnfail,
+       eIOConnfailNow,
+       eIOConnNow,
+       eIOConnWait,
+       eCurlQ,
+       eCurlStart,
+       eCurlShutdown,
+       eCurlNewIO,
+       eCurlGotIO,
+       eCurlGotData,
+       eCurlGotStatus,
+       eCaresStart,
+       eCaresDoneIO,
+       eCaresFinished,
+       eCaresX,
+       eKill,
+       eExit
+}eIOState;
 
 typedef enum _eNextState {
        eSendDNSQuery,
@@ -45,6 +84,8 @@ typedef enum _eNextState {
        eAbort
 }eNextState;
 
+void SetEVState(AsyncIO *IO, eIOState State);
+
 typedef eNextState (*IO_CallBack)(AsyncIO *IO);
 typedef eReadState (*IO_LineReaderCallback)(AsyncIO *IO);
 typedef void (*ParseDNSAnswerCb)(AsyncIO*, unsigned char*, int);
@@ -70,6 +111,8 @@ typedef struct _DNSQueryParts {
        ParseDNSAnswerCb DNS_CB;
        IO_CallBack PostDNS;
 
+       const char *QueryTYPE;
+       const char *QStr;
        int DNSStatus;
        void *VParsedDNSReply;
        FreeDNSReply DNSReplyFree;
@@ -164,7 +207,7 @@ struct AsyncIO {
 
        /* Context specific data; Hint: put AsyncIO in there */
        void *Data;        /* application specific data */
-       void *CitContext;  /* Citadel Session context... */
+       CitContext *CitContext;  /* Citadel Session context... */
 };
 
 typedef struct _IOAddHandler {
@@ -235,9 +278,11 @@ void FreeAsyncIOContents(AsyncIO *IO);
 
 eNextState NextDBOperation(AsyncIO *IO, IO_CallBack CB);
 eNextState QueueDBOperation(AsyncIO *IO, IO_CallBack CB);
+eNextState EventQueueDBOperation(AsyncIO *IO, IO_CallBack CB);
 void StopDBWatchers(AsyncIO *IO);
 eNextState QueueEventContext(AsyncIO *IO, IO_CallBack CB);
 eNextState QueueCurlContext(AsyncIO *IO);
+eNextState DBQueueEventContext(AsyncIO *IO, IO_CallBack CB);
 
 eNextState EvConnectSock(AsyncIO *IO,
                         double conn_timeout,
@@ -296,9 +341,10 @@ int InitcURLIOStruct(AsyncIO *IO,
                     IO_CallBack Terminate,
                     IO_CallBack DBTerminate,
                     IO_CallBack ShutdownAbort);
-
+void KillAsyncIOContext(AsyncIO *IO);
 void StopCurlWatchers(AsyncIO *IO);
 
+eNextState CurlQueueDBOperation(AsyncIO *IO, IO_CallBack CB);
 
 eNextState ReAttachIO(AsyncIO *IO,
                      void *pData,