[IOMultiplexer] Added asynchronous DNS Lookups
[IOMultiplexer.git] / src / IOHandler.h
index eb32cdc71ab345ca8961e4e411b72acfa8064cef..b52f55260bc043f6ab8bf213114c45d6315d1568 100644 (file)
@@ -27,6 +27,8 @@ struct timeval;
 struct IODescriptor;
 struct IOEvent;
 struct IOSSLNode;
+struct IODNSQuery;
+struct IODNSEvent;
 
 enum IOLogType {
     IOLOG_DEBUG,
@@ -52,6 +54,7 @@ enum IOType {
 };
 
 enum IOStatus { 
+    IO_PENDING, /* descriptor is initializing */
     IO_CLOSED, /* descriptor is dead (socket waiting for removal or timer) */
     IO_LISTENING, /* descriptor is waiting for connections (server socket) */
     IO_CONNECTING, /* descriptor is waiting for connection approval (connecting client socket) */
@@ -66,10 +69,14 @@ enum IOEventType {
     IOEVENT_CONNECTED, /* client socket connected successful */
     IOEVENT_NOTCONNECTED, /* client socket could not connect (errid valid) */
     IOEVENT_CLOSED, /* client socket lost connection (errid valid) */
-    IOEVENT_ACCEPT, /* server socket accepted new connection (accept_fd valid) */
+    IOEVENT_ACCEPT, /* server socket accepted new connection (accept_iofd valid) */
     IOEVENT_SSLACCEPT, /* SSL server socket accepted new connection (accept_iofd valid) */
     IOEVENT_TIMEOUT, /* timer timed out */
-    IOEVENT_SSLFAILED /* failed to initialize SSL session */
+    IOEVENT_SSLFAILED, /* failed to initialize SSL session */
+    IOEVENT_DNS_FAILED,
+    IOEVENT_SOCKET_ERROR, /* socket() call failed (errid valid) */
+    IOEVENT_BIND_ERROR, /* bind() call failed (errid valid) */
+    
 };
 
 struct IOBuffer {
@@ -77,11 +84,16 @@ struct IOBuffer {
     size_t bufpos, buflen;
 };
 
+struct IOLowlevelDescriptor;
+
 struct IODescriptor {
-    int fd;
+    union {
+        struct IOLowlevelDescriptor *iold;
+        struct IODescriptorStartup *iostartup;
+    } fd;
+    unsigned int flags; /* internal flags! see IOEngine.h  */
     enum IOType type;
     enum IOStatus state;
-    struct timeval timeout;
     int constant_timeout;
     iohandler_callback *callback;
     struct IOBuffer readbuf;
@@ -93,9 +105,8 @@ struct IODescriptor {
     int ssl_active : 1;
     int ssl_hs_read : 1;
     int ssl_hs_write : 1;
-    struct IOSSLNode *sslnode;
-    
-    struct IODescriptor *next, *prev;
+    int iofd_free_lock : 1;
+    int iofd_want_free : 1;
 };
 
 struct IOEvent {
@@ -103,7 +114,6 @@ struct IOEvent {
     struct IODescriptor *iofd;
     union {
         char *recv_str;
-        int accept_fd;
         int errid;
         struct IODescriptor *accept_iofd;
     } data;