Lines 188-195
Link Here
|
188 |
|
188 |
|
189 |
char const *progname; |
189 |
char const *progname; |
190 |
|
190 |
|
191 |
int was_alarmed; |
|
|
192 |
|
193 |
#ifdef DECL_SYSCALL |
191 |
#ifdef DECL_SYSCALL |
194 |
/* |
192 |
/* |
195 |
* We put this here, since the argument profile is syscall-specific |
193 |
* We put this here, since the argument profile is syscall-specific |
Lines 443-448
Link Here
|
443 |
msyslog(LOG_ERR, "set_process_priority: No way found to improve our priority"); |
441 |
msyslog(LOG_ERR, "set_process_priority: No way found to improve our priority"); |
444 |
} |
442 |
} |
445 |
|
443 |
|
|
|
444 |
#define TS_LAST_SIZE 2 |
446 |
|
445 |
|
447 |
/* |
446 |
/* |
448 |
* Main program. Initialize us, disconnect us from the tty if necessary, |
447 |
* Main program. Initialize us, disconnect us from the tty if necessary, |
Lines 455-460
Link Here
|
455 |
) |
454 |
) |
456 |
{ |
455 |
{ |
457 |
l_fp now; |
456 |
l_fp now; |
|
|
457 |
l_fp ts_last[TS_LAST_SIZE]; |
458 |
unsigned int ts_last_index; |
459 |
int time_elapsed; |
458 |
struct recvbuf *rbuf; |
460 |
struct recvbuf *rbuf; |
459 |
#ifdef _AIX /* HMS: ifdef SIGDANGER? */ |
461 |
#ifdef _AIX /* HMS: ifdef SIGDANGER? */ |
460 |
struct sigaction sa; |
462 |
struct sigaction sa; |
Lines 1012-1018
Link Here
|
1012 |
#else /* normal I/O */ |
1014 |
#else /* normal I/O */ |
1013 |
|
1015 |
|
1014 |
BLOCK_IO_AND_ALARM(); |
1016 |
BLOCK_IO_AND_ALARM(); |
1015 |
was_alarmed = 0; |
1017 |
|
|
|
1018 |
for (ts_last_index = 0; ts_last_index < TS_LAST_SIZE; ts_last_index++) |
1019 |
L_CLR(&ts_last[ts_last_index]); |
1020 |
time_elapsed = 0; |
1021 |
|
1016 |
for (;;) |
1022 |
for (;;) |
1017 |
{ |
1023 |
{ |
1018 |
# if !defined(HAVE_SIGNALED_IO) |
1024 |
# if !defined(HAVE_SIGNALED_IO) |
Lines 1023-1061
Link Here
|
1023 |
int nfound; |
1029 |
int nfound; |
1024 |
# endif |
1030 |
# endif |
1025 |
|
1031 |
|
1026 |
if (alarm_flag) /* alarmed? */ |
1032 |
if (has_full_recv_buffer() == ISC_FALSE) |
1027 |
{ |
|
|
1028 |
was_alarmed = 1; |
1029 |
alarm_flag = 0; |
1030 |
} |
1031 |
|
1032 |
if (!was_alarmed && has_full_recv_buffer() == ISC_FALSE) |
1033 |
{ |
1033 |
{ |
1034 |
/* |
1034 |
/* |
1035 |
* Nothing to do. Wait for something. |
1035 |
* Nothing to do. Wait for something. |
1036 |
*/ |
1036 |
*/ |
1037 |
# ifndef HAVE_SIGNALED_IO |
1037 |
# ifndef HAVE_SIGNALED_IO |
|
|
1038 |
extern l_fp timer_base; |
1039 |
l_fp ts, ts2, ts3; |
1040 |
double d; |
1041 |
|
1038 |
rdfdes = activefds; |
1042 |
rdfdes = activefds; |
1039 |
# if defined(VMS) || defined(SYS_VXWORKS) |
1043 |
ts2 = timer_base; |
1040 |
/* make select() wake up after one second */ |
1044 |
get_systime(&ts); |
1041 |
{ |
1045 |
ts3 = ts; |
|
|
1046 |
L_SUB(&ts3, &ts_last[ts_last_index]); |
1047 |
|
1048 |
/* don't call when_next_event() too often */ |
1049 |
if (ts3.l_ui) |
1050 |
ts2.l_ui += when_next_event(); |
1051 |
else |
1052 |
ts2.l_ui += 1; |
1053 |
|
1054 |
L_SUB(&ts2, &ts); |
1055 |
LFPTOD(&ts2, d); |
1056 |
#if 0 |
1057 |
printf("%f ", d); |
1058 |
#endif |
1059 |
if (d >= 0.0) { |
1042 |
struct timeval t1; |
1060 |
struct timeval t1; |
1043 |
|
1061 |
|
1044 |
t1.tv_sec = 1; t1.tv_usec = 0; |
1062 |
/* shoot 1ms over */ |
|
|
1063 |
d += 0.001; |
1064 |
t1.tv_sec = floor(d); |
1065 |
t1.tv_usec = (d - t1.tv_sec) * 1000000; |
1045 |
nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0, |
1066 |
nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0, |
1046 |
(fd_set *)0, &t1); |
1067 |
(fd_set *)0, &t1); |
1047 |
} |
|
|
1048 |
# else |
1049 |
nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0, |
1050 |
(fd_set *)0, (struct timeval *)0); |
1051 |
# endif /* VMS */ |
1052 |
if (nfound > 0) |
1053 |
{ |
1054 |
l_fp ts; |
1055 |
|
1056 |
get_systime(&ts); |
1068 |
get_systime(&ts); |
|
|
1069 |
} else |
1070 |
nfound = 0; |
1057 |
|
1071 |
|
|
|
1072 |
ts2 = ts; |
1073 |
L_SUB(&ts2, &timer_base); |
1074 |
time_elapsed += ts2.l_ui; |
1075 |
timer_base.l_ui += ts2.l_ui; |
1076 |
#if 0 |
1077 |
ts2 = ts; |
1078 |
ts2.l_ui = 0; |
1079 |
LFPTOD(&ts2, d); |
1080 |
printf("%f\n", d); |
1081 |
#endif |
1082 |
if (nfound > 0) |
1083 |
{ |
1058 |
(void)input_handler(&ts); |
1084 |
(void)input_handler(&ts); |
|
|
1085 |
ts_last[ts_last_index] = ts; |
1086 |
ts_last_index = (ts_last_index + 1) % TS_LAST_SIZE; |
1059 |
} |
1087 |
} |
1060 |
else if (nfound == -1 && errno != EINTR) |
1088 |
else if (nfound == -1 && errno != EINTR) |
1061 |
netsyslog(LOG_ERR, "select() error: %m"); |
1089 |
netsyslog(LOG_ERR, "select() error: %m"); |
Lines 1067-1088
Link Here
|
1067 |
|
1095 |
|
1068 |
wait_for_signal(); |
1096 |
wait_for_signal(); |
1069 |
# endif /* HAVE_SIGNALED_IO */ |
1097 |
# endif /* HAVE_SIGNALED_IO */ |
1070 |
if (alarm_flag) /* alarmed? */ |
|
|
1071 |
{ |
1072 |
was_alarmed = 1; |
1073 |
alarm_flag = 0; |
1074 |
} |
1075 |
} |
1098 |
} |
1076 |
|
1099 |
|
1077 |
if (was_alarmed) |
1100 |
if (time_elapsed) |
1078 |
{ |
1101 |
{ |
1079 |
UNBLOCK_IO_AND_ALARM(); |
1102 |
UNBLOCK_IO_AND_ALARM(); |
1080 |
/* |
1103 |
/* |
1081 |
* Out here, signals are unblocked. Call timer routine |
1104 |
* Out here, signals are unblocked. Call timer routine |
1082 |
* to process expiry. |
1105 |
* to process expiry. |
1083 |
*/ |
1106 |
*/ |
1084 |
timer(); |
1107 |
timer(time_elapsed); |
1085 |
was_alarmed = 0; |
1108 |
time_elapsed = 0; |
1086 |
BLOCK_IO_AND_ALARM(); |
1109 |
BLOCK_IO_AND_ALARM(); |
1087 |
} |
1110 |
} |
1088 |
|
1111 |
|