1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Decrement the timeout being passed to poll() if poll was interrupted for

some reason.  This will prevent an infinite loop if (say) a sigalarm is
being scheduled at a more frequent interval than the poll timeout.

PR:	2191, 8847, 10553
This commit is contained in:
Jonathan Lemon 2000-03-26 19:20:50 +00:00
parent b10e6acec4
commit 6134837824
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=58637

View File

@ -635,11 +635,17 @@ res_send(buf, buflen, ans, anssiz)
#ifndef NOPOLL
othersyscall:
if (use_poll) {
struct timeval itv;
msec = (_res.retrans << try) * 1000;
if (try > 0)
msec /= _res.nscount;
if (msec <= 0)
msec = 1000;
gettimeofday(&timeout, NULL);
itv.tv_sec = msec / 1000;
itv.tv_usec = (msec % 1000) * 1000;
timeradd(&timeout, &itv, &timeout);
} else {
#endif
timeout.tv_sec = (_res.retrans << try);
@ -685,12 +691,23 @@ res_send(buf, buflen, ans, anssiz)
} else if (use_poll == 1)
use_poll = 2;
if (n < 0) {
if (errno == EINTR)
if (errno == EINTR) {
struct timeval ctv;
gettimeofday(&ctv, NULL);
if (timercmp(&ctv, &timeout, <)) {
timersub(&timeout,
&ctv, &ctv);
msec = ctv.tv_sec * 1000;
msec += ctv.tv_usec / 1000;
goto wait;
}
} else {
Perror(stderr, "poll", errno);
res_close();
goto next_ns;
}
}
} else {
#endif
dsmasklen = howmany(s + 1, NFDBITS) *