1 | /* |
1 | /* |
|
|
2 | * libev event processing core, watcher management |
|
|
3 | * |
2 | * Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de> |
4 | * Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de> |
3 | * All rights reserved. |
5 | * All rights reserved. |
4 | * |
6 | * |
5 | * Redistribution and use in source and binary forms, with or without |
7 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are |
8 | * modification, are permitted provided that the following conditions are |
… | |
… | |
45 | #include <sys/wait.h> |
47 | #include <sys/wait.h> |
46 | #include <sys/time.h> |
48 | #include <sys/time.h> |
47 | #include <time.h> |
49 | #include <time.h> |
48 | |
50 | |
49 | #ifndef EV_USE_MONOTONIC |
51 | #ifndef EV_USE_MONOTONIC |
50 | # ifdef CLOCK_MONOTONIC |
|
|
51 | # define EV_USE_MONOTONIC 1 |
52 | # define EV_USE_MONOTONIC 1 |
52 | # endif |
53 | #endif |
|
|
54 | |
|
|
55 | #ifndef CLOCK_MONOTONIC |
|
|
56 | # undef EV_USE_MONOTONIC |
|
|
57 | # define EV_USE_MONOTONIC 0 |
53 | #endif |
58 | #endif |
54 | |
59 | |
55 | #ifndef EV_USE_SELECT |
60 | #ifndef EV_USE_SELECT |
56 | # define EV_USE_SELECT 1 |
61 | # define EV_USE_SELECT 1 |
57 | #endif |
62 | #endif |
… | |
… | |
489 | } |
494 | } |
490 | |
495 | |
491 | /*****************************************************************************/ |
496 | /*****************************************************************************/ |
492 | |
497 | |
493 | void |
498 | void |
494 | ev_prefork (void) |
499 | ev_fork_prepare (void) |
495 | { |
500 | { |
496 | /* nop */ |
501 | /* nop */ |
497 | } |
502 | } |
498 | |
503 | |
499 | void |
504 | void |
500 | ev_postfork_parent (void) |
505 | ev_fork_parent (void) |
501 | { |
506 | { |
502 | /* nop */ |
507 | /* nop */ |
503 | } |
508 | } |
504 | |
509 | |
505 | void |
510 | void |
506 | ev_postfork_child (void) |
511 | ev_fork_child (void) |
507 | { |
512 | { |
508 | #if EV_USE_EPOLL |
513 | #if EV_USE_EPOLL |
509 | if (ev_method == EVMETHOD_EPOLL) |
514 | if (ev_method == EVMETHOD_EPOLL) |
510 | epoll_postfork_child (); |
515 | epoll_postfork_child (); |
511 | #endif |
516 | #endif |
… | |
… | |
761 | /*****************************************************************************/ |
766 | /*****************************************************************************/ |
762 | |
767 | |
763 | void |
768 | void |
764 | ev_io_start (struct ev_io *w) |
769 | ev_io_start (struct ev_io *w) |
765 | { |
770 | { |
766 | if (ev_is_active (w)) |
|
|
767 | return; |
|
|
768 | |
|
|
769 | int fd = w->fd; |
771 | int fd = w->fd; |
|
|
772 | |
|
|
773 | if (ev_is_active (w)) |
|
|
774 | return; |
770 | |
775 | |
771 | assert (("ev_io_start called with negative fd", fd >= 0)); |
776 | assert (("ev_io_start called with negative fd", fd >= 0)); |
772 | |
777 | |
773 | ev_start ((W)w, 1); |
778 | ev_start ((W)w, 1); |
774 | array_needsize (anfds, anfdmax, fd + 1, anfds_init); |
779 | array_needsize (anfds, anfdmax, fd + 1, anfds_init); |