X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fevent_client.h;h=c949a6ce937c3517fe826b9db1463ce984c7ad41;hb=7cced4381b0497cf3d99a489bbb1a4f5375ded32;hp=dd334f9633311fd50c70435f7eb0eee1630843f4;hpb=b5b30adb3ece1aa3de706047de6ba0245eea74fc;p=citadel.git diff --git a/citadel/event_client.h b/citadel/event_client.h index dd334f963..c949a6ce9 100644 --- a/citadel/event_client.h +++ b/citadel/event_client.h @@ -1,6 +1,7 @@ #ifndef __EVENT_CLIENT_H__ #define __EVENT_CLIENT_H__ #define EV_COMPAT3 0 +#include "sysconfig.h" #include #include #include @@ -77,6 +78,21 @@ typedef struct _evcurl_request_data long httpcode; } evcurl_request_data; +/* DNS Related */ +typedef struct __evcares_data { + ev_io recv_event, + send_event; + ev_timer timeout; /* timeout while requesting ips */ +#ifdef DEBUG_CARES + short int SourcePort; +#endif + struct ares_options Options; + ares_channel Channel; + DNSQueryParts *Query; + + IO_CallBack Fail; /* the dns lookup didn't work out. */ +} evcares_data; + struct AsyncIO { long ID; eNextState NextState; @@ -111,25 +127,20 @@ struct AsyncIO { Terminate, /* shutting down... */ Timeout, /* Timeout handler; may also be connection timeout */ ConnFail, /* What to do when one connection failed? */ - DNSFail, /* the dns lookup didn't work out. */ ShutdownAbort,/* we're going down. make your piece. */ NextDBOperation; /* Perform Database IO */ IO_LineReaderCallback LineReader; /* if we have linereaders, maybe we want to read more lines before the real application logic is called? */ - /* DNS Related */ - ev_io dns_recv_event, - dns_send_event; - struct ares_options DNSOptions; - ares_channel DNSChannel; - DNSQueryParts *DNSQuery; - + evcares_data DNS; + evcurl_request_data HttpReq; /* Saving / loading a message async from / to disk */ ReadAsyncMsg *ReadMsg; struct CtdlMessage *AsyncMsg; struct recptypes *AsyncRcp; + /* Custom data; its expected to contain AsyncIO so we can save malloc()s... */ void *Data; /* application specific data */ void *CitContext; /* Citadel Session context... */ @@ -140,8 +151,12 @@ typedef struct _IOAddHandler { IO_CallBack EvAttch; }IOAddHandler; -#define EV_syslog(LEVEL, FORMAT, ...) syslog(LEVEL, "IO[%ld]" FORMAT, IO->ID, __VA_ARGS__) -#define EVM_syslog(LEVEL, FORMAT) syslog(LEVEL, "IO[%ld]" FORMAT, IO->ID) +#define CCID ((CitContext*)IO->CitContext)->cs_pid +#define EV_syslog(LEVEL, FORMAT, ...) syslog(LEVEL, "IO[%ld]CC[%d]" FORMAT, IO->ID, CCID, __VA_ARGS__) +#define EVM_syslog(LEVEL, FORMAT) syslog(LEVEL, "IO[%ld]CC[%d]" FORMAT, IO->ID, CCID) + +#define EVNC_syslog(LEVEL, FORMAT, ...) syslog(LEVEL, "IO[%ld]" FORMAT, IO->ID, __VA_ARGS__) +#define EVNCM_syslog(LEVEL, FORMAT) syslog(LEVEL, "IO[%ld]" FORMAT, IO->ID) void FreeAsyncIOContents(AsyncIO *IO); @@ -149,13 +164,11 @@ eNextState NextDBOperation(AsyncIO *IO, IO_CallBack CB); eNextState QueueDBOperation(AsyncIO *IO, IO_CallBack CB); eNextState QueueEventContext(AsyncIO *IO, IO_CallBack CB); eNextState QueueCurlContext(AsyncIO *IO); -int ShutDownEventQueue(void); -eNextState InitEventIO(AsyncIO *IO, - void *pData, - double conn_timeout, - double first_rw_timeout, - int ReadFirst); +eNextState EvConnectSock(AsyncIO *IO, + double conn_timeout, + double first_rw_timeout, + int ReadFirst); void IO_postdns_callback(struct ev_loop *loop, ev_idle *watcher, int revents); int QueueQuery(ns_type Type, const char *name, AsyncIO *IO, DNSQueryParts *QueryParts, IO_CallBack PostDNS); @@ -187,6 +200,18 @@ int evcurl_init(AsyncIO *IO, IO_CallBack Terminate, IO_CallBack ShutdownAbort); +void InitIOStruct(AsyncIO *IO, + void *Data, + eNextState NextState, + IO_LineReaderCallback LineReader, + IO_CallBack DNS_Fail, + IO_CallBack SendDone, + IO_CallBack ReadDone, + IO_CallBack Terminate, + IO_CallBack ConnFail, + IO_CallBack Timeout, + IO_CallBack ShutdownAbort); + eNextState ReAttachIO(AsyncIO *IO, void *pData, int ReadFirst);