changeset 6477:08712c93b643

Here I go again, another fix for the timeout. Note that we shouldn't rely on the value of the timeval struct after select returns.
author bertrand
date Fri, 21 Jun 2002 07:06:46 +0000
parents a48a7315ed88
children feb97a44080b
files libmpdemux/network.c
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/network.c	Fri Jun 21 06:28:24 2002 +0000
+++ b/libmpdemux/network.c	Fri Jun 21 07:06:46 2002 +0000
@@ -168,16 +168,16 @@
 			return -1;
 		}
 	}
-	tv.tv_sec = 5;
-	tv.tv_usec = 0;
+	tv.tv_sec = 0;
+	tv.tv_usec = 500000;
 	FD_ZERO( &set );
 	FD_SET( socket_server_fd, &set );
 	// When the connection will be made, we will have a writable fd
 	while((ret = select(socket_server_fd+1, NULL, &set, NULL, &tv)) == 0) {
 	      if( ret<0 ) mp_msg(MSGT_NETWORK,MSGL_ERR,"select failed\n");
 	      else if(ret > 0) break;
-	      else if(count > 15 || mpdemux_check_interrupt(500)) {
-		if(count > 15)
+	      else if(count > 30 || mpdemux_check_interrupt(500)) {
+		if(count > 30)
 		  mp_msg(MSGT_NETWORK,MSGL_ERR,"Connection timeout\n");
 		else
 		  mp_msg(MSGT_NETWORK,MSGL_V,"Connection interuppted by user\n");
@@ -186,6 +186,8 @@
 	      count++;
 	      FD_ZERO( &set );
 	      FD_SET( socket_server_fd, &set );
+	      tv.tv_sec = 0;
+	      tv.tv_usec = 500000;
 	}
 
 	// Turn back the socket as blocking