Commit Diff
Diff:
579f6873c39e47bf96113ec9b04ce20996915631
e3c23322b3ba1ec2606dd53fb756d82e6830f94c
Commit:
e3c23322b3ba1ec2606dd53fb756d82e6830f94c
Tree:
ad8501e5d9d0e2514120788f204ab8134d23df58
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Fri Jul 3 09:14:39 2020 UTC
Message:
wrap a timeout of 2 seconds around the receiving TCP socket after we sent off a question, 2 seconds is short, hopefully not too short
blob - 5544c5bb0b4ef35b85eccf64ea476ab863fa0727
blob + ab90a7a43818c96c8f21f8626fa006fc46c85e39
--- forward.c
+++ forward.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: forward.c,v 1.5 2020/07/03 09:04:07 pjp Exp $
+ * $Id: forward.c,v 1.6 2020/07/03 09:14:39 pjp Exp $
*/
#include <sys/types.h>
@@ -210,10 +210,14 @@ insert_forward(int family, struct sockaddr_storage *ip
void
forwardloop(ddDB *db, struct cfg *cfg, struct imsgbuf *ibuf)
{
- char *buf;
+ struct timeval tv;
struct imsg imsg;
+
+ char *buf;
+
int max, sel;
int len, need;
+
ssize_t n, datalen;
fd_set rset;
@@ -245,6 +249,14 @@ forwardloop(ddDB *db, struct cfg *cfg, struct imsgbuf
SLIST_FOREACH_SAFE(fwq1, &fwqhead, entries, fwqp) {
if (FD_ISSET(fwq1->so, &rset)) {
if (fwq1->istcp) {
+ tv.tv_sec = 2;
+ tv.tv_usec = 0;
+
+ if (setsockopt(fwq1->so, SOL_SOCKET, SO_RCVTIMEO, &tv,
+ sizeof(tv)) < 0) {
+ goto drop;
+ }
+
len = recv(fwq1->so, buf, 2, MSG_WAITALL);
if (len <= 0)
goto drop;
repomaster@centroid.eu