--- rxvt-unicode/src/iom.C 2004/12/15 02:53:49 1.25 +++ rxvt-unicode/src/iom.C 2005/11/29 19:22:48 1.30 @@ -1,8 +1,10 @@ /* iom.C -- generic I/O multiplexer - Copyright (C) 2003, 2004 Marc Lehmann + Copyright (C) 2003, 2004 Marc Lehmann - This program is free software; you can redistribute it and/or modify + This file is part of GVPE. + + GVPE is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -13,8 +15,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + along with gvpe; if not, write to the Free Software + Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "iom.h" @@ -35,7 +37,7 @@ // for IOM_SIG #if IOM_SIG -# include +# include # include #endif @@ -43,9 +45,6 @@ // until that happens, sys/select.h must come last #include -// TSTAMP_MAX must still fit into a positive struct timeval -#define TSTAMP_MAX (double)(1UL<<31) - #define TIMEVAL timeval #define TV_FRAC tv_usec #define TV_MULT 1000000L @@ -382,7 +381,17 @@ # endif # if IOM_TIME - set_now (); + { + // update time, try to compensate for gross non-monotonic time changes + tstamp diff = NOW; + set_now (); + diff = NOW - diff; + + if (diff < 0) + for (io_manager_vec::const_iterator i = tw.end (); i-- > tw.begin (); ) + if (*i) + (*i)->at += diff; + } # endif if (fds > 0) @@ -416,13 +425,14 @@ iow.erase_unordered (i); else { - short revents = iow[i]->events; + io_watcher &w = *iow[i]; + short revents = w.events; - if (!FD_ISSET (iow[i]->fd, &rfd)) revents &= ~EVENT_READ; - if (!FD_ISSET (iow[i]->fd, &wfd)) revents &= ~EVENT_WRITE; + if (!FD_ISSET (w.fd, &rfd)) revents &= ~EVENT_READ; + if (!FD_ISSET (w.fd, &wfd)) revents &= ~EVENT_WRITE; if (revents) - iow[i]->call (*iow[i], revents); + w.call (w, revents); } #endif }