#include "event.h"
#ifdef HAVE_SELECT
-extern struct eventop selectops;
+extern const struct eventop selectops;
#endif
#ifdef HAVE_POLL
-extern struct eventop pollops;
+extern const struct eventop pollops;
+#endif
+#ifdef HAVE_RTSIG
+extern const struct eventop rtsigops;
#endif
#ifdef HAVE_EPOLL
-extern struct eventop epollops;
+extern const struct eventop epollops;
#endif
#ifdef HAVE_WORKING_KQUEUE
-extern struct eventop kqops;
+extern const struct eventop kqops;
#endif
#ifdef WIN32
-extern struct eventop win32ops;
+extern const struct eventop win32ops;
#endif
/* In order of preference */
-struct eventop *eventops[] = {
+const struct eventop *eventops[] = {
#ifdef HAVE_WORKING_KQUEUE
&kqops,
#endif
#ifdef HAVE_EPOLL
&epollops,
#endif
+#ifdef HAVE_RTSIG
+ &rtsigops,
+#endif
#ifdef HAVE_POLL
&pollops,
#endif
NULL
};
-struct eventop *evsel;
+const struct eventop *evsel;
void *evbase;
/* Handle signals */
extern "C" {
#endif
+#ifdef WIN32
+#include <windows.h>
+#endif
+
#define EVLIST_TIMEOUT 0x01
#define EVLIST_INSERTED 0x02
#define EVLIST_SIGNAL 0x04
TAILQ_ENTRY (event) ev_signal_next;
RB_ENTRY (event) ev_timeout_node;
+#ifdef WIN32
+ HANDLE ev_fd;
+ OVERLAPPED overlap;
+#else
int ev_fd;
+#endif
short ev_events;
short ev_ncalls;
short *ev_pncalls; /* Allows deletes in callback */
int ev_flags;
};
-#define EVENT_SIGNAL(ev) ev->ev_fd
-#define EVENT_FD(ev) ev->ev_fd
+#define EVENT_SIGNAL(ev) (int)ev->ev_fd
+#define EVENT_FD(ev) (int)ev->ev_fd
#ifdef _EVENT_DEFINED_TQENTRY
#undef TAILQ_ENTRY
int event_pending(struct event *, short, struct timeval *);
+#ifdef WIN32
+#define event_initialized(ev) ((ev)->ev_flags & EVLIST_INIT && (ev)->ev_fd != INVALID_HANDLE_VALUE)
+#else
#define event_initialized(ev) ((ev)->ev_flags & EVLIST_INIT)
+#endif
#ifdef __cplusplus
}
int kq_dispatch (void *, struct timeval *);
int kq_insert (struct kqop *, struct kevent *);
-struct eventop kqops = {
+const struct eventop kqops = {
"kqueue",
kq_init,
kq_add,
for (i = 0; i < nfds; i++) {
res = 0;
+ /* If the file gets closed notify */
+ if (pop->event_set[i].revents & POLLHUP)
+ pop->event_set[i].revents = POLLIN|POLLOUT;
if (pop->event_set[i].revents & POLLIN)
res = EV_READ;
else if (pop->event_set[i].revents & POLLOUT)
int select_recalc (void *, int);
int select_dispatch (void *, struct timeval *);
-struct eventop selectops = {
+const struct eventop selectops = {
"select",
select_init,
select_add,