#define IODESYNCHRONIZE(var)
#endif
-struct IODescriptor;
-enum IOType;
-enum IOStatus;
-enum IOEventType;
-
#define timeval_is_bigger(x,y) ((x->tv_sec > y->tv_sec) || (x->tv_sec == y->tv_sec && x->tv_usec > y->tv_usec))
#define timeval_is_smaler(x,y) ((x->tv_sec < y->tv_sec) || (x->tv_sec == y->tv_sec && x->tv_usec < y->tv_usec))
-extern struct IODescriptor *first_descriptor;
-extern struct IODescriptor *timer_priority;
+
+struct IODescriptor;
+struct IOLowlevelDescriptor;
+
+extern struct IOLowlevelDescriptor *first_descriptor;
+extern struct IOLowlevelDescriptor *timer_priority;
+extern struct IOLowlevelDescriptor *lowlevel_descriptor;
+
+#define IOLOWLEVEL_CALLBACK(NAME) void NAME(struct IOLowlevelDescriptor *iold, int can_read)
+typedef IOLOWLEVEL_CALLBACK(iolowlevel_callback);
+
+#define IOFLAGS_WANT_READ 0x01
+#define IOFLAGS_WANT_WRITE 0x02
+#define IOFLAGS_HAVE_IOFD 0x04
+#define IOFLAGS_HAVE_TIMEOUT 0x08
+
+#define IOFDFLAGS_HAVE_IOLD 0x01
+#define IOFDFLAGS_FREE_LOCK 0x02
+#define IOFDFLAGS_WANT_FREE 0x04
+#define IOFDFLAGS_SSL_ACTIVE 0x08
+#define IOFDFLAGS_SSL_SERVER_HS 0x10
+#define IOFDFLAGS_SSL_HS_READ 0x20
+#define IOFDFLAGS_SSL_HS_WRITE 0x40
+
+struct IOLowlevelDescriptor {
+ int fd;
+ unsigned int flags;
+ struct timeval timeout;
+ union {
+ struct IODescriptor *iofd;
+ iolowlevel_callback *callback;
+ } data;
+ struct IOLowlevelDescriptor *next, *prev;
+};
+
+#define IOLOWLEVEL_GET_IOFD(iold) ((iold->flags & IOFLAGS_HAVE_IOFD) ? iold->data.iofd : NULL)
+#define IODESCRIPTOR_GET_IOLD(iofd) ((iofd->flags & IOFDFLAGS_HAVE_IOLD) ? iofd->fd.iold : NULL)
struct IOEngine {
const char *name;
int (*init)(void);
- void (*add)(struct IODescriptor *iofd);
- void (*remove)(struct IODescriptor *iofd);
- void (*update)(struct IODescriptor *iofd);
+ void (*add)(struct IOLowlevelDescriptor *iofd);
+ void (*remove)(struct IOLowlevelDescriptor *iofd);
+ void (*update)(struct IOLowlevelDescriptor *iofd);
void (*loop)(struct timeval *timeout);
void (*cleanup)(void);
};
char *iohandler_iostatus_name(enum IOStatus status);
char *iohandler_ioeventtype_name(enum IOEventType type);
+struct IOLowlevelDescriptor *iohandler_lowlevel_add(int fd, int want_read, int want_write, iolowlevel_callback *callback);
+void iohandler_lowlevel_update(struct IOLowlevelDescriptor *iolow, int want_read, int want_write);
+void iohandler_lowlevel_del(struct IOLowlevelDescriptor *iolow);
+
#endif