Browse code

use new socket after failure

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

Tomasz Kojm authored on 2005/01/26 23:33:02
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Wed Jan 26 15:25:56 CET 2005 (tk)
2
+---------------------------------
3
+  * freshclam/manager.c: wwwconnect(): use new socket after failure (patch by 
4
+			 Geoff Gibbs <ggibbs*hgmp.mrc.ac.uk>)
5
+
1 6
 Wed Jan 26 15:10:02 CET 2005 (tk)
2 7
 ---------------------------------
3 8
   * shared/misc.c: freshdbdir(): fix possible dbdir string corruption
... ...
@@ -423,13 +423,6 @@ int wwwconnect(const char *server, const char *proxy, int pport, char *ip)
423 423
     if(ip)
424 424
 	strcpy(ip, "???");
425 425
 
426
-    /* njh@bandsman.co.uk: for BEOS */
427
-#ifdef PF_INET
428
-    socketfd = socket(PF_INET, SOCK_STREAM, 0);
429
-#else
430
-    socketfd = socket(AF_INET, SOCK_STREAM, 0);
431
-#endif
432
-
433 426
     name.sin_family = AF_INET;
434 427
 
435 428
     if(proxy) {
... ...
@@ -474,8 +467,15 @@ int wwwconnect(const char *server, const char *proxy, int pport, char *ip)
474 474
 	name.sin_addr = *((struct in_addr *) host->h_addr_list[i]);
475 475
 	name.sin_port = htons(port);
476 476
 
477
+#ifdef PF_INET
478
+	socketfd = socket(PF_INET, SOCK_STREAM, 0);
479
+#else
480
+	socketfd = socket(AF_INET, SOCK_STREAM, 0);
481
+#endif
482
+
477 483
 	if(connect(socketfd, (struct sockaddr *) &name, sizeof(struct sockaddr_in)) == -1) {
478 484
 	    mprintf("Can't connect to port %d of host %s (%s)\n", port, hostpt, ipaddr);
485
+	    close(socketfd);
479 486
 	    continue;
480 487
 	}
481 488