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

Comparing libev/ev.c (file contents):
Revision 1.30 by root, Thu Nov 1 08:28:33 2007 UTC vs.
Revision 1.32 by root, Thu Nov 1 09:21:51 2007 UTC

58 58
59#ifndef EV_USE_EPOLL 59#ifndef EV_USE_EPOLL
60# define EV_USE_EPOLL 0 60# define EV_USE_EPOLL 0
61#endif 61#endif
62 62
63#ifndef CLOCK_REALTIME
64# define EV_USE_REALTIME 0
65#endif
63#ifndef EV_USE_REALTIME 66#ifndef EV_USE_REALTIME
64# define EV_USE_REALTIME 1 /* posix requirement, but might be slower */ 67# define EV_USE_REALTIME 1 /* posix requirement, but might be slower */
65#endif 68#endif
66 69
67#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */ 70#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */
68#define MAX_BLOCKTIME 59.731 71#define MAX_BLOCKTIME 59.731 /* never wait longer than this time (to detetc time jumps) */
69#define PID_HASHSIZE 16 /* size of pid hahs table, must be power of two */ 72#define PID_HASHSIZE 16 /* size of pid hash table, must be power of two */
73#define CLEANUP_INTERVAL (MAX_BLOCKTIME * 5.) /* how often to try to free memory and re-check fds */
70 74
71#include "ev.h" 75#include "ev.h"
72 76
73typedef struct ev_watcher *W; 77typedef struct ev_watcher *W;
74typedef struct ev_watcher_list *WL; 78typedef struct ev_watcher_list *WL;
164static int pendingmax, pendingcnt; 168static int pendingmax, pendingcnt;
165 169
166static void 170static void
167event (W w, int events) 171event (W w, int events)
168{ 172{
173 if (w->pending)
174 {
175 pendings [w->pending - 1].events |= events;
176 return;
177 }
178
169 w->pending = ++pendingcnt; 179 w->pending = ++pendingcnt;
170 array_needsize (pendings, pendingmax, pendingcnt, ); 180 array_needsize (pendings, pendingmax, pendingcnt, );
171 pendings [pendingcnt - 1].w = w; 181 pendings [pendingcnt - 1].w = w;
172 pendings [pendingcnt - 1].events = events; 182 pendings [pendingcnt - 1].events = events;
173} 183}
251 for (fd = 0; fd < anfdmax; ++fd) 261 for (fd = 0; fd < anfdmax; ++fd)
252 if (anfds [fd].events) 262 if (anfds [fd].events)
253 if (fcntl (fd, F_GETFD) == -1 && errno == EBADF) 263 if (fcntl (fd, F_GETFD) == -1 && errno == EBADF)
254 while (anfds [fd].head) 264 while (anfds [fd].head)
255 { 265 {
266 ev_io_stop (anfds [fd].head);
256 event ((W)anfds [fd].head, EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT); 267 event ((W)anfds [fd].head, EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT);
257 ev_io_stop (anfds [fd].head);
258 } 268 }
259} 269}
260 270
261/*****************************************************************************/ 271/*****************************************************************************/
262 272

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines