… | |
… | |
33 | # include <time.h> |
33 | # include <time.h> |
34 | #endif |
34 | #endif |
35 | |
35 | |
36 | // for IOM_SIG |
36 | // for IOM_SIG |
37 | #if IOM_SIG |
37 | #if IOM_SIG |
38 | # include <signal.h> |
38 | # include <csignal> |
39 | # include <fcntl.h> |
39 | # include <fcntl.h> |
40 | #endif |
40 | #endif |
41 | |
41 | |
42 | // if the BSDs would at least be marginally POSIX-compatible.. *sigh* |
42 | // if the BSDs would at least be marginally POSIX-compatible.. *sigh* |
43 | // until that happens, sys/select.h must come last |
43 | // until that happens, sys/select.h must come last |
… | |
… | |
380 | # if IOM_SIG |
380 | # if IOM_SIG |
381 | sigprocmask (SIG_BLOCK, &sigs, NULL); |
381 | sigprocmask (SIG_BLOCK, &sigs, NULL); |
382 | # endif |
382 | # endif |
383 | |
383 | |
384 | # if IOM_TIME |
384 | # if IOM_TIME |
|
|
385 | { |
|
|
386 | // update time, try to compensate for gross non-monotonic time changes |
|
|
387 | tstamp diff = NOW; |
385 | set_now (); |
388 | set_now (); |
|
|
389 | diff = NOW - diff; |
|
|
390 | |
|
|
391 | if (diff < 0) |
|
|
392 | for (io_manager_vec<time_watcher>::const_iterator i = tw.end (); i-- > tw.begin (); ) |
|
|
393 | if (*i) |
|
|
394 | (*i)->at += diff; |
|
|
395 | } |
386 | # endif |
396 | # endif |
387 | |
397 | |
388 | if (fds > 0) |
398 | if (fds > 0) |
389 | { |
399 | { |
390 | # if IOM_SIG |
400 | # if IOM_SIG |
… | |
… | |
414 | for (int i = iow.size (); i--; ) |
424 | for (int i = iow.size (); i--; ) |
415 | if (!iow[i]) |
425 | if (!iow[i]) |
416 | iow.erase_unordered (i); |
426 | iow.erase_unordered (i); |
417 | else |
427 | else |
418 | { |
428 | { |
|
|
429 | io_watcher &w = *iow[i]; |
419 | short revents = iow[i]->events; |
430 | short revents = w.events; |
420 | |
431 | |
421 | if (!FD_ISSET (iow[i]->fd, &rfd)) revents &= ~EVENT_READ; |
432 | if (!FD_ISSET (w.fd, &rfd)) revents &= ~EVENT_READ; |
422 | if (!FD_ISSET (iow[i]->fd, &wfd)) revents &= ~EVENT_WRITE; |
433 | if (!FD_ISSET (w.fd, &wfd)) revents &= ~EVENT_WRITE; |
423 | |
434 | |
424 | if (revents) |
435 | if (revents) |
425 | iow[i]->call (*iow[i], revents); |
436 | w.call (w, revents); |
426 | } |
437 | } |
427 | #endif |
438 | #endif |
428 | } |
439 | } |
429 | else if (fds < 0 && errno != EINTR) |
440 | else if (fds < 0 && errno != EINTR) |
430 | { |
441 | { |