Skip to content

Commit

Permalink
constify; some windows stuff by mike davis; fix a poll bug
Browse files Browse the repository at this point in the history
svn:r77
  • Loading branch information
provos committed Sep 25, 2003
1 parent dd0b36a commit e506eaf
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
20 changes: 13 additions & 7 deletions event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -102,7 +108,7 @@ struct eventop *eventops[] = {
NULL
};

struct eventop *evsel;
const struct eventop *evsel;
void *evbase;

/* Handle signals */
Expand Down
17 changes: 15 additions & 2 deletions event.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion kqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion select.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e506eaf

Please sign in to comment.