diff options
Diffstat (limited to 'src/fdevent_solaris_devpoll.c')
-rw-r--r-- | src/fdevent_solaris_devpoll.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/fdevent_solaris_devpoll.c b/src/fdevent_solaris_devpoll.c index f77daef..91238b0 100644 --- a/src/fdevent_solaris_devpoll.c +++ b/src/fdevent_solaris_devpoll.c @@ -23,55 +23,55 @@ static void fdevent_solaris_devpoll_free(fdevents *ev) { static int fdevent_solaris_devpoll_event_del(fdevents *ev, int fde_ndx, int fd) { struct pollfd pfd; - + if (fde_ndx < 0) return -1; - + pfd.fd = fd; pfd.events = POLLREMOVE; pfd.revents = 0; - + if (-1 == write(ev->devpoll_fd, &pfd, sizeof(pfd))) { - fprintf(stderr, "%s.%d: (del) write failed: (%d, %s)\n", - __FILE__, __LINE__, + fprintf(stderr, "%s.%d: (del) write failed: (%d, %s)\n", + __FILE__, __LINE__, fd, strerror(errno)); - + return -1; } - + return -1; } static int fdevent_solaris_devpoll_event_add(fdevents *ev, int fde_ndx, int fd, int events) { struct pollfd pfd; int add = 0; - + if (fde_ndx == -1) add = 1; - + pfd.fd = fd; pfd.events = events; pfd.revents = 0; - + if (-1 == write(ev->devpoll_fd, &pfd, sizeof(pfd))) { - fprintf(stderr, "%s.%d: (del) write failed: (%d, %s)\n", - __FILE__, __LINE__, + fprintf(stderr, "%s.%d: (del) write failed: (%d, %s)\n", + __FILE__, __LINE__, fd, strerror(errno)); - + return -1; } - + return fd; } static int fdevent_solaris_devpoll_poll(fdevents *ev, int timeout_ms) { struct dvpoll dopoll; int ret; - + dopoll.dp_timeout = timeout_ms; dopoll.dp_nfds = ev->maxfds; dopoll.dp_fds = ev->devpollfds; - + ret = ioctl(ev->devpoll_fd, DP_POLL, &dopoll); - + return ret; } @@ -85,11 +85,11 @@ static int fdevent_solaris_devpoll_event_get_fd(fdevents *ev, size_t ndx) { static int fdevent_solaris_devpoll_event_next_fdndx(fdevents *ev, int last_ndx) { size_t i; - + UNUSED(ev); i = (last_ndx < 0) ? 0 : last_ndx + 1; - + return i; } @@ -117,20 +117,20 @@ int fdevent_solaris_devpoll_init(fdevents *ev) { ev->type = FDEVENT_HANDLER_SOLARIS_DEVPOLL; #define SET(x) \ ev->x = fdevent_solaris_devpoll_##x; - + SET(free); SET(poll); SET(reset); - + SET(event_del); SET(event_add); - + SET(event_next_fdndx); SET(event_get_fd); SET(event_get_revent); - + ev->devpollfds = malloc(sizeof(*ev->devpollfds) * ev->maxfds); - + if ((ev->devpoll_fd = open("/dev/poll", O_RDWR)) < 0) { fprintf(stderr, "%s.%d: opening /dev/poll failed (%s), try to set server.event-handler = \"poll\" or \"select\"\n", __FILE__, __LINE__, strerror(errno)); @@ -152,7 +152,7 @@ int fdevent_solaris_devpoll_init(fdevents *ev) { fprintf(stderr, "%s.%d: solaris-devpoll not supported, try to set server.event-handler = \"poll\" or \"select\"\n", __FILE__, __LINE__); - + return -1; } #endif |