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

Comparing libev/ev.c (file contents):
Revision 1.62 by root, Sun Nov 4 20:38:07 2007 UTC vs.
Revision 1.70 by root, Tue Nov 6 00:52:32 2007 UTC

145typedef struct ev_watcher_list *WL; 145typedef struct ev_watcher_list *WL;
146typedef struct ev_watcher_time *WT; 146typedef struct ev_watcher_time *WT;
147 147
148static int have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ 148static int have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */
149 149
150#if WIN32
151/* note: the comment below could not be substantiated, but what would I care */
152/* MSDN says this is required to handle SIGFPE */
153volatile double SIGFPE_REQ = 0.0f;
154#endif
155
150/*****************************************************************************/ 156/*****************************************************************************/
151 157
158static void (*syserr_cb)(const char *msg);
159
160void ev_set_syserr_cb (void (*cb)(const char *msg))
161{
162 syserr_cb = cb;
163}
164
165static void
166syserr (const char *msg)
167{
168 if (!msg)
169 msg = "(libev) system error";
170
171 if (syserr_cb)
172 syserr_cb (msg);
173 else
174 {
175 perror (msg);
176 abort ();
177 }
178}
179
180static void *(*alloc)(void *ptr, long size);
181
182void ev_set_allocator (void *(*cb)(void *ptr, long size))
183{
184 alloc = cb;
185}
186
187static void *
188ev_realloc (void *ptr, long size)
189{
190 ptr = alloc ? alloc (ptr, size) : realloc (ptr, size);
191
192 if (!ptr && size)
193 {
194 fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size);
195 abort ();
196 }
197
198 return ptr;
199}
200
201#define ev_malloc(size) ev_realloc (0, (size))
202#define ev_free(ptr) ev_realloc ((ptr), 0)
203
204/*****************************************************************************/
205
152typedef struct 206typedef struct
153{ 207{
154 struct ev_watcher_list *head; 208 WL head;
155 unsigned char events; 209 unsigned char events;
156 unsigned char reify; 210 unsigned char reify;
157} ANFD; 211} ANFD;
158 212
159typedef struct 213typedef struct
217 return rt_now; 271 return rt_now;
218} 272}
219 273
220#define array_roundsize(base,n) ((n) | 4 & ~3) 274#define array_roundsize(base,n) ((n) | 4 & ~3)
221 275
222#define array_needsize(base,cur,cnt,init) \ 276#define array_needsize(base,cur,cnt,init) \
223 if (expect_false ((cnt) > cur)) \ 277 if (expect_false ((cnt) > cur)) \
224 { \ 278 { \
225 int newcnt = cur; \ 279 int newcnt = cur; \
226 do \ 280 do \
227 { \ 281 { \
228 newcnt = array_roundsize (base, newcnt << 1); \ 282 newcnt = array_roundsize (base, newcnt << 1); \
229 } \ 283 } \
230 while ((cnt) > newcnt); \ 284 while ((cnt) > newcnt); \
231 \ 285 \
232 base = realloc (base, sizeof (*base) * (newcnt)); \ 286 base = ev_realloc (base, sizeof (*base) * (newcnt)); \
233 init (base + cur, newcnt - cur); \ 287 init (base + cur, newcnt - cur); \
234 cur = newcnt; \ 288 cur = newcnt; \
235 } 289 }
290
291#define array_slim(stem) \
292 if (stem ## max < array_roundsize (stem ## cnt >> 2)) \
293 { \
294 stem ## max = array_roundsize (stem ## cnt >> 1); \
295 base = ev_realloc (base, sizeof (*base) * (stem ## max)); \
296 fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\
297 }
298
299#define array_free(stem, idx) \
300 ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0;
236 301
237/*****************************************************************************/ 302/*****************************************************************************/
238 303
239static void 304static void
240anfds_init (ANFD *base, int count) 305anfds_init (ANFD *base, int count)
306 for (w = (struct ev_io *)anfd->head; w; w = (struct ev_io *)((WL)w)->next) 371 for (w = (struct ev_io *)anfd->head; w; w = (struct ev_io *)((WL)w)->next)
307 events |= w->events; 372 events |= w->events;
308 373
309 anfd->reify = 0; 374 anfd->reify = 0;
310 375
311 if (anfd->events != events)
312 {
313 method_modify (EV_A_ fd, anfd->events, events); 376 method_modify (EV_A_ fd, anfd->events, events);
314 anfd->events = events; 377 anfd->events = events;
315 }
316 } 378 }
317 379
318 fdchangecnt = 0; 380 fdchangecnt = 0;
319} 381}
320 382
321static void 383static void
322fd_change (EV_P_ int fd) 384fd_change (EV_P_ int fd)
323{ 385{
324 if (anfds [fd].reify || fdchangecnt < 0) 386 if (anfds [fd].reify)
325 return; 387 return;
326 388
327 anfds [fd].reify = 1; 389 anfds [fd].reify = 1;
328 390
329 ++fdchangecnt; 391 ++fdchangecnt;
362 int fd; 424 int fd;
363 425
364 for (fd = anfdmax; fd--; ) 426 for (fd = anfdmax; fd--; )
365 if (anfds [fd].events) 427 if (anfds [fd].events)
366 { 428 {
367 close (fd);
368 fd_kill (EV_A_ fd); 429 fd_kill (EV_A_ fd);
369 return; 430 return;
370 } 431 }
371} 432}
372 433
373/* susually called after fork if method needs to re-arm all fds from scratch */ 434/* usually called after fork if method needs to re-arm all fds from scratch */
374static void 435static void
375fd_rearm_all (EV_P) 436fd_rearm_all (EV_P)
376{ 437{
377 int fd; 438 int fd;
378 439
430 491
431/*****************************************************************************/ 492/*****************************************************************************/
432 493
433typedef struct 494typedef struct
434{ 495{
435 struct ev_watcher_list *head; 496 WL head;
436 sig_atomic_t volatile gotsig; 497 sig_atomic_t volatile gotsig;
437} ANSIG; 498} ANSIG;
438 499
439static ANSIG *signals; 500static ANSIG *signals;
440static int signalmax; 501static int signalmax;
456} 517}
457 518
458static void 519static void
459sighandler (int signum) 520sighandler (int signum)
460{ 521{
522#if WIN32
523 signal (signum, sighandler);
524#endif
525
461 signals [signum - 1].gotsig = 1; 526 signals [signum - 1].gotsig = 1;
462 527
463 if (!gotsig) 528 if (!gotsig)
464 { 529 {
465 int old_errno = errno; 530 int old_errno = errno;
470} 535}
471 536
472static void 537static void
473sigcb (EV_P_ struct ev_io *iow, int revents) 538sigcb (EV_P_ struct ev_io *iow, int revents)
474{ 539{
475 struct ev_watcher_list *w; 540 WL w;
476 int signum; 541 int signum;
477 542
478 read (sigpipe [0], &revents, 1); 543 read (sigpipe [0], &revents, 1);
479 gotsig = 0; 544 gotsig = 0;
480 545
522 struct ev_child *w; 587 struct ev_child *w;
523 588
524 for (w = (struct ev_child *)childs [chain & (PID_HASHSIZE - 1)]; w; w = (struct ev_child *)((WL)w)->next) 589 for (w = (struct ev_child *)childs [chain & (PID_HASHSIZE - 1)]; w; w = (struct ev_child *)((WL)w)->next)
525 if (w->pid == pid || !w->pid) 590 if (w->pid == pid || !w->pid)
526 { 591 {
527 w->priority = sw->priority; /* need to do it *now* */ 592 ev_priority (w) = ev_priority (sw); /* need to do it *now* */
528 w->rpid = pid; 593 w->rpid = pid;
529 w->rstatus = status; 594 w->rstatus = status;
530 event (EV_A_ (W)w, EV_CHILD); 595 event (EV_A_ (W)w, EV_CHILD);
531 } 596 }
532} 597}
533 598
534static void 599static void
631 if (!method && (methods & EVMETHOD_POLL )) method = poll_init (EV_A_ methods); 696 if (!method && (methods & EVMETHOD_POLL )) method = poll_init (EV_A_ methods);
632#endif 697#endif
633#if EV_USE_SELECT 698#if EV_USE_SELECT
634 if (!method && (methods & EVMETHOD_SELECT)) method = select_init (EV_A_ methods); 699 if (!method && (methods & EVMETHOD_SELECT)) method = select_init (EV_A_ methods);
635#endif 700#endif
701
702 ev_watcher_init (&sigev, sigcb);
703 ev_set_priority (&sigev, EV_MAXPRI);
636 } 704 }
637} 705}
638 706
639void 707void
640loop_destroy (EV_P) 708loop_destroy (EV_P)
641{ 709{
710 int i;
711
642#if EV_USE_WIN32 712#if EV_USE_WIN32
643 if (method == EVMETHOD_WIN32 ) win32_destroy (EV_A); 713 if (method == EVMETHOD_WIN32 ) win32_destroy (EV_A);
644#endif 714#endif
645#if EV_USE_KQUEUE 715#if EV_USE_KQUEUE
646 if (method == EVMETHOD_KQUEUE) kqueue_destroy (EV_A); 716 if (method == EVMETHOD_KQUEUE) kqueue_destroy (EV_A);
653#endif 723#endif
654#if EV_USE_SELECT 724#if EV_USE_SELECT
655 if (method == EVMETHOD_SELECT) select_destroy (EV_A); 725 if (method == EVMETHOD_SELECT) select_destroy (EV_A);
656#endif 726#endif
657 727
728 for (i = NUMPRI; i--; )
729 array_free (pending, [i]);
730
731 array_free (fdchange, );
732 array_free (timer, );
733 array_free (periodic, );
734 array_free (idle, );
735 array_free (prepare, );
736 array_free (check, );
737
658 method = 0; 738 method = 0;
659 /*TODO*/
660} 739}
661 740
662void 741static void
663loop_fork (EV_P) 742loop_fork (EV_P)
664{ 743{
665 /*TODO*/
666#if EV_USE_EPOLL 744#if EV_USE_EPOLL
667 if (method == EVMETHOD_EPOLL ) epoll_fork (EV_A); 745 if (method == EVMETHOD_EPOLL ) epoll_fork (EV_A);
668#endif 746#endif
669#if EV_USE_KQUEUE 747#if EV_USE_KQUEUE
670 if (method == EVMETHOD_KQUEUE) kqueue_fork (EV_A); 748 if (method == EVMETHOD_KQUEUE) kqueue_fork (EV_A);
671#endif 749#endif
750
751 if (ev_is_active (&sigev))
752 {
753 /* default loop */
754
755 ev_ref (EV_A);
756 ev_io_stop (EV_A_ &sigev);
757 close (sigpipe [0]);
758 close (sigpipe [1]);
759
760 while (pipe (sigpipe))
761 syserr ("(libev) error creating pipe");
762
763 siginit (EV_A);
764 }
765
766 postfork = 0;
672} 767}
673 768
674#if EV_MULTIPLICITY 769#if EV_MULTIPLICITY
675struct ev_loop * 770struct ev_loop *
676ev_loop_new (int methods) 771ev_loop_new (int methods)
677{ 772{
678 struct ev_loop *loop = (struct ev_loop *)calloc (1, sizeof (struct ev_loop)); 773 struct ev_loop *loop = (struct ev_loop *)ev_malloc (sizeof (struct ev_loop));
774
775 memset (loop, 0, sizeof (struct ev_loop));
679 776
680 loop_init (EV_A_ methods); 777 loop_init (EV_A_ methods);
681 778
682 if (ev_method (EV_A)) 779 if (ev_method (EV_A))
683 return loop; 780 return loop;
687 784
688void 785void
689ev_loop_destroy (EV_P) 786ev_loop_destroy (EV_P)
690{ 787{
691 loop_destroy (EV_A); 788 loop_destroy (EV_A);
692 free (loop); 789 ev_free (loop);
693} 790}
694 791
695void 792void
696ev_loop_fork (EV_P) 793ev_loop_fork (EV_P)
697{ 794{
698 loop_fork (EV_A); 795 postfork = 1;
699} 796}
700 797
701#endif 798#endif
702 799
703#if EV_MULTIPLICITY 800#if EV_MULTIPLICITY
726 823
727 loop_init (EV_A_ methods); 824 loop_init (EV_A_ methods);
728 825
729 if (ev_method (EV_A)) 826 if (ev_method (EV_A))
730 { 827 {
731 ev_watcher_init (&sigev, sigcb);
732 ev_set_priority (&sigev, EV_MAXPRI);
733 siginit (EV_A); 828 siginit (EV_A);
734 829
735#ifndef WIN32 830#ifndef WIN32
736 ev_signal_init (&childev, childcb, SIGCHLD); 831 ev_signal_init (&childev, childcb, SIGCHLD);
737 ev_set_priority (&childev, EV_MAXPRI); 832 ev_set_priority (&childev, EV_MAXPRI);
770{ 865{
771#if EV_MULTIPLICITY 866#if EV_MULTIPLICITY
772 struct ev_loop *loop = default_loop; 867 struct ev_loop *loop = default_loop;
773#endif 868#endif
774 869
775 loop_fork (EV_A); 870 if (method)
776 871 postfork = 1;
777 ev_io_stop (EV_A_ &sigev);
778 close (sigpipe [0]);
779 close (sigpipe [1]);
780 pipe (sigpipe);
781
782 ev_ref (EV_A); /* signal watcher */
783 siginit (EV_A);
784} 872}
785 873
786/*****************************************************************************/ 874/*****************************************************************************/
787 875
788static void 876static void
804} 892}
805 893
806static void 894static void
807timers_reify (EV_P) 895timers_reify (EV_P)
808{ 896{
809 while (timercnt && timers [0]->at <= mn_now) 897 while (timercnt && ((WT)timers [0])->at <= mn_now)
810 { 898 {
811 struct ev_timer *w = timers [0]; 899 struct ev_timer *w = timers [0];
812 900
813 assert (("inactive timer on timer heap detected", ev_is_active (w))); 901 assert (("inactive timer on timer heap detected", ev_is_active (w)));
814 902
815 /* first reschedule or stop timer */ 903 /* first reschedule or stop timer */
816 if (w->repeat) 904 if (w->repeat)
817 { 905 {
818 assert (("negative ev_timer repeat value found while processing timers", w->repeat > 0.)); 906 assert (("negative ev_timer repeat value found while processing timers", w->repeat > 0.));
819 w->at = mn_now + w->repeat; 907 ((WT)w)->at = mn_now + w->repeat;
820 downheap ((WT *)timers, timercnt, 0); 908 downheap ((WT *)timers, timercnt, 0);
821 } 909 }
822 else 910 else
823 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */ 911 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */
824 912
827} 915}
828 916
829static void 917static void
830periodics_reify (EV_P) 918periodics_reify (EV_P)
831{ 919{
832 while (periodiccnt && periodics [0]->at <= rt_now) 920 while (periodiccnt && ((WT)periodics [0])->at <= rt_now)
833 { 921 {
834 struct ev_periodic *w = periodics [0]; 922 struct ev_periodic *w = periodics [0];
835 923
836 assert (("inactive timer on periodic heap detected", ev_is_active (w))); 924 assert (("inactive timer on periodic heap detected", ev_is_active (w)));
837 925
838 /* first reschedule or stop timer */ 926 /* first reschedule or stop timer */
839 if (w->interval) 927 if (w->interval)
840 { 928 {
841 w->at += floor ((rt_now - w->at) / w->interval + 1.) * w->interval; 929 ((WT)w)->at += floor ((rt_now - ((WT)w)->at) / w->interval + 1.) * w->interval;
842 assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", w->at > rt_now)); 930 assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ((WT)w)->at > rt_now));
843 downheap ((WT *)periodics, periodiccnt, 0); 931 downheap ((WT *)periodics, periodiccnt, 0);
844 } 932 }
845 else 933 else
846 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */ 934 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */
847 935
859 { 947 {
860 struct ev_periodic *w = periodics [i]; 948 struct ev_periodic *w = periodics [i];
861 949
862 if (w->interval) 950 if (w->interval)
863 { 951 {
864 ev_tstamp diff = ceil ((rt_now - w->at) / w->interval) * w->interval; 952 ev_tstamp diff = ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval;
865 953
866 if (fabs (diff) >= 1e-4) 954 if (fabs (diff) >= 1e-4)
867 { 955 {
868 ev_periodic_stop (EV_A_ w); 956 ev_periodic_stop (EV_A_ w);
869 ev_periodic_start (EV_A_ w); 957 ev_periodic_start (EV_A_ w);
930 { 1018 {
931 periodics_reschedule (EV_A); 1019 periodics_reschedule (EV_A);
932 1020
933 /* adjust timers. this is easy, as the offset is the same for all */ 1021 /* adjust timers. this is easy, as the offset is the same for all */
934 for (i = 0; i < timercnt; ++i) 1022 for (i = 0; i < timercnt; ++i)
935 timers [i]->at += rt_now - mn_now; 1023 ((WT)timers [i])->at += rt_now - mn_now;
936 } 1024 }
937 1025
938 mn_now = rt_now; 1026 mn_now = rt_now;
939 } 1027 }
940} 1028}
966 { 1054 {
967 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); 1055 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE);
968 call_pending (EV_A); 1056 call_pending (EV_A);
969 } 1057 }
970 1058
1059 /* we might have forked, so reify kernel state if necessary */
1060 if (expect_false (postfork))
1061 loop_fork (EV_A);
1062
971 /* update fd-related kernel structures */ 1063 /* update fd-related kernel structures */
972 fd_reify (EV_A); 1064 fd_reify (EV_A);
973 1065
974 /* calculate blocking time */ 1066 /* calculate blocking time */
975 1067
991 { 1083 {
992 block = MAX_BLOCKTIME; 1084 block = MAX_BLOCKTIME;
993 1085
994 if (timercnt) 1086 if (timercnt)
995 { 1087 {
996 ev_tstamp to = timers [0]->at - mn_now + method_fudge; 1088 ev_tstamp to = ((WT)timers [0])->at - mn_now + method_fudge;
997 if (block > to) block = to; 1089 if (block > to) block = to;
998 } 1090 }
999 1091
1000 if (periodiccnt) 1092 if (periodiccnt)
1001 { 1093 {
1002 ev_tstamp to = periodics [0]->at - rt_now + method_fudge; 1094 ev_tstamp to = ((WT)periodics [0])->at - rt_now + method_fudge;
1003 if (block > to) block = to; 1095 if (block > to) block = to;
1004 } 1096 }
1005 1097
1006 if (block < 0.) block = 0.; 1098 if (block < 0.) block = 0.;
1007 } 1099 }
1124ev_timer_start (EV_P_ struct ev_timer *w) 1216ev_timer_start (EV_P_ struct ev_timer *w)
1125{ 1217{
1126 if (ev_is_active (w)) 1218 if (ev_is_active (w))
1127 return; 1219 return;
1128 1220
1129 w->at += mn_now; 1221 ((WT)w)->at += mn_now;
1130 1222
1131 assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); 1223 assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
1132 1224
1133 ev_start (EV_A_ (W)w, ++timercnt); 1225 ev_start (EV_A_ (W)w, ++timercnt);
1134 array_needsize (timers, timermax, timercnt, ); 1226 array_needsize (timers, timermax, timercnt, );
1151 { 1243 {
1152 timers [((W)w)->active - 1] = timers [timercnt]; 1244 timers [((W)w)->active - 1] = timers [timercnt];
1153 downheap ((WT *)timers, timercnt, ((W)w)->active - 1); 1245 downheap ((WT *)timers, timercnt, ((W)w)->active - 1);
1154 } 1246 }
1155 1247
1156 w->at = w->repeat; 1248 ((WT)w)->at = w->repeat;
1157 1249
1158 ev_stop (EV_A_ (W)w); 1250 ev_stop (EV_A_ (W)w);
1159} 1251}
1160 1252
1161void 1253void
1163{ 1255{
1164 if (ev_is_active (w)) 1256 if (ev_is_active (w))
1165 { 1257 {
1166 if (w->repeat) 1258 if (w->repeat)
1167 { 1259 {
1168 w->at = mn_now + w->repeat; 1260 ((WT)w)->at = mn_now + w->repeat;
1169 downheap ((WT *)timers, timercnt, ((W)w)->active - 1); 1261 downheap ((WT *)timers, timercnt, ((W)w)->active - 1);
1170 } 1262 }
1171 else 1263 else
1172 ev_timer_stop (EV_A_ w); 1264 ev_timer_stop (EV_A_ w);
1173 } 1265 }
1183 1275
1184 assert (("ev_periodic_start called with negative interval value", w->interval >= 0.)); 1276 assert (("ev_periodic_start called with negative interval value", w->interval >= 0.));
1185 1277
1186 /* this formula differs from the one in periodic_reify because we do not always round up */ 1278 /* this formula differs from the one in periodic_reify because we do not always round up */
1187 if (w->interval) 1279 if (w->interval)
1188 w->at += ceil ((rt_now - w->at) / w->interval) * w->interval; 1280 ((WT)w)->at += ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval;
1189 1281
1190 ev_start (EV_A_ (W)w, ++periodiccnt); 1282 ev_start (EV_A_ (W)w, ++periodiccnt);
1191 array_needsize (periodics, periodicmax, periodiccnt, ); 1283 array_needsize (periodics, periodicmax, periodiccnt, );
1192 periodics [periodiccnt - 1] = w; 1284 periodics [periodiccnt - 1] = w;
1193 upheap ((WT *)periodics, periodiccnt - 1); 1285 upheap ((WT *)periodics, periodiccnt - 1);
1296 1388
1297 ev_start (EV_A_ (W)w, 1); 1389 ev_start (EV_A_ (W)w, 1);
1298 array_needsize (signals, signalmax, w->signum, signals_init); 1390 array_needsize (signals, signalmax, w->signum, signals_init);
1299 wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w); 1391 wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w);
1300 1392
1301 if (!w->next) 1393 if (!((WL)w)->next)
1302 { 1394 {
1395#if WIN32
1396 signal (w->signum, sighandler);
1397#else
1303 struct sigaction sa; 1398 struct sigaction sa;
1304 sa.sa_handler = sighandler; 1399 sa.sa_handler = sighandler;
1305 sigfillset (&sa.sa_mask); 1400 sigfillset (&sa.sa_mask);
1306 sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */ 1401 sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */
1307 sigaction (w->signum, &sa, 0); 1402 sigaction (w->signum, &sa, 0);
1403#endif
1308 } 1404 }
1309} 1405}
1310 1406
1311void 1407void
1312ev_signal_stop (EV_P_ struct ev_signal *w) 1408ev_signal_stop (EV_P_ struct ev_signal *w)
1362 void (*cb)(int revents, void *arg) = once->cb; 1458 void (*cb)(int revents, void *arg) = once->cb;
1363 void *arg = once->arg; 1459 void *arg = once->arg;
1364 1460
1365 ev_io_stop (EV_A_ &once->io); 1461 ev_io_stop (EV_A_ &once->io);
1366 ev_timer_stop (EV_A_ &once->to); 1462 ev_timer_stop (EV_A_ &once->to);
1367 free (once); 1463 ev_free (once);
1368 1464
1369 cb (revents, arg); 1465 cb (revents, arg);
1370} 1466}
1371 1467
1372static void 1468static void
1382} 1478}
1383 1479
1384void 1480void
1385ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) 1481ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg)
1386{ 1482{
1387 struct ev_once *once = malloc (sizeof (struct ev_once)); 1483 struct ev_once *once = ev_malloc (sizeof (struct ev_once));
1388 1484
1389 if (!once) 1485 if (!once)
1390 cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT, arg); 1486 cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT, arg);
1391 else 1487 else
1392 { 1488 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines