constify; some windows stuff by mike davis; fix a poll bug

svn:r77
This commit is contained in:
Niels Provos 2003-09-25 03:26:53 +00:00
parent dd0b36ab03
commit e506eaf79e
5 changed files with 33 additions and 11 deletions

20
event.c
View File

@ -67,29 +67,35 @@
#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
@ -102,7 +108,7 @@ struct eventop *eventops[] = {
NULL
};
struct eventop *evsel;
const struct eventop *evsel;
void *evbase;
/* Handle signals */

17
event.h
View File

@ -36,6 +36,10 @@
extern "C" {
#endif
#ifdef WIN32
#include <windows.h>
#endif
#define EVLIST_TIMEOUT 0x01
#define EVLIST_INSERTED 0x02
#define EVLIST_SIGNAL 0x04
@ -77,7 +81,12 @@ struct event {
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 */
@ -91,8 +100,8 @@ struct event {
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
@ -153,7 +162,11 @@ void event_active(struct event *, int, short);
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
}

View File

@ -90,7 +90,7 @@ int kq_recalc (void *, int);
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,

3
poll.c
View File

@ -193,6 +193,9 @@ poll_dispatch(void *arg, struct timeval *tv)
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)

View File

@ -80,7 +80,7 @@ int select_del (void *, struct event *);
int select_recalc (void *, int);
int select_dispatch (void *, struct timeval *);
struct eventop selectops = {
const struct eventop selectops = {
"select",
select_init,
select_add,