cool.io 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +26 -0
- data/.rspec +3 -0
- data/.travis.yml +4 -0
- data/{CHANGES → CHANGES.md} +43 -79
- data/Gemfile +4 -0
- data/Gemfile.lock +32 -0
- data/{README.markdown → README.md} +0 -4
- data/Rakefile +31 -67
- data/cool.io.gemspec +25 -133
- data/ext/cool.io/extconf.rb +3 -0
- data/ext/cool.io/stat_watcher.c +99 -23
- data/ext/libev/Changes +24 -0
- data/ext/libev/ev.c +78 -32
- data/ext/libev/ev.h +11 -8
- data/ext/libev/ev_epoll.c +39 -7
- data/ext/libev/ev_kqueue.c +5 -5
- data/ext/libev/ev_poll.c +5 -5
- data/ext/libev/ev_port.c +26 -11
- data/ext/libev/ev_select.c +11 -8
- data/ext/libev/ev_vars.h +10 -4
- data/ext/libev/ev_win32.c +6 -6
- data/ext/libev/ev_wrap.h +10 -0
- data/lib/cool.io.rb +3 -3
- data/lib/cool.io/async_watcher.rb +1 -1
- data/lib/cool.io/dns_resolver.rb +14 -12
- data/lib/cool.io/dsl.rb +26 -26
- data/lib/cool.io/eventmachine.rb +18 -18
- data/lib/cool.io/http_client.rb +29 -22
- data/lib/cool.io/io.rb +18 -18
- data/lib/cool.io/iowatcher.rb +1 -1
- data/lib/cool.io/listener.rb +2 -2
- data/lib/cool.io/loop.rb +12 -12
- data/lib/cool.io/meta.rb +4 -4
- data/lib/cool.io/server.rb +3 -3
- data/lib/cool.io/socket.rb +36 -28
- data/lib/cool.io/timer_watcher.rb +1 -1
- data/lib/cool.io/version.rb +5 -0
- data/lib/coolio.rb +1 -1
- data/spec/stat_watcher_spec.rb +77 -0
- metadata +47 -56
- data/VERSION +0 -1
- data/lib/rev.rb +0 -4
- data/spec/possible_tests/schedules_other_threads.rb +0 -48
- data/spec/possible_tests/test_on_resolve_failed.rb +0 -9
- data/spec/possible_tests/test_resolves.rb +0 -27
- data/spec/possible_tests/test_write_during_resolve.rb +0 -27
- data/spec/possible_tests/works_straight.rb +0 -71
    
        data/ext/libev/ev.h
    CHANGED
    
    | @@ -1,19 +1,19 @@ | |
| 1 1 | 
             
            /*
         | 
| 2 2 | 
             
             * libev native API header
         | 
| 3 3 | 
             
             *
         | 
| 4 | 
            -
             * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libev@schmorp.de>
         | 
| 4 | 
            +
             * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
         | 
| 5 5 | 
             
             * All rights reserved.
         | 
| 6 6 | 
             
             *
         | 
| 7 7 | 
             
             * Redistribution and use in source and binary forms, with or without modifica-
         | 
| 8 8 | 
             
             * tion, are permitted provided that the following conditions are met:
         | 
| 9 | 
            -
             * | 
| 9 | 
            +
             *
         | 
| 10 10 | 
             
             *   1.  Redistributions of source code must retain the above copyright notice,
         | 
| 11 11 | 
             
             *       this list of conditions and the following disclaimer.
         | 
| 12 | 
            -
             * | 
| 12 | 
            +
             *
         | 
| 13 13 | 
             
             *   2.  Redistributions in binary form must reproduce the above copyright
         | 
| 14 14 | 
             
             *       notice, this list of conditions and the following disclaimer in the
         | 
| 15 15 | 
             
             *       documentation and/or other materials provided with the distribution.
         | 
| 16 | 
            -
             * | 
| 16 | 
            +
             *
         | 
| 17 17 | 
             
             * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
         | 
| 18 18 | 
             
             * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
         | 
| 19 19 | 
             
             * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
         | 
| @@ -185,7 +185,7 @@ struct ev_loop; | |
| 185 185 | 
             
            # define EV_INLINE static
         | 
| 186 186 | 
             
            #endif
         | 
| 187 187 |  | 
| 188 | 
            -
            /* EV_PROTOTYPES can be  | 
| 188 | 
            +
            /* EV_PROTOTYPES can be used to switch of prototype declarations */
         | 
| 189 189 | 
             
            #ifndef EV_PROTOTYPES
         | 
| 190 190 | 
             
            # define EV_PROTOTYPES 1
         | 
| 191 191 | 
             
            #endif
         | 
| @@ -193,7 +193,7 @@ struct ev_loop; | |
| 193 193 | 
             
            /*****************************************************************************/
         | 
| 194 194 |  | 
| 195 195 | 
             
            #define EV_VERSION_MAJOR 4
         | 
| 196 | 
            -
            #define EV_VERSION_MINOR  | 
| 196 | 
            +
            #define EV_VERSION_MINOR 4
         | 
| 197 197 |  | 
| 198 198 | 
             
            /* eventmask, revents, events... */
         | 
| 199 199 | 
             
            enum {
         | 
| @@ -491,7 +491,8 @@ enum { | |
| 491 491 | 
             
            #if EV_COMPAT3
         | 
| 492 492 | 
             
              EVFLAG_NOSIGFD   = 0, /* compatibility to pre-3.9 */
         | 
| 493 493 | 
             
            #endif
         | 
| 494 | 
            -
              EVFLAG_SIGNALFD  = 0x00200000U | 
| 494 | 
            +
              EVFLAG_SIGNALFD  = 0x00200000U, /* attempt to use signalfd */
         | 
| 495 | 
            +
              EVFLAG_NOSIGMASK = 0x00400000U  /* avoid modifying the signal mask */
         | 
| 495 496 | 
             
            };
         | 
| 496 497 |  | 
| 497 498 | 
             
            /* method bits to be ored together */
         | 
| @@ -502,7 +503,8 @@ enum { | |
| 502 503 | 
             
              EVBACKEND_KQUEUE  = 0x00000008U, /* bsd */
         | 
| 503 504 | 
             
              EVBACKEND_DEVPOLL = 0x00000010U, /* solaris 8 */ /* NYI */
         | 
| 504 505 | 
             
              EVBACKEND_PORT    = 0x00000020U, /* solaris 10 */
         | 
| 505 | 
            -
              EVBACKEND_ALL     = 0x0000003FU
         | 
| 506 | 
            +
              EVBACKEND_ALL     = 0x0000003FU, /* all known backends */
         | 
| 507 | 
            +
              EVBACKEND_MASK    = 0x0000FFFFU  /* all future backends */
         | 
| 506 508 | 
             
            };
         | 
| 507 509 |  | 
| 508 510 | 
             
            #if EV_PROTOTYPES
         | 
| @@ -720,6 +722,7 @@ void ev_resume  (EV_P); | |
| 720 722 | 
             
            void ev_feed_event     (EV_P_ void *w, int revents);
         | 
| 721 723 | 
             
            void ev_feed_fd_event  (EV_P_ int fd, int revents);
         | 
| 722 724 | 
             
            #if EV_SIGNAL_ENABLE
         | 
| 725 | 
            +
            void ev_feed_signal    (int signum);
         | 
| 723 726 | 
             
            void ev_feed_signal_event (EV_P_ int signum);
         | 
| 724 727 | 
             
            #endif
         | 
| 725 728 | 
             
            void ev_invoke         (EV_P_ void *w, int revents);
         | 
    
        data/ext/libev/ev_epoll.c
    CHANGED
    
    | @@ -1,19 +1,19 @@ | |
| 1 1 | 
             
            /*
         | 
| 2 2 | 
             
             * libev epoll fd activity backend
         | 
| 3 3 | 
             
             *
         | 
| 4 | 
            -
             * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libev@schmorp.de>
         | 
| 4 | 
            +
             * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
         | 
| 5 5 | 
             
             * All rights reserved.
         | 
| 6 6 | 
             
             *
         | 
| 7 7 | 
             
             * Redistribution and use in source and binary forms, with or without modifica-
         | 
| 8 8 | 
             
             * tion, are permitted provided that the following conditions are met:
         | 
| 9 | 
            -
             * | 
| 9 | 
            +
             *
         | 
| 10 10 | 
             
             *   1.  Redistributions of source code must retain the above copyright notice,
         | 
| 11 11 | 
             
             *       this list of conditions and the following disclaimer.
         | 
| 12 | 
            -
             * | 
| 12 | 
            +
             *
         | 
| 13 13 | 
             
             *   2.  Redistributions in binary form must reproduce the above copyright
         | 
| 14 14 | 
             
             *       notice, this list of conditions and the following disclaimer in the
         | 
| 15 15 | 
             
             *       documentation and/or other materials provided with the distribution.
         | 
| 16 | 
            -
             * | 
| 16 | 
            +
             *
         | 
| 17 17 | 
             
             * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
         | 
| 18 18 | 
             
             * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
         | 
| 19 19 | 
             
             * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
         | 
| @@ -53,7 +53,8 @@ | |
| 53 53 | 
             
             *    (such as files). while not critical, no other advanced interface
         | 
| 54 54 | 
             
             *    seems to share this (rather non-unixy) limitation.
         | 
| 55 55 | 
             
             * e) epoll claims to be embeddable, but in practise you never get
         | 
| 56 | 
            -
             *    a ready event for the epoll fd.
         | 
| 56 | 
            +
             *    a ready event for the epoll fd (broken: <=2.6.26, working: >=2.6.32).
         | 
| 57 | 
            +
             * f) epoll_ctl returning EPERM means the fd is always ready.
         | 
| 57 58 | 
             
             *
         | 
| 58 59 | 
             
             * lots of "weird code" and complication handling in this file is due
         | 
| 59 60 | 
             
             * to these design problems with epoll, as we try very hard to avoid
         | 
| @@ -64,6 +65,8 @@ | |
| 64 65 |  | 
| 65 66 | 
             
            #include <sys/epoll.h>
         | 
| 66 67 |  | 
| 68 | 
            +
            #define EV_EMASK_EPERM 0x80
         | 
| 69 | 
            +
             | 
| 67 70 | 
             
            static void
         | 
| 68 71 | 
             
            epoll_modify (EV_P_ int fd, int oev, int nev)
         | 
| 69 72 | 
             
            {
         | 
| @@ -112,6 +115,21 @@ epoll_modify (EV_P_ int fd, int oev, int nev) | |
| 112 115 | 
             
                  if (!epoll_ctl (backend_fd, EPOLL_CTL_MOD, fd, &ev))
         | 
| 113 116 | 
             
                    return;
         | 
| 114 117 | 
             
                }
         | 
| 118 | 
            +
              else if (expect_true (errno == EPERM))
         | 
| 119 | 
            +
                {
         | 
| 120 | 
            +
                  /* EPERM means the fd is always ready, but epoll is too snobbish */
         | 
| 121 | 
            +
                  /* to handle it, unlike select or poll. */
         | 
| 122 | 
            +
                  anfds [fd].emask = EV_EMASK_EPERM;
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                  /* add fd to epoll_eperms, if not already inside */
         | 
| 125 | 
            +
                  if (!(oldmask & EV_EMASK_EPERM))
         | 
| 126 | 
            +
                    {
         | 
| 127 | 
            +
                      array_needsize (int, epoll_eperms, epoll_epermmax, epoll_epermcnt + 1, EMPTY2);
         | 
| 128 | 
            +
                      epoll_eperms [epoll_epermcnt++] = fd;
         | 
| 129 | 
            +
                    }
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                  return;
         | 
| 132 | 
            +
                }
         | 
| 115 133 |  | 
| 116 134 | 
             
              fd_kill (EV_A_ fd);
         | 
| 117 135 |  | 
| @@ -125,11 +143,12 @@ epoll_poll (EV_P_ ev_tstamp timeout) | |
| 125 143 | 
             
            {
         | 
| 126 144 | 
             
              int i;
         | 
| 127 145 | 
             
              int eventcnt;
         | 
| 128 | 
            -
             | 
| 146 | 
            +
             | 
| 129 147 | 
             
              /* epoll wait times cannot be larger than (LONG_MAX - 999UL) / HZ msecs, which is below */
         | 
| 130 148 | 
             
              /* the default libev max wait time, however. */
         | 
| 131 149 | 
             
              EV_RELEASE_CB;
         | 
| 132 | 
            -
              eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax, | 
| 150 | 
            +
              eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax,
         | 
| 151 | 
            +
                                     epoll_epermcnt ? 0 : ev_timeout_to_ms (timeout));
         | 
| 133 152 | 
             
              EV_ACQUIRE_CB;
         | 
| 134 153 |  | 
| 135 154 | 
             
              if (expect_false (eventcnt < 0))
         | 
| @@ -186,6 +205,18 @@ epoll_poll (EV_P_ ev_tstamp timeout) | |
| 186 205 | 
             
                  epoll_eventmax = array_nextsize (sizeof (struct epoll_event), epoll_eventmax, epoll_eventmax + 1);
         | 
| 187 206 | 
             
                  epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) * epoll_eventmax);
         | 
| 188 207 | 
             
                }
         | 
| 208 | 
            +
             | 
| 209 | 
            +
              /* now synthesize events for all fds where epoll fails, while select works... */
         | 
| 210 | 
            +
              for (i = epoll_epermcnt; i--; )
         | 
| 211 | 
            +
                {
         | 
| 212 | 
            +
                  int fd = epoll_eperms [i];
         | 
| 213 | 
            +
                  unsigned char events = anfds [fd].events & (EV_READ | EV_WRITE);
         | 
| 214 | 
            +
             | 
| 215 | 
            +
                  if (anfds [fd].emask & EV_EMASK_EPERM && events)
         | 
| 216 | 
            +
                    fd_event (EV_A_ fd, events);
         | 
| 217 | 
            +
                  else
         | 
| 218 | 
            +
                    epoll_eperms [i] = epoll_eperms [--epoll_epermcnt];
         | 
| 219 | 
            +
                }
         | 
| 189 220 | 
             
            }
         | 
| 190 221 |  | 
| 191 222 | 
             
            int inline_size
         | 
| @@ -217,6 +248,7 @@ void inline_size | |
| 217 248 | 
             
            epoll_destroy (EV_P)
         | 
| 218 249 | 
             
            {
         | 
| 219 250 | 
             
              ev_free (epoll_events);
         | 
| 251 | 
            +
              array_free (epoll_eperm, EMPTY);
         | 
| 220 252 | 
             
            }
         | 
| 221 253 |  | 
| 222 254 | 
             
            void inline_size
         | 
    
        data/ext/libev/ev_kqueue.c
    CHANGED
    
    | @@ -6,14 +6,14 @@ | |
| 6 6 | 
             
             *
         | 
| 7 7 | 
             
             * Redistribution and use in source and binary forms, with or without modifica-
         | 
| 8 8 | 
             
             * tion, are permitted provided that the following conditions are met:
         | 
| 9 | 
            -
             * | 
| 9 | 
            +
             *
         | 
| 10 10 | 
             
             *   1.  Redistributions of source code must retain the above copyright notice,
         | 
| 11 11 | 
             
             *       this list of conditions and the following disclaimer.
         | 
| 12 | 
            -
             * | 
| 12 | 
            +
             *
         | 
| 13 13 | 
             
             *   2.  Redistributions in binary form must reproduce the above copyright
         | 
| 14 14 | 
             
             *       notice, this list of conditions and the following disclaimer in the
         | 
| 15 15 | 
             
             *       documentation and/or other materials provided with the distribution.
         | 
| 16 | 
            -
             * | 
| 16 | 
            +
             *
         | 
| 17 17 | 
             
             * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
         | 
| 18 18 | 
             
             * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
         | 
| 19 19 | 
             
             * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
         | 
| @@ -103,12 +103,12 @@ kqueue_poll (EV_P_ ev_tstamp timeout) | |
| 103 103 | 
             
              kqueue_changecnt = 0;
         | 
| 104 104 |  | 
| 105 105 | 
             
              if (expect_false (res < 0))
         | 
| 106 | 
            -
                { | 
| 106 | 
            +
                {
         | 
| 107 107 | 
             
                  if (errno != EINTR)
         | 
| 108 108 | 
             
                    ev_syserr ("(libev) kevent");
         | 
| 109 109 |  | 
| 110 110 | 
             
                  return;
         | 
| 111 | 
            -
                } | 
| 111 | 
            +
                }
         | 
| 112 112 |  | 
| 113 113 | 
             
              for (i = 0; i < res; ++i)
         | 
| 114 114 | 
             
                {
         | 
    
        data/ext/libev/ev_poll.c
    CHANGED
    
    | @@ -1,19 +1,19 @@ | |
| 1 1 | 
             
            /*
         | 
| 2 2 | 
             
             * libev poll fd activity backend
         | 
| 3 3 | 
             
             *
         | 
| 4 | 
            -
             * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libev@schmorp.de>
         | 
| 4 | 
            +
             * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
         | 
| 5 5 | 
             
             * All rights reserved.
         | 
| 6 6 | 
             
             *
         | 
| 7 7 | 
             
             * Redistribution and use in source and binary forms, with or without modifica-
         | 
| 8 8 | 
             
             * tion, are permitted provided that the following conditions are met:
         | 
| 9 | 
            -
             * | 
| 9 | 
            +
             *
         | 
| 10 10 | 
             
             *   1.  Redistributions of source code must retain the above copyright notice,
         | 
| 11 11 | 
             
             *       this list of conditions and the following disclaimer.
         | 
| 12 | 
            -
             * | 
| 12 | 
            +
             *
         | 
| 13 13 | 
             
             *   2.  Redistributions in binary form must reproduce the above copyright
         | 
| 14 14 | 
             
             *       notice, this list of conditions and the following disclaimer in the
         | 
| 15 15 | 
             
             *       documentation and/or other materials provided with the distribution.
         | 
| 16 | 
            -
             * | 
| 16 | 
            +
             *
         | 
| 17 17 | 
             
             * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
         | 
| 18 18 | 
             
             * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
         | 
| 19 19 | 
             
             * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
         | 
| @@ -92,7 +92,7 @@ poll_poll (EV_P_ ev_tstamp timeout) | |
| 92 92 | 
             
              int res;
         | 
| 93 93 |  | 
| 94 94 | 
             
              EV_RELEASE_CB;
         | 
| 95 | 
            -
              res = poll (polls, pollcnt,  | 
| 95 | 
            +
              res = poll (polls, pollcnt, ev_timeout_to_ms (timeout));
         | 
| 96 96 | 
             
              EV_ACQUIRE_CB;
         | 
| 97 97 |  | 
| 98 98 | 
             
              if (expect_false (res < 0))
         | 
    
        data/ext/libev/ev_port.c
    CHANGED
    
    | @@ -1,19 +1,19 @@ | |
| 1 1 | 
             
            /*
         | 
| 2 2 | 
             
             * libev solaris event port backend
         | 
| 3 3 | 
             
             *
         | 
| 4 | 
            -
             * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libev@schmorp.de>
         | 
| 4 | 
            +
             * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
         | 
| 5 5 | 
             
             * All rights reserved.
         | 
| 6 6 | 
             
             *
         | 
| 7 7 | 
             
             * Redistribution and use in source and binary forms, with or without modifica-
         | 
| 8 8 | 
             
             * tion, are permitted provided that the following conditions are met:
         | 
| 9 | 
            -
             * | 
| 9 | 
            +
             *
         | 
| 10 10 | 
             
             *   1.  Redistributions of source code must retain the above copyright notice,
         | 
| 11 11 | 
             
             *       this list of conditions and the following disclaimer.
         | 
| 12 | 
            -
             * | 
| 12 | 
            +
             *
         | 
| 13 13 | 
             
             *   2.  Redistributions in binary form must reproduce the above copyright
         | 
| 14 14 | 
             
             *       notice, this list of conditions and the following disclaimer in the
         | 
| 15 15 | 
             
             *       documentation and/or other materials provided with the distribution.
         | 
| 16 | 
            -
             * | 
| 16 | 
            +
             *
         | 
| 17 17 | 
             
             * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
         | 
| 18 18 | 
             
             * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
         | 
| 19 19 | 
             
             * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
         | 
| @@ -37,6 +37,17 @@ | |
| 37 37 | 
             
             * either the BSD or the GPL.
         | 
| 38 38 | 
             
             */
         | 
| 39 39 |  | 
| 40 | 
            +
            /* useful reading:
         | 
| 41 | 
            +
             *
         | 
| 42 | 
            +
             * http://bugs.opensolaris.org/view_bug.do?bug_id=6268715 (random results)
         | 
| 43 | 
            +
             * http://bugs.opensolaris.org/view_bug.do?bug_id=6455223 (just totally broken)
         | 
| 44 | 
            +
             * http://bugs.opensolaris.org/view_bug.do?bug_id=6873782 (manpage ETIME)
         | 
| 45 | 
            +
             * http://bugs.opensolaris.org/view_bug.do?bug_id=6874410 (implementation ETIME)
         | 
| 46 | 
            +
             * http://www.mail-archive.com/networking-discuss@opensolaris.org/msg11898.html ETIME vs. nget
         | 
| 47 | 
            +
             * http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/event_port.c (libc)
         | 
| 48 | 
            +
             * http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/fs/portfs/port.c#1325 (kernel)
         | 
| 49 | 
            +
             */
         | 
| 50 | 
            +
             | 
| 40 51 | 
             
            #include <sys/types.h>
         | 
| 41 52 | 
             
            #include <sys/time.h>
         | 
| 42 53 | 
             
            #include <poll.h>
         | 
| @@ -85,18 +96,20 @@ port_poll (EV_P_ ev_tstamp timeout) | |
| 85 96 | 
             
              struct timespec ts;
         | 
| 86 97 | 
             
              uint_t nget = 1;
         | 
| 87 98 |  | 
| 99 | 
            +
              /* we initialise this to something we will skip in the loop, as */
         | 
| 100 | 
            +
              /* port_getn can return with nget unchanged, but no indication */
         | 
| 101 | 
            +
              /* whether it was the original value or has been updated :/ */
         | 
| 102 | 
            +
              port_events [0].portev_source = 0;
         | 
| 103 | 
            +
             | 
| 88 104 | 
             
              EV_RELEASE_CB;
         | 
| 89 105 | 
             
              EV_TS_SET (ts, timeout);
         | 
| 90 106 | 
             
              res = port_getn (backend_fd, port_events, port_eventmax, &nget, &ts);
         | 
| 91 107 | 
             
              EV_ACQUIRE_CB;
         | 
| 92 108 |  | 
| 93 | 
            -
               | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
                  return;
         | 
| 99 | 
            -
                } 
         | 
| 109 | 
            +
              /* port_getn may or may not set nget on error */
         | 
| 110 | 
            +
              /* so we rely on port_events [0].portev_source not being updated */
         | 
| 111 | 
            +
              if (res == -1 && errno != ETIME && errno != EINTR)
         | 
| 112 | 
            +
                ev_syserr ("(libev) port_getn (see http://bugs.opensolaris.org/view_bug.do?bug_id=6268715, try LIBEV_FLAGS=3 env variable)");
         | 
| 100 113 |  | 
| 101 114 | 
             
              for (i = 0; i < nget; ++i)
         | 
| 102 115 | 
             
                {
         | 
| @@ -130,6 +143,8 @@ port_init (EV_P_ int flags) | |
| 130 143 | 
             
              if ((backend_fd = port_create ()) < 0)
         | 
| 131 144 | 
             
                return 0;
         | 
| 132 145 |  | 
| 146 | 
            +
              assert (("libev: PORT_SOURCE_FD must not be zero", PORT_SOURCE_FD));
         | 
| 147 | 
            +
             | 
| 133 148 | 
             
              fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */
         | 
| 134 149 |  | 
| 135 150 | 
             
              backend_fudge  = 1e-3; /* needed to compensate for port_getn returning early */
         | 
    
        data/ext/libev/ev_select.c
    CHANGED
    
    | @@ -6,14 +6,14 @@ | |
| 6 6 | 
             
             *
         | 
| 7 7 | 
             
             * Redistribution and use in source and binary forms, with or without modifica-
         | 
| 8 8 | 
             
             * tion, are permitted provided that the following conditions are met:
         | 
| 9 | 
            -
             * | 
| 9 | 
            +
             *
         | 
| 10 10 | 
             
             *   1.  Redistributions of source code must retain the above copyright notice,
         | 
| 11 11 | 
             
             *       this list of conditions and the following disclaimer.
         | 
| 12 | 
            -
             * | 
| 12 | 
            +
             *
         | 
| 13 13 | 
             
             *   2.  Redistributions in binary form must reproduce the above copyright
         | 
| 14 14 | 
             
             *       notice, this list of conditions and the following disclaimer in the
         | 
| 15 15 | 
             
             *       documentation and/or other materials provided with the distribution.
         | 
| 16 | 
            -
             * | 
| 16 | 
            +
             *
         | 
| 17 17 | 
             
             * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
         | 
| 18 18 | 
             
             * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
         | 
| 19 19 | 
             
             * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
         | 
| @@ -39,8 +39,11 @@ | |
| 39 39 |  | 
| 40 40 | 
             
            #ifndef _WIN32
         | 
| 41 41 | 
             
            /* for unix systems */
         | 
| 42 | 
            -
            # include <sys/select.h>
         | 
| 43 42 | 
             
            # include <inttypes.h>
         | 
| 43 | 
            +
            # ifndef __hpux
         | 
| 44 | 
            +
            /* for REAL unix systems */
         | 
| 45 | 
            +
            #  include <sys/select.h>
         | 
| 46 | 
            +
            # endif
         | 
| 44 47 | 
             
            #endif
         | 
| 45 48 |  | 
| 46 49 | 
             
            #ifndef EV_SELECT_USE_FD_SET
         | 
| @@ -280,10 +283,10 @@ select_init (EV_P_ int flags) | |
| 280 283 | 
             
              #endif
         | 
| 281 284 | 
             
            #else
         | 
| 282 285 | 
             
              vec_max = 0;
         | 
| 283 | 
            -
              vec_ri  = 0; | 
| 284 | 
            -
              vec_ro  = 0; | 
| 285 | 
            -
              vec_wi  = 0; | 
| 286 | 
            -
              vec_wo  = 0; | 
| 286 | 
            +
              vec_ri  = 0;
         | 
| 287 | 
            +
              vec_ro  = 0;
         | 
| 288 | 
            +
              vec_wi  = 0;
         | 
| 289 | 
            +
              vec_wo  = 0;
         | 
| 287 290 | 
             
              #ifdef _WIN32
         | 
| 288 291 | 
             
              vec_eo  = 0;
         | 
| 289 292 | 
             
              #endif
         | 
    
        data/ext/libev/ev_vars.h
    CHANGED
    
    | @@ -1,19 +1,19 @@ | |
| 1 1 | 
             
            /*
         | 
| 2 2 | 
             
             * loop member variable declarations
         | 
| 3 3 | 
             
             *
         | 
| 4 | 
            -
             * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libev@schmorp.de>
         | 
| 4 | 
            +
             * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
         | 
| 5 5 | 
             
             * All rights reserved.
         | 
| 6 6 | 
             
             *
         | 
| 7 7 | 
             
             * Redistribution and use in source and binary forms, with or without modifica-
         | 
| 8 8 | 
             
             * tion, are permitted provided that the following conditions are met:
         | 
| 9 | 
            -
             * | 
| 9 | 
            +
             *
         | 
| 10 10 | 
             
             *   1.  Redistributions of source code must retain the above copyright notice,
         | 
| 11 11 | 
             
             *       this list of conditions and the following disclaimer.
         | 
| 12 | 
            -
             * | 
| 12 | 
            +
             *
         | 
| 13 13 | 
             
             *   2.  Redistributions in binary form must reproduce the above copyright
         | 
| 14 14 | 
             
             *       notice, this list of conditions and the following disclaimer in the
         | 
| 15 15 | 
             
             *       documentation and/or other materials provided with the distribution.
         | 
| 16 | 
            -
             * | 
| 16 | 
            +
             *
         | 
| 17 17 | 
             
             * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
         | 
| 18 18 | 
             
             * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
         | 
| 19 19 | 
             
             * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
         | 
| @@ -102,6 +102,9 @@ VARx(int, pollidxmax) | |
| 102 102 | 
             
            #if EV_USE_EPOLL || EV_GENWRAP
         | 
| 103 103 | 
             
            VARx(struct epoll_event *, epoll_events)
         | 
| 104 104 | 
             
            VARx(int, epoll_eventmax)
         | 
| 105 | 
            +
            VARx(int *, epoll_eperms)
         | 
| 106 | 
            +
            VARx(int, epoll_epermcnt)
         | 
| 107 | 
            +
            VARx(int, epoll_epermmax)
         | 
| 105 108 | 
             
            #endif
         | 
| 106 109 |  | 
| 107 110 | 
             
            #if EV_USE_KQUEUE || EV_GENWRAP
         | 
| @@ -177,12 +180,15 @@ VAR (fs_hash, ANFS fs_hash [EV_INOTIFY_HASHSIZE]) | |
| 177 180 | 
             
            #endif
         | 
| 178 181 |  | 
| 179 182 | 
             
            VARx(EV_ATOMIC_T, sig_pending)
         | 
| 183 | 
            +
            VARx(int, nosigmask)
         | 
| 180 184 | 
             
            #if EV_USE_SIGNALFD || EV_GENWRAP
         | 
| 181 185 | 
             
            VARx(int, sigfd)
         | 
| 182 186 | 
             
            VARx(ev_io, sigfd_w)
         | 
| 183 187 | 
             
            VARx(sigset_t, sigfd_set)
         | 
| 184 188 | 
             
            #endif
         | 
| 185 189 |  | 
| 190 | 
            +
            VARx(unsigned int, origflags) /* original loop flags */
         | 
| 191 | 
            +
             | 
| 186 192 | 
             
            #if EV_FEATURE_API || EV_GENWRAP
         | 
| 187 193 | 
             
            VARx(unsigned int, loop_count) /* total number of loop iterations/blocks */
         | 
| 188 194 | 
             
            VARx(unsigned int, loop_depth) /* #ev_run enters - #ev_run leaves */
         | 
    
        data/ext/libev/ev_win32.c
    CHANGED
    
    | @@ -6,14 +6,14 @@ | |
| 6 6 | 
             
             *
         | 
| 7 7 | 
             
             * Redistribution and use in source and binary forms, with or without modifica-
         | 
| 8 8 | 
             
             * tion, are permitted provided that the following conditions are met:
         | 
| 9 | 
            -
             * | 
| 9 | 
            +
             *
         | 
| 10 10 | 
             
             *   1.  Redistributions of source code must retain the above copyright notice,
         | 
| 11 11 | 
             
             *       this list of conditions and the following disclaimer.
         | 
| 12 | 
            -
             * | 
| 12 | 
            +
             *
         | 
| 13 13 | 
             
             *   2.  Redistributions in binary form must reproduce the above copyright
         | 
| 14 14 | 
             
             *       notice, this list of conditions and the following disclaimer in the
         | 
| 15 15 | 
             
             *       documentation and/or other materials provided with the distribution.
         | 
| 16 | 
            -
             * | 
| 16 | 
            +
             *
         | 
| 17 17 | 
             
             * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
         | 
| 18 18 | 
             
             * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
         | 
| 19 19 | 
             
             * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
         | 
| @@ -46,7 +46,7 @@ | |
| 46 46 | 
             
            /* MSDN says this is required to handle SIGFPE */
         | 
| 47 47 | 
             
            /* my wild guess would be that using something floating-pointy is required */
         | 
| 48 48 | 
             
            /* for the crt to do something about it */
         | 
| 49 | 
            -
            volatile double SIGFPE_REQ = 0.0f; | 
| 49 | 
            +
            volatile double SIGFPE_REQ = 0.0f;
         | 
| 50 50 |  | 
| 51 51 | 
             
            /* oh, the humanity! */
         | 
| 52 52 | 
             
            static int
         | 
| @@ -59,7 +59,7 @@ ev_pipe (int filedes [2]) | |
| 59 59 | 
             
              SOCKET listener;
         | 
| 60 60 | 
             
              SOCKET sock [2] = { -1, -1 };
         | 
| 61 61 |  | 
| 62 | 
            -
              if ((listener = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) | 
| 62 | 
            +
              if ((listener = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
         | 
| 63 63 | 
             
                return -1;
         | 
| 64 64 |  | 
| 65 65 | 
             
              addr.sin_family = AF_INET;
         | 
| @@ -75,7 +75,7 @@ ev_pipe (int filedes [2]) | |
| 75 75 | 
             
              if (listen (listener, 1))
         | 
| 76 76 | 
             
                goto fail;
         | 
| 77 77 |  | 
| 78 | 
            -
              if ((sock [0] = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) | 
| 78 | 
            +
              if ((sock [0] = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
         | 
| 79 79 | 
             
                goto fail;
         | 
| 80 80 |  | 
| 81 81 | 
             
              if (connect (sock [0], (struct sockaddr *)&addr, addr_size))
         |