ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/iom.C
(Generate patch)

Comparing rxvt-unicode/src/iom.C (file contents):
Revision 1.23 by root, Sun Nov 14 22:24:09 2004 UTC vs.
Revision 1.27 by root, Mon Dec 20 16:44:31 2004 UTC

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
94 } tw0; 94 } tw0;
95 95
96tstamp NOW; 96tstamp NOW;
97 97
98#if IOM_TIME 98#if IOM_TIME
99inline void set_now (void) 99tstamp io_manager::now ()
100{ 100{
101 struct timeval tv; 101 struct timeval tv;
102 102
103 gettimeofday (&tv, 0); 103 gettimeofday (&tv, 0);
104 NOW = (tstamp)tv.tv_sec + (tstamp)tv.tv_usec / 1000000.; 104 return (tstamp)tv.tv_sec + (tstamp)tv.tv_usec / 1000000.;
105}
106
107void io_manager::set_now ()
108{
109 NOW = now ();
105} 110}
106#endif 111#endif
107 112
108static bool iom_valid; 113static bool iom_valid;
109 114
118 { 123 {
119 perror ("io_manager: unable to create signal pipe, aborting."); 124 perror ("io_manager: unable to create signal pipe, aborting.");
120 abort (); 125 abort ();
121 } 126 }
122 127
123 fcntl (sigpipe[0], F_SETFL, O_NONBLOCK); 128 fcntl (sigpipe[0], F_SETFL, O_NONBLOCK); fcntl (sigpipe[0], F_SETFD, FD_CLOEXEC);
124 fcntl (sigpipe[1], F_SETFL, O_NONBLOCK); 129 fcntl (sigpipe[1], F_SETFL, O_NONBLOCK); fcntl (sigpipe[1], F_SETFD, FD_CLOEXEC);
125#endif 130#endif
126 131
127 iom_valid = true; 132 iom_valid = true;
128 133
129#if IOM_TIME 134#if IOM_TIME
130 set_now (); 135 io_manager::set_now ();
131 136
132 tw0.start (TSTAMP_MAX); 137 tw0.start (TSTAMP_MAX);
133#endif 138#endif
134 } 139 }
135 140
409 for (int i = iow.size (); i--; ) 414 for (int i = iow.size (); i--; )
410 if (!iow[i]) 415 if (!iow[i])
411 iow.erase_unordered (i); 416 iow.erase_unordered (i);
412 else 417 else
413 { 418 {
419 io_watcher &w = *iow[i];
414 short revents = iow[i]->events; 420 short revents = w.events;
415 421
416 if (!FD_ISSET (iow[i]->fd, &rfd)) revents &= ~EVENT_READ; 422 if (!FD_ISSET (w.fd, &rfd)) revents &= ~EVENT_READ;
417 if (!FD_ISSET (iow[i]->fd, &wfd)) revents &= ~EVENT_WRITE; 423 if (!FD_ISSET (w.fd, &wfd)) revents &= ~EVENT_WRITE;
418 424
419 if (revents) 425 if (revents)
420 iow[i]->call (*iow[i], revents); 426 w.call (w, revents);
421 } 427 }
422#endif 428#endif
423 } 429 }
424 else if (fds < 0 && errno != EINTR) 430 else if (fds < 0 && errno != EINTR)
425 { 431 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines