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.33 by root, Tue Dec 25 07:05:45 2007 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 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
91 ev_free (kqueue_events); 90 ev_free (kqueue_events);
92 kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_changecnt); 91 kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_changecnt);
93 kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); 92 kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax);
94 } 93 }
95 94
95 EV_RELEASE_CB;
96 ts.tv_sec = (time_t)timeout; 96 ts.tv_sec = (time_t)timeout;
97 ts.tv_nsec = (long)((timeout - (ev_tstamp)ts.tv_sec) * 1e9); 97 ts.tv_nsec = (long)((timeout - (ev_tstamp)ts.tv_sec) * 1e9);
98 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;
99 kqueue_changecnt = 0; 100 kqueue_changecnt = 0;
100 101
101 if (expect_false (res < 0)) 102 if (expect_false (res < 0))
102 { 103 {
103 if (errno != EINTR) 104 if (errno != EINTR)
104 syserr ("(libev) kevent"); 105 ev_syserr ("(libev) kevent");
105 106
106 return; 107 return;
107 } 108 }
108 109
109 for (i = 0; i < res; ++i) 110 for (i = 0; i < res; ++i)
182kqueue_fork (EV_P) 183kqueue_fork (EV_P)
183{ 184{
184 close (backend_fd); 185 close (backend_fd);
185 186
186 while ((backend_fd = kqueue ()) < 0) 187 while ((backend_fd = kqueue ()) < 0)
187 syserr ("(libev) kqueue"); 188 ev_syserr ("(libev) kqueue");
188 189
189 fcntl (backend_fd, F_SETFD, FD_CLOEXEC); 190 fcntl (backend_fd, F_SETFD, FD_CLOEXEC);
190 191
191 /* re-register interest in fds */ 192 /* re-register interest in fds */
192 fd_rearm_all (EV_A); 193 fd_rearm_all (EV_A);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines