List:Internals« Previous MessageNext Message »
From:ramil Date:July 27 2005 12:41pm
Subject:bk commit into 4.1 tree (ramil:1.2347) BUG#5449
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of ram. When ram does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2347 05/07/27 17:41:34 ramil@stripped +4 -0
  A fix (bug #5449: Client hangs if connection to remote server is dropped).

  vio/viosocket.c
    1.33 05/07/27 17:41:29 ramil@stripped +15 -18
    A fix (bug #5449: Client hangs if connection to remote server is dropped).

  sql/net_serv.cc
    1.75 05/07/27 17:41:29 ramil@stripped +13 -14
    A fix (bug #5449: Client hangs if connection to remote server is dropped).

  sql-common/client.c
    1.86 05/07/27 17:41:29 ramil@stripped +6 -0
    A fix (bug #5449: Client hangs if connection to remote server is dropped).

  include/violite.h
    1.41 05/07/27 17:41:28 ramil@stripped +3 -3
    A fix (bug #5449: Client hangs if connection to remote server is dropped).

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	ramil
# Host:	gw.mysql.r18.ru
# Root:	/usr/home/ram/work/4.1.b11774

--- 1.40/include/violite.h	2005-05-05 20:13:57 +05:00
+++ 1.41/include/violite.h	2005-07-27 17:41:28 +05:00
@@ -81,7 +81,7 @@
 /* Remotes in_addr */
 void	vio_in_addr(Vio *vio, struct in_addr *in);
 my_bool	vio_poll_read(Vio *vio,uint timeout);
-void	vio_timeout(Vio *vio,uint which, uint timeout);
+void	vio_timeout(Vio *vio, uint which, uint milliseconds);
 
 #ifdef HAVE_OPENSSL
 #include <openssl/opensslv.h>
@@ -149,7 +149,7 @@
 #define vio_close(vio)				((vio)->vioclose)(vio)
 #define vio_peer_addr(vio, buf, prt)		(vio)->peer_addr(vio, buf, prt)
 #define vio_in_addr(vio, in)			(vio)->in_addr(vio, in)
-#define vio_timeout(vio, which, seconds)	(vio)->timeout(vio, which, seconds)
+#define vio_timeout(vio, which, milliseconds)	(vio)->timeout(vio, which, milliseconds)
 #endif /* defined(HAVE_VIO) && !defined(DONT_MAP_VIO) */
 
 /* This enumerator is used in parser - should be always visible */
@@ -189,7 +189,7 @@
   void    (*in_addr)(Vio*, struct in_addr*);
   my_bool (*should_retry)(Vio*);
   int     (*vioclose)(Vio*);
-  void	  (*timeout)(Vio*, unsigned int which, unsigned int timeout);
+  void	  (*timeout)(Vio*, unsigned int which, unsigned int milliseconds);
   void	  *ssl_arg;
 #ifdef HAVE_SMEM
   HANDLE  handle_file_map;

--- 1.74/sql/net_serv.cc	2005-07-12 19:56:30 +05:00
+++ 1.75/sql/net_serv.cc	2005-07-27 17:41:29 +05:00
@@ -485,13 +485,10 @@
 #endif /* HAVE_COMPRESS */
 
   /* DBUG_DUMP("net",packet,len); */
-#ifndef NO_ALARM
   thr_alarm_init(&alarmed);
+#ifndef NO_ALARM
   if (net_blocking)
     thr_alarm(&alarmed,(uint) net->write_timeout,&alarm_buff);
-#else
-  alarmed=0;
-  vio_timeout(net->vio, 1, net->write_timeout);
 #endif /* NO_ALARM */
 
   pos=(char*) packet; end=pos+len;
@@ -506,9 +503,11 @@
         if (!thr_alarm(&alarmed,(uint) net->write_timeout,&alarm_buff))
         {                                       /* Always true for client */
 	  my_bool old_mode;
+          uint fcntl_count= 0;
+
 	  while (vio_blocking(net->vio, TRUE, &old_mode) < 0)
 	  {
-	    if (vio_should_retry(net->vio) && retry_count++ < net->retry_count)
+	    if (vio_should_retry(net->vio) && fcntl_count++ < net->retry_count)
 	      continue;
 #ifdef EXTRA_DEBUG
 	    fprintf(stderr,
@@ -522,8 +521,8 @@
             net->report_error= 1;
 	    goto end;
 	  }
-	  retry_count=0;
-	  continue;
+          if (retry_count++ < net->retry_count)
+            continue;
 	}
       }
       else
@@ -539,7 +538,7 @@
 #endif /* EXTRA_DEBUG */
       }
 #if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER)
-      if (vio_errno(net->vio) == SOCKET_EINTR)
+      if (interrupted && retry_count++ < net->retry_count)
       {
 	DBUG_PRINT("warning",("Interrupted write. Retrying..."));
 	continue;
@@ -683,8 +682,6 @@
 #ifndef NO_ALARM
   if (net_blocking)
     thr_alarm(&alarmed,net->read_timeout,&alarm_buff);
-#else
-  vio_timeout(net->vio, 0, net->read_timeout);
 #endif /* NO_ALARM */
 
     pos = net->buff + net->where_b;		/* net->packet -4 */
@@ -710,10 +707,12 @@
 	    if (!thr_alarm(&alarmed,net->read_timeout,&alarm_buff)) /* Don't wait too long */
 	    {
 	      my_bool old_mode;
+              uint fcntl_count= 0;
+
 	      while (vio_blocking(net->vio, TRUE, &old_mode) < 0)
 	      {
 		if (vio_should_retry(net->vio) &&
-		    retry_count++ < net->retry_count)
+		    fcntl_count++ < net->retry_count)
 		  continue;
 		DBUG_PRINT("error",
 			   ("fcntl returned error %d, aborting thread",
@@ -731,8 +730,8 @@
 #endif
 		goto end;
 	      }
-	      retry_count=0;
-	      continue;
+              if (retry_count++ < net->retry_count)
+                continue;
 	    }
 	  }
 #endif /* (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER) */
@@ -747,7 +746,7 @@
 #endif /* EXTRA_DEBUG */
 	  }
 #if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER)
-	  if (vio_should_retry(net->vio))
+	  if (interrupted && retry_count++ < net->retry_count)
 	  {
 	    DBUG_PRINT("warning",("Interrupted read. Retrying..."));
 	    continue;

--- 1.85/sql-common/client.c	2005-07-19 20:31:13 +05:00
+++ 1.86/sql-common/client.c	2005-07-27 17:41:29 +05:00
@@ -1800,9 +1800,15 @@
   vio_keepalive(net->vio,TRUE);
   /* Override local client variables */
   if (mysql->options.read_timeout)
+  {
     net->read_timeout= mysql->options.read_timeout;
+    vio_timeout(net->vio, 0, net->read_timeout * 1000 / (net->retry_count + 1));
+  }
   if (mysql->options.write_timeout)
+  {
     net->write_timeout= mysql->options.write_timeout;
+    vio_timeout(net->vio, 1, net->write_timeout * 1000 / (net->retry_count + 1));
+  }
   if (mysql->options.max_allowed_packet)
     net->max_packet_size= mysql->options.max_allowed_packet;
 

--- 1.32/vio/viosocket.c	2005-07-12 19:56:30 +05:00
+++ 1.33/vio/viosocket.c	2005-07-27 17:41:29 +05:00
@@ -35,12 +35,7 @@
   DBUG_ENTER("vio_read");
   DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
 
-#ifdef __WIN__
-  r = recv(vio->sd, buf, size,0);
-#else
-  errno=0;					/* For linux */
-  r = read(vio->sd, buf, size);
-#endif /* __WIN__ */
+  r= recv(vio->sd, buf, size, 0);
 #ifndef DBUG_OFF
   if (r < 0)
   {
@@ -57,11 +52,8 @@
   int r;
   DBUG_ENTER("vio_write");
   DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
-#ifdef __WIN__
-  r = send(vio->sd, buf, size,0);
-#else
-  r = write(vio->sd, buf, size);
-#endif /* __WIN__ */
+
+  r= send(vio->sd, buf, size, 0);
 #ifndef DBUG_OFF
   if (r < 0)
   {
@@ -317,15 +309,20 @@
 }
 
 
-void vio_timeout(Vio *vio __attribute__((unused)),
-		 uint which __attribute__((unused)),
-                 uint timeout __attribute__((unused)))
+void vio_timeout(Vio *vio, uint which, uint milliseconds)
 {
+  int optname= which ? SO_SNDTIMEO : SO_RCVTIMEO;
 #ifdef __WIN__
-  ulong wait_timeout= (ulong) timeout * 1000;
-  (void) setsockopt(vio->sd, SOL_SOCKET, 
-	which ? SO_SNDTIMEO : SO_RCVTIMEO, (char*) &wait_timeout,
-        sizeof(wait_timeout));
+  ulong wait_timeout= (ulong) milliseconds;
+
+  setsockopt(vio->sd, SOL_SOCKET, optname, (char*) &wait_timeout,
+             sizeof(wait_timeout));
+#else
+  struct timeval tv;
+
+  tv.tv_sec = milliseconds / 1000;
+  tv.tv_usec = milliseconds % 1000 * 1000;
+  setsockopt(vio->sd, SOL_SOCKET, optname, &tv, sizeof(tv));
 #endif /* __WIN__ */
 }
 
Thread
bk commit into 4.1 tree (ramil:1.2347) BUG#5449ramil27 Jul