Browse code

disable timeout when ReadTimeout=0

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@451 77e5149b-7576-45b1-b177-96237e5ba77b

Trog authored on 2004/03/30 00:06:07
Showing 4 changed files
... ...
@@ -1,3 +1,7 @@
1
+Mon Mar 29 16:17:05 BST 2004 (trog)
2
+-----------------------------------
3
+  * clamd: disable timeout when ReadTimeout=0
4
+
1 5
 Mon Mar 29 15:45:15 BST 2004 (trog)
2 6
 -----------------------------------
3 7
   * clamd: add support for ReadTimeout option
... ...
@@ -98,8 +98,11 @@ int poll_fd(int fd, int timeout_sec)
98 98
     poll_data[0].events = POLLIN;
99 99
     poll_data[0].revents = 0;
100 100
 
101
+    if (timeout_sec > 0) {
102
+    	timeout_sec *= 1000;
103
+    }
101 104
     while (1) {
102
-    	retval = poll(poll_data, 1, timeout_sec*1000);
105
+    	retval = poll(poll_data, 1, timeout_sec);
103 106
 	if (retval == -1) {
104 107
    	    if (errno == EINTR) {
105 108
 		continue;
... ...
@@ -123,7 +126,8 @@ int poll_fd(int fd, int timeout_sec)
123 123
 	tv.tv_sec = timeout_sec;
124 124
 	tv.tv_usec = 0;
125 125
 
126
-	retval = select(fd+1, &rfds, NULL, NULL, &tv);
126
+	retval = select(fd+1, &rfds, NULL, NULL,
127
+			(timeout_sec>0 ? &tv : NULL));
127 128
 	if (retval == -1) {
128 129
 	    if (errno == EINTR) {
129 130
 		continue;
... ...
@@ -227,6 +227,9 @@ int scanstream(int odesc, unsigned long int *scanned, const struct cl_node *root
227 227
     } else {
228 228
 	timeout = CL_DEFAULT_SCANTIMEOUT;
229 229
     }
230
+    if (timeout == 0) {
231
+    	timeout = -1;
232
+    }
230 233
 
231 234
     if(!bound && !portscan) {
232 235
 	mdprintf(odesc, "ERROR\n");
... ...
@@ -67,7 +67,10 @@ int command(int desc, const struct cl_node *root, const struct cl_limits *limits
67 67
     } else {
68 68
 	timeout = CL_DEFAULT_SCANTIMEOUT;
69 69
     }
70
-    
70
+    if (timeout == 0) {
71
+    	timeout = -1;
72
+    }
73
+       
71 74
     retval = poll_fd(desc, timeout);
72 75
     switch (retval) {
73 76
     case 0: /* timeout */