Finesse TCP timeouts for upstream connections.

Timeouts for TCP connections to non-responive servers are very long.
This in not appropriate for DNS connections.

Set timeouts for connection setup, sending data and recieving data.
The timeouts for connection setup and sending data are set at 5 seconds.
For recieving the reply this is doubled, to take into account the
time for usptream to actually get the answer.

Thanks to Petr Menšík for pointing out this problem, and finding a better
and more portable solution than the one in place heretofore.
This commit is contained in:
Simon Kelley committed 2024-11-25 23:18:07 +00:00
1 parent 481ff0ed10
commit 32a8f3e009
10 files changed
+113 -85

No files matched your search

+2 -2
View File
@@ -101,7 +101,7 @@ static struct blockdata *blockdata_alloc_real(int fd, char *data, size_t len)
memcpy(block->key, data, blen);
data += blen;
}
else if (!read_write(fd, block->key, blen, 1))
else if (!read_write(fd, block->key, blen, RW_READ))
{
/* failed read free partial chain */
blockdata_free(ret);
@@ -228,7 +228,7 @@ void blockdata_write(struct blockdata *block, size_t len, int fd)
for (; len > 0 && block; block = block->next)
{
size_t blen = len > KEYBLOCK_LEN ? KEYBLOCK_LEN : len;
read_write(fd, block->key, blen, 0);
read_write(fd, block->key, blen, RW_WRITE);
len -= blen;
}
}