OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2000-2004 Niels Provos <provos@citi.umich.edu> | 2 * Copyright 2000-2004 Niels Provos <provos@citi.umich.edu> |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 15 matching lines...) Expand all Loading... |
26 */ | 26 */ |
27 #ifdef HAVE_CONFIG_H | 27 #ifdef HAVE_CONFIG_H |
28 #include "config.h" | 28 #include "config.h" |
29 #endif | 29 #endif |
30 | 30 |
31 #include <sys/types.h> | 31 #include <sys/types.h> |
32 #include <sys/resource.h> | 32 #include <sys/resource.h> |
33 #ifdef HAVE_SYS_TIME_H | 33 #ifdef HAVE_SYS_TIME_H |
34 #include <sys/time.h> | 34 #include <sys/time.h> |
35 #else | 35 #else |
36 #include <sys/_time.h> | 36 #include <sys/_libevent_time.h> |
37 #endif | 37 #endif |
38 #include <sys/queue.h> | 38 #include <sys/queue.h> |
39 #include <sys/devpoll.h> | 39 #include <sys/devpoll.h> |
40 #include <signal.h> | 40 #include <signal.h> |
41 #include <stdio.h> | 41 #include <stdio.h> |
42 #include <stdlib.h> | 42 #include <stdlib.h> |
43 #include <string.h> | 43 #include <string.h> |
44 #include <unistd.h> | 44 #include <unistd.h> |
45 #include <fcntl.h> | 45 #include <fcntl.h> |
46 #include <errno.h> | 46 #include <errno.h> |
(...skipping 21 matching lines...) Expand all Loading... |
68 struct pollfd *changes; | 68 struct pollfd *changes; |
69 int nchanges; | 69 int nchanges; |
70 }; | 70 }; |
71 | 71 |
72 static void *devpoll_init (struct event_base *); | 72 static void *devpoll_init (struct event_base *); |
73 static int devpoll_add (void *, struct event *); | 73 static int devpoll_add (void *, struct event *); |
74 static int devpoll_del (void *, struct event *); | 74 static int devpoll_del (void *, struct event *); |
75 static int devpoll_dispatch (struct event_base *, void *, struct timeval *); | 75 static int devpoll_dispatch (struct event_base *, void *, struct timeval *); |
76 static void devpoll_dealloc (struct event_base *, void *); | 76 static void devpoll_dealloc (struct event_base *, void *); |
77 | 77 |
78 struct eventop devpollops = { | 78 const struct eventop devpollops = { |
79 "devpoll", | 79 "devpoll", |
80 devpoll_init, | 80 devpoll_init, |
81 devpoll_add, | 81 devpoll_add, |
82 devpoll_del, | 82 devpoll_del, |
83 devpoll_dispatch, | 83 devpoll_dispatch, |
84 devpoll_dealloc, | 84 devpoll_dealloc, |
85 1 /* need reinit */ | 85 1 /* need reinit */ |
86 }; | 86 }; |
87 | 87 |
88 #define NEVENT 32000 | 88 #define NEVENT 32000 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 124 } |
125 | 125 |
126 static void * | 126 static void * |
127 devpoll_init(struct event_base *base) | 127 devpoll_init(struct event_base *base) |
128 { | 128 { |
129 int dpfd, nfiles = NEVENT; | 129 int dpfd, nfiles = NEVENT; |
130 struct rlimit rl; | 130 struct rlimit rl; |
131 struct devpollop *devpollop; | 131 struct devpollop *devpollop; |
132 | 132 |
133 /* Disable devpoll when this environment variable is set */ | 133 /* Disable devpoll when this environment variable is set */ |
134 » if (getenv("EVENT_NODEVPOLL")) | 134 » if (evutil_getenv("EVENT_NODEVPOLL")) |
135 return (NULL); | 135 return (NULL); |
136 | 136 |
137 if (!(devpollop = calloc(1, sizeof(struct devpollop)))) | 137 if (!(devpollop = calloc(1, sizeof(struct devpollop)))) |
138 return (NULL); | 138 return (NULL); |
139 | 139 |
140 if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && | 140 if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && |
141 rl.rlim_cur != RLIM_INFINITY) | 141 rl.rlim_cur != RLIM_INFINITY) |
142 nfiles = rl.rlim_cur; | 142 nfiles = rl.rlim_cur; |
143 | 143 |
144 /* Initialize the kernel queue */ | 144 /* Initialize the kernel queue */ |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 if (devpollop->events) | 408 if (devpollop->events) |
409 free(devpollop->events); | 409 free(devpollop->events); |
410 if (devpollop->changes) | 410 if (devpollop->changes) |
411 free(devpollop->changes); | 411 free(devpollop->changes); |
412 if (devpollop->dpfd >= 0) | 412 if (devpollop->dpfd >= 0) |
413 close(devpollop->dpfd); | 413 close(devpollop->dpfd); |
414 | 414 |
415 memset(devpollop, 0, sizeof(struct devpollop)); | 415 memset(devpollop, 0, sizeof(struct devpollop)); |
416 free(devpollop); | 416 free(devpollop); |
417 } | 417 } |
OLD | NEW |