summaryrefslogtreecommitdiff
path: root/network/redir/patches/04_fix_timeouts.dpatch
blob: 87c1984517c5fd02e4fd4a46f89db8013408eb2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /bin/sh /usr/share/dpatch/dpatch-run
## 04_fix_timeouts.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Apply a close approximation of Robert de Bath's patch for bug #142382

@DPATCH@
diff -urNad redir-2.2.1~/redir.c redir-2.2.1/redir.c
--- redir-2.2.1~/redir.c	2005-10-22 22:44:39.504061784 -0400
+++ redir-2.2.1/redir.c	2005-10-22 22:47:14.746461352 -0400
@@ -598,10 +598,6 @@
 	/* Record start time */
 	start_time = (unsigned int) time(NULL);
 
-	/* Set up timeout */
-	timeout.tv_sec = timeout_secs;
-	timeout.tv_usec = 0;
-
 	/* file descriptor bits */
 	FD_ZERO(&iofds);
 	FD_SET(insock, &iofds);
@@ -618,14 +614,21 @@
 	while(1) {
 		(void) memcpy(&c_iofds, &iofds, sizeof(iofds));
 
+		/* Set up timeout, Linux returns seconds left in this structure
+		 * so we have to reset it before each select(). */
+		timeout.tv_sec = timeout_secs;
+		timeout.tv_usec = 0;
+
 
 		if (select(max_fd + 1,
 			   &c_iofds,
 			   (fd_set *)0,
 			   (fd_set *)0,
 			   (timeout_secs ? &timeout : NULL)) <= 0) {
-			/*	    syslog(LLEV,"connection timeout: %d sec",timeout.tv_sec);*/
-			break;
+		  if (dosyslog) {
+		    syslog(LOG_NOTICE,"connection timeout: %d sec",timeout_secs);
+		  }
+		  break;
 		}
 
 		if(FD_ISSET(insock, &c_iofds)) {