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

Comparing libev/ev.c (file contents):
Revision 1.13 by root, Wed Oct 31 10:50:05 2007 UTC vs.
Revision 1.26 by root, Wed Oct 31 21:50:15 2007 UTC

1/*
2 * Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following
14 * disclaimer in the documentation and/or other materials provided
15 * with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
1#include <math.h> 30#include <math.h>
2#include <stdlib.h> 31#include <stdlib.h>
3#include <unistd.h> 32#include <unistd.h>
4#include <fcntl.h> 33#include <fcntl.h>
5#include <signal.h> 34#include <signal.h>
35#include <stddef.h>
6 36
7#include <stdio.h> 37#include <stdio.h>
8 38
9#include <assert.h> 39#include <assert.h>
10#include <errno.h> 40#include <errno.h>
41#include <sys/types.h>
42#include <sys/wait.h>
11#include <sys/time.h> 43#include <sys/time.h>
12#include <time.h> 44#include <time.h>
13
14#define HAVE_EPOLL 1
15 45
16#ifndef HAVE_MONOTONIC 46#ifndef HAVE_MONOTONIC
17# ifdef CLOCK_MONOTONIC 47# ifdef CLOCK_MONOTONIC
18# define HAVE_MONOTONIC 1 48# define HAVE_MONOTONIC 1
19# endif 49# endif
31# define HAVE_REALTIME 1 /* posix requirement, but might be slower */ 61# define HAVE_REALTIME 1 /* posix requirement, but might be slower */
32#endif 62#endif
33 63
34#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */ 64#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */
35#define MAX_BLOCKTIME 60. 65#define MAX_BLOCKTIME 60.
66#define PID_HASHSIZE 16 /* size of pid hahs table, must be power of two */
36 67
37#include "ev.h" 68#include "ev.h"
38 69
39typedef struct ev_watcher *W; 70typedef struct ev_watcher *W;
40typedef struct ev_watcher_list *WL; 71typedef struct ev_watcher_list *WL;
82} 113}
83 114
84#define array_needsize(base,cur,cnt,init) \ 115#define array_needsize(base,cur,cnt,init) \
85 if ((cnt) > cur) \ 116 if ((cnt) > cur) \
86 { \ 117 { \
87 int newcnt = cur ? cur << 1 : 16; \ 118 int newcnt = cur; \
88 fprintf (stderr, "resize(" # base ") from %d to %d\n", cur, newcnt);\ 119 do \
120 { \
121 newcnt = (newcnt << 1) | 4 & ~3; \
122 } \
123 while ((cnt) > newcnt); \
124 \
89 base = realloc (base, sizeof (*base) * (newcnt)); \ 125 base = realloc (base, sizeof (*base) * (newcnt)); \
90 init (base + cur, newcnt - cur); \ 126 init (base + cur, newcnt - cur); \
91 cur = newcnt; \ 127 cur = newcnt; \
92 } 128 }
93 129
126static int pendingmax, pendingcnt; 162static int pendingmax, pendingcnt;
127 163
128static void 164static void
129event (W w, int events) 165event (W w, int events)
130{ 166{
167 if (w->active)
168 {
131 w->pending = ++pendingcnt; 169 w->pending = ++pendingcnt;
132 array_needsize (pendings, pendingmax, pendingcnt, ); 170 array_needsize (pendings, pendingmax, pendingcnt, );
133 pendings [pendingcnt - 1].w = w; 171 pendings [pendingcnt - 1].w = w;
134 pendings [pendingcnt - 1].events = events; 172 pendings [pendingcnt - 1].events = events;
173 }
135} 174}
136 175
137static void 176static void
138fd_event (int fd, int events) 177fd_event (int fd, int events)
139{ 178{
154{ 193{
155 int i; 194 int i;
156 195
157 for (i = 0; i < eventcnt; ++i) 196 for (i = 0; i < eventcnt; ++i)
158 event (events [i], type); 197 event (events [i], type);
198}
199
200/* called on EBADF to verify fds */
201static void
202fd_recheck (void)
203{
204 int fd;
205
206 for (fd = 0; fd < anfdmax; ++fd)
207 if (anfds [fd].wev)
208 if (fcntl (fd, F_GETFD) == -1 && errno == EBADF)
209 while (anfds [fd].head)
210 {
211 event ((W)anfds [fd].head, EV_ERROR);
212 evio_stop (anfds [fd].head);
213 }
159} 214}
160 215
161/*****************************************************************************/ 216/*****************************************************************************/
162 217
163static struct ev_timer **timers; 218static struct ev_timer **timers;
281/*****************************************************************************/ 336/*****************************************************************************/
282 337
283static struct ev_idle **idles; 338static struct ev_idle **idles;
284static int idlemax, idlecnt; 339static int idlemax, idlecnt;
285 340
341static struct ev_prepare **prepares;
342static int preparemax, preparecnt;
343
286static struct ev_check **checks; 344static struct ev_check **checks;
287static int checkmax, checkcnt; 345static int checkmax, checkcnt;
288 346
289/*****************************************************************************/ 347/*****************************************************************************/
290 348
349static struct ev_child *childs [PID_HASHSIZE];
350static struct ev_signal childev;
351
352#ifndef WCONTINUED
353# define WCONTINUED 0
354#endif
355
356static void
357childcb (struct ev_signal *sw, int revents)
358{
359 struct ev_child *w;
360 int pid, status;
361
362 while ((pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED)) != -1)
363 for (w = childs [pid & (PID_HASHSIZE - 1)]; w; w = w->next)
364 if (w->pid == pid || w->pid == -1)
365 {
366 w->status = status;
367 event ((W)w, EV_CHILD);
368 }
369}
370
371/*****************************************************************************/
372
291#if HAVE_EPOLL 373#if HAVE_EPOLL
292# include "ev_epoll.c" 374# include "ev_epoll.c"
293#endif 375#endif
294#if HAVE_SELECT 376#if HAVE_SELECT
295# include "ev_select.c" 377# include "ev_select.c"
296#endif 378#endif
297 379
380int
381ev_version_major (void)
382{
383 return EV_VERSION_MAJOR;
384}
385
386int
387ev_version_minor (void)
388{
389 return EV_VERSION_MINOR;
390}
391
298int ev_init (int flags) 392int ev_init (int flags)
299{ 393{
394 if (!ev_method)
395 {
300#if HAVE_MONOTONIC 396#if HAVE_MONOTONIC
301 { 397 {
302 struct timespec ts; 398 struct timespec ts;
303 if (!clock_gettime (CLOCK_MONOTONIC, &ts)) 399 if (!clock_gettime (CLOCK_MONOTONIC, &ts))
304 have_monotonic = 1; 400 have_monotonic = 1;
305 } 401 }
306#endif 402#endif
307 403
308 ev_now = ev_time (); 404 ev_now = ev_time ();
309 now = get_clock (); 405 now = get_clock ();
310 diff = ev_now - now; 406 diff = ev_now - now;
311 407
312 if (pipe (sigpipe)) 408 if (pipe (sigpipe))
313 return 0; 409 return 0;
314 410
315 ev_method = EVMETHOD_NONE; 411 ev_method = EVMETHOD_NONE;
316#if HAVE_EPOLL 412#if HAVE_EPOLL
317 if (ev_method == EVMETHOD_NONE) epoll_init (flags); 413 if (ev_method == EVMETHOD_NONE) epoll_init (flags);
318#endif 414#endif
319#if HAVE_SELECT 415#if HAVE_SELECT
320 if (ev_method == EVMETHOD_NONE) select_init (flags); 416 if (ev_method == EVMETHOD_NONE) select_init (flags);
321#endif 417#endif
322 418
323 if (ev_method) 419 if (ev_method)
324 { 420 {
325 evw_init (&sigev, sigcb); 421 evw_init (&sigev, sigcb);
326 siginit (); 422 siginit ();
423
424 evsignal_init (&childev, childcb, SIGCHLD);
425 evsignal_start (&childev);
426 }
327 } 427 }
328 428
329 return ev_method; 429 return ev_method;
330} 430}
331 431
332/*****************************************************************************/ 432/*****************************************************************************/
333 433
434void
334void ev_prefork (void) 435ev_prefork (void)
335{ 436{
336 /* nop */ 437 /* nop */
337} 438}
338 439
440void
339void ev_postfork_parent (void) 441ev_postfork_parent (void)
340{ 442{
341 /* nop */ 443 /* nop */
342} 444}
343 445
446void
344void ev_postfork_child (void) 447ev_postfork_child (void)
345{ 448{
346#if HAVE_EPOLL 449#if HAVE_EPOLL
347 if (ev_method == EVMETHOD_EPOLL) 450 if (ev_method == EVMETHOD_EPOLL)
348 epoll_postfork_child (); 451 epoll_postfork_child ();
349#endif 452#endif
382 485
383 fdchangecnt = 0; 486 fdchangecnt = 0;
384} 487}
385 488
386static void 489static void
387call_pending () 490call_pending (void)
388{ 491{
389 int i; 492 while (pendingcnt)
390
391 for (i = 0; i < pendingcnt; ++i)
392 { 493 {
393 ANPENDING *p = pendings + i; 494 ANPENDING *p = pendings + --pendingcnt;
394 495
395 if (p->w) 496 if (p->w)
396 { 497 {
397 p->w->pending = 0; 498 p->w->pending = 0;
398 p->w->cb (p->w, p->events); 499 p->w->cb (p->w, p->events);
399 } 500 }
400 } 501 }
401
402 pendingcnt = 0;
403} 502}
404 503
405static void 504static void
406timers_reify () 505timers_reify (void)
407{ 506{
408 while (timercnt && timers [0]->at <= now) 507 while (timercnt && timers [0]->at <= now)
409 { 508 {
410 struct ev_timer *w = timers [0]; 509 struct ev_timer *w = timers [0];
510
511 event ((W)w, EV_TIMEOUT);
411 512
412 /* first reschedule or stop timer */ 513 /* first reschedule or stop timer */
413 if (w->repeat) 514 if (w->repeat)
414 { 515 {
415 w->at = now + w->repeat; 516 w->at = now + w->repeat;
416 assert (("timer timeout in the past, negative repeat?", w->at > now)); 517 assert (("timer timeout in the past, negative repeat?", w->at > now));
417 downheap ((WT *)timers, timercnt, 0); 518 downheap ((WT *)timers, timercnt, 0);
418 } 519 }
419 else 520 else
420 evtimer_stop (w); /* nonrepeating: stop timer */ 521 evtimer_stop (w); /* nonrepeating: stop timer */
421
422 event ((W)w, EV_TIMEOUT);
423 } 522 }
424} 523}
425 524
426static void 525static void
427periodics_reify () 526periodics_reify (void)
428{ 527{
429 while (periodiccnt && periodics [0]->at <= ev_now) 528 while (periodiccnt && periodics [0]->at <= ev_now)
430 { 529 {
431 struct ev_periodic *w = periodics [0]; 530 struct ev_periodic *w = periodics [0];
432 531
468 } 567 }
469 } 568 }
470} 569}
471 570
472static void 571static void
473time_update () 572time_update (void)
474{ 573{
475 int i; 574 int i;
476 575
477 ev_now = ev_time (); 576 ev_now = ev_time ();
478 577
512int ev_loop_done; 611int ev_loop_done;
513 612
514void ev_loop (int flags) 613void ev_loop (int flags)
515{ 614{
516 double block; 615 double block;
517 ev_loop_done = flags & EVLOOP_ONESHOT ? 1 : 0; 616 ev_loop_done = flags & (EVLOOP_ONESHOT | EVLOOP_NONBLOCK) ? 1 : 0;
518
519 if (checkcnt)
520 {
521 queue_events ((W *)checks, checkcnt, EV_CHECK);
522 call_pending ();
523 }
524 617
525 do 618 do
526 { 619 {
620 /* queue check watchers (and execute them) */
621 if (preparecnt)
622 {
623 queue_events ((W *)prepares, preparecnt, EV_PREPARE);
624 call_pending ();
625 }
626
527 /* update fd-related kernel structures */ 627 /* update fd-related kernel structures */
528 fd_reify (); 628 fd_reify ();
529 629
530 /* calculate blocking time */ 630 /* calculate blocking time */
531 631
532 /* we only need this for !monotonic clock, but as we always have timers, we just calculate it every time */ 632 /* we only need this for !monotonic clockor timers, but as we basically
633 always have timers, we just calculate it always */
533 ev_now = ev_time (); 634 ev_now = ev_time ();
534 635
535 if (flags & EVLOOP_NONBLOCK || idlecnt) 636 if (flags & EVLOOP_NONBLOCK || idlecnt)
536 block = 0.; 637 block = 0.;
537 else 638 else
538 { 639 {
539 block = MAX_BLOCKTIME; 640 block = MAX_BLOCKTIME;
540 641
541 if (timercnt) 642 if (timercnt)
542 { 643 {
543 ev_tstamp to = timers [0]->at - get_clock () + method_fudge; 644 ev_tstamp to = timers [0]->at - (have_monotonic ? get_clock () : ev_now) + method_fudge;
544 if (block > to) block = to; 645 if (block > to) block = to;
545 } 646 }
546 647
547 if (periodiccnt) 648 if (periodiccnt)
548 { 649 {
557 658
558 /* update ev_now, do magic */ 659 /* update ev_now, do magic */
559 time_update (); 660 time_update ();
560 661
561 /* queue pending timers and reschedule them */ 662 /* queue pending timers and reschedule them */
663 timers_reify (); /* relative timers called last */
562 periodics_reify (); /* absolute timers first */ 664 periodics_reify (); /* absolute timers called first */
563 timers_reify (); /* relative timers second */
564 665
565 /* queue idle watchers unless io or timers are pending */ 666 /* queue idle watchers unless io or timers are pending */
566 if (!pendingcnt) 667 if (!pendingcnt)
567 queue_events ((W *)idles, idlecnt, EV_IDLE); 668 queue_events ((W *)idles, idlecnt, EV_IDLE);
568 669
569 /* queue check and possibly idle watchers */ 670 /* queue check watchers, to be executed first */
671 if (checkcnt)
570 queue_events ((W *)checks, checkcnt, EV_CHECK); 672 queue_events ((W *)checks, checkcnt, EV_CHECK);
571 673
572 call_pending (); 674 call_pending ();
573 } 675 }
574 while (!ev_loop_done); 676 while (!ev_loop_done);
575 677
600 head = &(*head)->next; 702 head = &(*head)->next;
601 } 703 }
602} 704}
603 705
604static void 706static void
707ev_clear (W w)
708{
709 if (w->pending)
710 {
711 pendings [w->pending - 1].w = 0;
712 w->pending = 0;
713 }
714}
715
716static void
605ev_start (W w, int active) 717ev_start (W w, int active)
606{ 718{
607 w->pending = 0;
608 w->active = active; 719 w->active = active;
609} 720}
610 721
611static void 722static void
612ev_stop (W w) 723ev_stop (W w)
613{ 724{
614 if (w->pending)
615 pendings [w->pending - 1].w = 0;
616
617 w->active = 0; 725 w->active = 0;
618} 726}
619 727
620/*****************************************************************************/ 728/*****************************************************************************/
621 729
632 wlist_add ((WL *)&anfds[fd].head, (WL)w); 740 wlist_add ((WL *)&anfds[fd].head, (WL)w);
633 741
634 ++fdchangecnt; 742 ++fdchangecnt;
635 array_needsize (fdchanges, fdchangemax, fdchangecnt, ); 743 array_needsize (fdchanges, fdchangemax, fdchangecnt, );
636 fdchanges [fdchangecnt - 1] = fd; 744 fdchanges [fdchangecnt - 1] = fd;
745
746 if (w->fd == 9)
747 printf ("start %p:%x\n", w, w->events);//D
637} 748}
638 749
639void 750void
640evio_stop (struct ev_io *w) 751evio_stop (struct ev_io *w)
641{ 752{
753 if (w->fd == 9)
754 printf ("stop %p:%x\n", w, w->events);//D
755 ev_clear ((W)w);
642 if (!ev_is_active (w)) 756 if (!ev_is_active (w))
643 return; 757 return;
644 758
645 wlist_del ((WL *)&anfds[w->fd].head, (WL)w); 759 wlist_del ((WL *)&anfds[w->fd].head, (WL)w);
646 ev_stop ((W)w); 760 ev_stop ((W)w);
647 761
648 ++fdchangecnt; 762 ++fdchangecnt;
649 array_needsize (fdchanges, fdchangemax, fdchangecnt, ); 763 array_needsize (fdchanges, fdchangemax, fdchangecnt, );
650 fdchanges [fdchangecnt - 1] = w->fd; 764 fdchanges [fdchangecnt - 1] = w->fd;
651} 765}
652
653 766
654void 767void
655evtimer_start (struct ev_timer *w) 768evtimer_start (struct ev_timer *w)
656{ 769{
657 if (ev_is_active (w)) 770 if (ev_is_active (w))
668} 781}
669 782
670void 783void
671evtimer_stop (struct ev_timer *w) 784evtimer_stop (struct ev_timer *w)
672{ 785{
786 ev_clear ((W)w);
673 if (!ev_is_active (w)) 787 if (!ev_is_active (w))
674 return; 788 return;
675 789
676 if (w->active < timercnt--) 790 if (w->active < timercnt--)
677 { 791 {
678 timers [w->active - 1] = timers [timercnt]; 792 timers [w->active - 1] = timers [timercnt];
679 downheap ((WT *)timers, timercnt, w->active - 1); 793 downheap ((WT *)timers, timercnt, w->active - 1);
680 } 794 }
681 795
796 w->at = w->repeat;
797
682 ev_stop ((W)w); 798 ev_stop ((W)w);
799}
800
801void
802evtimer_again (struct ev_timer *w)
803{
804 if (ev_is_active (w))
805 {
806 if (w->repeat)
807 {
808 w->at = now + w->repeat;
809 downheap ((WT *)timers, timercnt, w->active - 1);
810 }
811 else
812 evtimer_stop (w);
813 }
814 else if (w->repeat)
815 evtimer_start (w);
683} 816}
684 817
685void 818void
686evperiodic_start (struct ev_periodic *w) 819evperiodic_start (struct ev_periodic *w)
687{ 820{
701} 834}
702 835
703void 836void
704evperiodic_stop (struct ev_periodic *w) 837evperiodic_stop (struct ev_periodic *w)
705{ 838{
839 ev_clear ((W)w);
706 if (!ev_is_active (w)) 840 if (!ev_is_active (w))
707 return; 841 return;
708 842
709 if (w->active < periodiccnt--) 843 if (w->active < periodiccnt--)
710 { 844 {
736} 870}
737 871
738void 872void
739evsignal_stop (struct ev_signal *w) 873evsignal_stop (struct ev_signal *w)
740{ 874{
875 ev_clear ((W)w);
741 if (!ev_is_active (w)) 876 if (!ev_is_active (w))
742 return; 877 return;
743 878
744 wlist_del ((WL *)&signals [w->signum - 1].head, (WL)w); 879 wlist_del ((WL *)&signals [w->signum - 1].head, (WL)w);
745 ev_stop ((W)w); 880 ev_stop ((W)w);
758 idles [idlecnt - 1] = w; 893 idles [idlecnt - 1] = w;
759} 894}
760 895
761void evidle_stop (struct ev_idle *w) 896void evidle_stop (struct ev_idle *w)
762{ 897{
898 ev_clear ((W)w);
899 if (ev_is_active (w))
900 return;
901
763 idles [w->active - 1] = idles [--idlecnt]; 902 idles [w->active - 1] = idles [--idlecnt];
903 ev_stop ((W)w);
904}
905
906void evprepare_start (struct ev_prepare *w)
907{
908 if (ev_is_active (w))
909 return;
910
911 ev_start ((W)w, ++preparecnt);
912 array_needsize (prepares, preparemax, preparecnt, );
913 prepares [preparecnt - 1] = w;
914}
915
916void evprepare_stop (struct ev_prepare *w)
917{
918 ev_clear ((W)w);
919 if (ev_is_active (w))
920 return;
921
922 prepares [w->active - 1] = prepares [--preparecnt];
764 ev_stop ((W)w); 923 ev_stop ((W)w);
765} 924}
766 925
767void evcheck_start (struct ev_check *w) 926void evcheck_start (struct ev_check *w)
768{ 927{
774 checks [checkcnt - 1] = w; 933 checks [checkcnt - 1] = w;
775} 934}
776 935
777void evcheck_stop (struct ev_check *w) 936void evcheck_stop (struct ev_check *w)
778{ 937{
938 ev_clear ((W)w);
939 if (ev_is_active (w))
940 return;
941
779 checks [w->active - 1] = checks [--checkcnt]; 942 checks [w->active - 1] = checks [--checkcnt];
780 ev_stop ((W)w); 943 ev_stop ((W)w);
944}
945
946void evchild_start (struct ev_child *w)
947{
948 if (ev_is_active (w))
949 return;
950
951 ev_start ((W)w, 1);
952 wlist_add ((WL *)&childs [w->pid & (PID_HASHSIZE - 1)], (WL)w);
953}
954
955void evchild_stop (struct ev_child *w)
956{
957 ev_clear ((W)w);
958 if (ev_is_active (w))
959 return;
960
961 wlist_del ((WL *)&childs [w->pid & (PID_HASHSIZE - 1)], (WL)w);
962 ev_stop ((W)w);
963}
964
965/*****************************************************************************/
966
967struct ev_once
968{
969 struct ev_io io;
970 struct ev_timer to;
971 void (*cb)(int revents, void *arg);
972 void *arg;
973};
974
975static void
976once_cb (struct ev_once *once, int revents)
977{
978 void (*cb)(int revents, void *arg) = once->cb;
979 void *arg = once->arg;
980
981 evio_stop (&once->io);
982 evtimer_stop (&once->to);
983 free (once);
984
985 cb (revents, arg);
986}
987
988static void
989once_cb_io (struct ev_io *w, int revents)
990{
991 once_cb ((struct ev_once *)(((char *)w) - offsetof (struct ev_once, io)), revents);
992}
993
994static void
995once_cb_to (struct ev_timer *w, int revents)
996{
997 once_cb ((struct ev_once *)(((char *)w) - offsetof (struct ev_once, to)), revents);
998}
999
1000void
1001ev_once (int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg)
1002{
1003 struct ev_once *once = malloc (sizeof (struct ev_once));
1004
1005 if (!once)
1006 cb (EV_ERROR, arg);
1007 else
1008 {
1009 once->cb = cb;
1010 once->arg = arg;
1011
1012 evw_init (&once->io, once_cb_io);
1013
1014 if (fd >= 0)
1015 {
1016 evio_set (&once->io, fd, events);
1017 evio_start (&once->io);
1018 }
1019
1020 evw_init (&once->to, once_cb_to);
1021
1022 if (timeout >= 0.)
1023 {
1024 evtimer_set (&once->to, timeout, 0.);
1025 evtimer_start (&once->to);
1026 }
1027 }
781} 1028}
782 1029
783/*****************************************************************************/ 1030/*****************************************************************************/
784 1031
785#if 0 1032#if 0

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines