ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev_kqueue.c
(Generate patch)

Comparing libev/ev_kqueue.c (file contents):
Revision 1.37 by root, Fri Jul 10 00:36:21 2009 UTC vs.
Revision 1.41 by root, Wed Jan 13 12:44:33 2010 UTC

1/* 1/*
2 * libev kqueue backend 2 * libev kqueue backend
3 * 3 *
4 * Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de> 4 * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without modifica- 7 * Redistribution and use in source and binary forms, with or without modifica-
8 * tion, are permitted provided that the following conditions are met: 8 * tion, are permitted provided that the following conditions are met:
9 * 9 *
37 * either the BSD or the GPL. 37 * either the BSD or the GPL.
38 */ 38 */
39 39
40#include <sys/types.h> 40#include <sys/types.h>
41#include <sys/time.h> 41#include <sys/time.h>
42#include <sys/queue.h>
43#include <sys/event.h> 42#include <sys/event.h>
44#include <string.h> 43#include <string.h>
45#include <errno.h> 44#include <errno.h>
46 45
47void inline_speed 46void inline_speed
83kqueue_poll (EV_P_ ev_tstamp timeout) 82kqueue_poll (EV_P_ ev_tstamp timeout)
84{ 83{
85 int res, i; 84 int res, i;
86 struct timespec ts; 85 struct timespec ts;
87 86
88 EV_SUSPEND_CB;
89
90 /* need to resize so there is enough space for errors */ 87 /* need to resize so there is enough space for errors */
91 if (kqueue_changecnt > kqueue_eventmax) 88 if (kqueue_changecnt > kqueue_eventmax)
92 { 89 {
93 ev_free (kqueue_events); 90 ev_free (kqueue_events);
94 kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_changecnt); 91 kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_changecnt);
95 kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); 92 kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax);
96 } 93 }
97 94
95 EV_RELEASE_CB;
98 ts.tv_sec = (time_t)timeout; 96 ts.tv_sec = (time_t)timeout;
99 ts.tv_nsec = (long)((timeout - (ev_tstamp)ts.tv_sec) * 1e9); 97 ts.tv_nsec = (long)((timeout - (ev_tstamp)ts.tv_sec) * 1e9);
100 res = kevent (backend_fd, kqueue_changes, kqueue_changecnt, kqueue_events, kqueue_eventmax, &ts); 98 res = kevent (backend_fd, kqueue_changes, kqueue_changecnt, kqueue_events, kqueue_eventmax, &ts);
99 EV_ACQUIRE_CB;
101 kqueue_changecnt = 0; 100 kqueue_changecnt = 0;
102
103 EV_RESUME_CB;
104 101
105 if (expect_false (res < 0)) 102 if (expect_false (res < 0))
106 { 103 {
107 if (errno != EINTR) 104 if (errno != EINTR)
108 ev_syserr ("(libev) kevent"); 105 ev_syserr ("(libev) kevent");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines