MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:msvensson Date:January 29 2007 1:31pm
Subject:bk commit into 4.1 tree (msvensson:1.2599) BUG#22943
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of msvensson. When msvensson 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@stripped, 2007-01-29 14:31:48+01:00, msvensson@stripped +11 -0
  Bug#22943 syscall pruning in libmysql
   - Set the timeout values only where needed

  sql-common/client.c@stripped, 2007-01-29 14:31:47+01:00, msvensson@stripped +7 -1
    Call 'vio_timeout' to set up the read and write timeout's for the
    newly created connection. It only need to be done once at connect time. 

  sql/mysql_priv.h@stripped, 2007-01-29 14:31:45+01:00, msvensson@stripped +2 -0
    Add new functions for setting read and write timeout on "net"

  sql/mysqld.cc@stripped, 2007-01-29 14:31:45+01:00, msvensson@stripped +2 -8
    - Move the setting of "read_timeout" to the value of "connect_timeout" to
      just before 'check_connection' which is the function where we want
      to use the different timeout
    - With the new functions to set timeout on "net", there is no need to
      specifically set the default wait_timeout on windows.

  sql/net_serv.cc@stripped, 2007-01-29 14:31:45+01:00, msvensson@stripped +25 -2
    Add new functions for setting read and write timeout of "net, when
    server is compiled not to use alarms it will set the write/read timeout
    directly on connection using 'vio_timeout'(using setsockopt if socket)

  sql/repl_failsafe.cc@stripped, 2007-01-29 14:31:46+01:00, msvensson@stripped +6 -3
    Put unused code within "#if NOT_USED"

  sql/set_var.cc@stripped, 2007-01-29 14:31:46+01:00, msvensson@stripped +2 -2
    Use 'net_set_*_timeout' when adjusting timeout value
    on the current connection

  sql/slave.cc@stripped, 2007-01-29 14:31:46+01:00, msvensson@stripped +0 -1
    The read timeout used when connecting to master server is set
    using 'mysql_options' in 'connect_to_master' function

  sql/sql_parse.cc@stripped, 2007-01-29 14:31:46+01:00, msvensson@stripped +25 -12
    - Set read and write timeout values to "connect_timeout" during
    connect phase
    - Use "read_timeout" value during sslaccept phase, since this is during
    connect phase it implies "connect-timeout"
    - Set read and write timeout value back to default after connect phase
    - Set "read_timeout" to "wait_timeout" while waiting for client.

  sql/sql_repl.cc@stripped, 2007-01-29 14:31:46+01:00, msvensson@stripped +3 -3
    Set "read_timeout" to "wait_timeout" while ask other mysqld to send file

  vio/vio.c@stripped, 2007-01-29 14:31:47+01:00, msvensson@stripped +1 -1
    Use 'vio_timeout' for setting timeout also on an SSL connection
    since they both use sockets

  vio/viossl.c@stripped, 2007-01-29 14:31:47+01:00, msvensson@stripped +0 -11
    Remove 'vio_ssl_timeout' function

# 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:	msvensson
# Host:	pilot.mysql.com
# Root:	/home/msvensson/mysql/bug22943/my41-bug22943

--- 1.385/sql/mysql_priv.h	2007-01-10 09:57:02 +01:00
+++ 1.386/sql/mysql_priv.h	2007-01-29 14:31:45 +01:00
@@ -59,6 +59,8 @@
 bool net_request_file(NET* net, const char* fname);
 char* query_table_status(THD *thd,const char *db,const char *table_name);
 
+void net_set_write_timeout(NET *net, uint timeout);
+void net_set_read_timeout(NET *net, uint timeout);
 
 #define x_free(A)	{ my_free((gptr) (A),MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); }
 #define safeFree(x)	{ if(x) { my_free((gptr) x,MYF(0)); x = NULL; } }

--- 1.622/sql/mysqld.cc	2007-01-10 09:57:02 +01:00
+++ 1.623/sql/mysqld.cc	2007-01-29 14:31:45 +01:00
@@ -3601,10 +3601,9 @@
 #ifndef EMBEDDED_LIBRARY
 static void create_new_thread(THD *thd)
 {
+  NET *net=&thd->net;
   DBUG_ENTER("create_new_thread");
 
-  NET *net=&thd->net;				// For easy ref
-  net->read_timeout = (uint) connect_timeout;
   if (protocol_version > 9)
     net->return_errno=1;
 
@@ -3899,12 +3898,7 @@
     }
     if (sock == unix_sock)
       thd->host=(char*) my_localhost;
-#ifdef __WIN__
-    /* Set default wait_timeout */
-    ulong wait_timeout= global_system_variables.net_wait_timeout * 1000;
-    (void) setsockopt(new_sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&wait_timeout,
-                    sizeof(wait_timeout));
-#endif
+
     create_new_thread(thd);
   }
 

--- 1.77/sql/net_serv.cc	2006-10-13 12:26:14 +02:00
+++ 1.78/sql/net_serv.cc	2007-01-29 14:31:45 +01:00
@@ -491,7 +491,7 @@
     thr_alarm(&alarmed,(uint) net->write_timeout,&alarm_buff);
 #else
   alarmed=0;
-  vio_timeout(net->vio, 1, net->write_timeout);
+  /* Write timeout is set in net_set_write_timeout */
 #endif /* NO_ALARM */
 
   pos=(char*) packet; end=pos+len;
@@ -684,7 +684,7 @@
   if (net_blocking)
     thr_alarm(&alarmed,net->read_timeout,&alarm_buff);
 #else
-  vio_timeout(net->vio, 0, net->read_timeout);
+  /* Read timeout is set in net_set_read_timeout */
 #endif /* NO_ALARM */
 
     pos = net->buff + net->where_b;		/* net->packet -4 */
@@ -995,3 +995,26 @@
   return len;
 }
 
+
+void net_set_read_timeout(NET *net, uint timeout)
+{
+  DBUG_ENTER("net_set_read_timeout");
+  DBUG_PRINT("enter", ("timeout: %d", timeout));
+  net->read_timeout= timeout;
+#ifdef NO_ALARM
+  vio_timeout(net->vio, 0, timeout);
+#endif
+  DBUG_VOID_RETURN;
+}
+
+
+void net_set_write_timeout(NET *net, uint timeout)
+{
+  DBUG_ENTER("net_set_write_timeout");
+  DBUG_PRINT("enter", ("timeout: %d", timeout));
+  net->write_timeout= timeout;
+#ifdef NO_ALARM
+  vio_timeout(net->vio, 1, timeout);
+#endif
+  DBUG_VOID_RETURN;
+}

--- 1.284/sql/slave.cc	2006-11-12 19:01:56 +01:00
+++ 1.285/sql/slave.cc	2007-01-29 14:31:46 +01:00
@@ -2625,7 +2625,6 @@
 */
   thd->variables.max_allowed_packet= global_system_variables.max_allowed_packet
     + MAX_LOG_EVENT_HEADER;  /* note, incr over the global not session var */
-  thd->net.read_timeout = slave_net_timeout;
   thd->master_access= ~(ulong)0;
   thd->priv_user = 0;
   thd->slave_thread = 1;

--- 1.491/sql/sql_parse.cc	2007-01-17 11:13:01 +01:00
+++ 1.492/sql/sql_parse.cc	2007-01-29 14:31:46 +01:00
@@ -867,7 +867,7 @@
       return(ER_HANDSHAKE_ERROR);
     }
     DBUG_PRINT("info", ("IO layer change in progress..."));
-    if (sslaccept(ssl_acceptor_fd, net->vio, thd->variables.net_wait_timeout))
+    if (sslaccept(ssl_acceptor_fd, net->vio, net->read_timeout))
     {
       DBUG_PRINT("error", ("Failed to read user information (pkt_len= %lu)",
 			   pkt_len));
@@ -897,7 +897,6 @@
   if ((thd->client_capabilities & CLIENT_TRANSACTIONS) &&
       opt_using_transactions)
     net->return_status= &thd->server_status;
-  net->read_timeout=(uint) thd->variables.net_read_timeout;
 
   char *user= end;
   char *passwd= strend(user)+1;
@@ -1029,6 +1028,10 @@
     NET *net= &thd->net;
     thd->thread_stack= (char*) &thd;
 
+    /* Use "connect_timeout" value during connection phase */
+    net_set_read_timeout(net, connect_timeout);
+    net_set_write_timeout(net, connect_timeout);
+
     if ((error=check_connection(thd)))
     {						// Wrong permissions
       if (error > 0)
@@ -1058,6 +1061,11 @@
       if (thd->query_error)
 	thd->killed= 1;
     }
+
+    /* Connect completed, set read/write timeouts back to tdefault */
+    net_set_read_timeout(net, thd->variables.net_read_timeout);
+    net_set_write_timeout(net, thd->variables.net_write_timeout);
+
     while (!net->error && net->vio != 0 && !thd->killed)
     {
       if (do_command(thd))
@@ -1261,7 +1269,7 @@
 #ifndef EMBEDDED_LIBRARY
 
 /*
-  Read one command from socket and execute it (query or simple command).
+  Read one command from connection and execute it (query or simple command).
   This function is called in loop from thread function.
   SYNOPSIS
     do_command()
@@ -1272,24 +1280,26 @@
 
 bool do_command(THD *thd)
 {
-  char *packet;
-  uint old_timeout;
+  char *packet= 0;
   ulong packet_length;
-  NET *net;
+  NET *net= &thd->net;
   enum enum_server_command command;
   DBUG_ENTER("do_command");
 
-  net= &thd->net;
   /*
     indicator of uninitialized lex => normal flow of errors handling
     (see my_message_sql)
   */
   thd->lex->current_select= 0;
 
-  packet=0;
-  old_timeout=net->read_timeout;
-  // Wait max for 8 hours
-  net->read_timeout=(uint) thd->variables.net_wait_timeout;
+  /*
+    This thread will do a blocking read from the client which
+    will be interrupted when the next command is received from
+    the client, the connection is closed or "net_wait_timeout"
+    number of seconds has passed
+  */
+  net_set_read_timeout(net, thd->variables.net_wait_timeout);
+
   thd->clear_error();				// Clear error message
 
   net_new_transaction(net);
@@ -1318,7 +1328,10 @@
 		       vio_description(net->vio), command,
 		       command_name[command]));
   }
-  net->read_timeout=old_timeout;		// restore it
+
+  /* Restore read timeout value */
+  net_set_read_timeout(net, thd->variables.net_read_timeout);
+
   /*
     packet_length contains length of data, as it was stored in packet
     header. In case of malformed header, packet_length can be zero.

--- 1.95/sql-common/client.c	2006-11-16 17:11:19 +01:00
+++ 1.96/sql-common/client.c	2007-01-29 14:31:47 +01:00
@@ -1881,11 +1881,17 @@
     goto error;
   }
   vio_keepalive(net->vio,TRUE);
-  /* Override local client variables */
+
+  /* If user set read_timeout, let it override the default */
   if (mysql->options.read_timeout)
     net->read_timeout= mysql->options.read_timeout;
+  vio_timeout(net->vio, 0, net->read_timeout);
+
+  /* If user set write_timeout, let it override the default */
   if (mysql->options.write_timeout)
     net->write_timeout= mysql->options.write_timeout;
+  vio_timeout(net->vio, 1, net->write_timeout);
+
   if (mysql->options.max_allowed_packet)
     net->max_packet_size= mysql->options.max_allowed_packet;
 

--- 1.189/sql/set_var.cc	2006-11-21 14:49:16 +01:00
+++ 1.190/sql/set_var.cc	2007-01-29 14:31:46 +01:00
@@ -1128,14 +1128,14 @@
 static void fix_net_read_timeout(THD *thd, enum_var_type type)
 {
   if (type != OPT_GLOBAL)
-    thd->net.read_timeout=thd->variables.net_read_timeout;
+    net_set_read_timeout(&thd->net, thd->variables.net_read_timeout);
 }
 
 
 static void fix_net_write_timeout(THD *thd, enum_var_type type)
 {
   if (type != OPT_GLOBAL)
-    thd->net.write_timeout=thd->variables.net_write_timeout;
+    net_set_write_timeout(&thd->net, thd->variables.net_write_timeout);
 }
 
 static void fix_net_retry_count(THD *thd, enum_var_type type)

--- 1.62/sql/repl_failsafe.cc	2005-10-14 15:34:49 +02:00
+++ 1.63/sql/repl_failsafe.cc	2007-01-29 14:31:46 +01:00
@@ -57,6 +57,7 @@
   functions like register_slave()) are working.
 */
 
+#if NOT_USED
 static int init_failsafe_rpl_thread(THD* thd)
 {
   DBUG_ENTER("init_failsafe_rpl_thread");
@@ -99,7 +100,7 @@
   thd->set_time();
   DBUG_RETURN(0);
 }
-
+#endif
 
 void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status)
 {
@@ -573,12 +574,14 @@
 }
 
 
+#if NOT_USED
 int find_recovery_captain(THD* thd, MYSQL* mysql)
 {
   return 0;
 }
+#endif
 
-
+#if NOT_USED
 pthread_handler_decl(handle_failsafe_rpl,arg)
 {
   DBUG_ENTER("handle_failsafe_rpl");
@@ -626,7 +629,7 @@
   pthread_exit(0);
   DBUG_RETURN(0);
 }
-
+#endif
 
 int show_slave_hosts(THD* thd)
 {

--- 1.140/sql/sql_repl.cc	2006-11-12 19:01:56 +01:00
+++ 1.141/sql/sql_repl.cc	2007-01-29 14:31:46 +01:00
@@ -89,8 +89,8 @@
     The client might be slow loading the data, give him wait_timeout to do
     the job
   */
-  old_timeout = thd->net.read_timeout;
-  thd->net.read_timeout = thd->variables.net_wait_timeout;
+  old_timeout= net->read_timeout;
+  net_set_read_timeout(net, thd->variables.net_wait_timeout);
 
   /*
     We need net_flush here because the client will not know it needs to send
@@ -134,7 +134,7 @@
   error = 0;
 
  err:
-  thd->net.read_timeout = old_timeout;
+  net_set_read_timeout(net, old_timeout);
   if (fd >= 0)
     (void) my_close(fd, MYF(0));
   if (errmsg)

--- 1.25/vio/vio.c	2005-11-21 13:08:39 +01:00
+++ 1.26/vio/vio.c	2007-01-29 14:31:47 +01:00
@@ -96,7 +96,7 @@
     vio->in_addr	=vio_ssl_in_addr;
     vio->vioblocking	=vio_ssl_blocking;
     vio->is_blocking	=vio_is_blocking;
-    vio->timeout	=vio_ssl_timeout;
+    vio->timeout	=vio_timeout;
   }
   else					/* default is VIO_TYPE_TCPIP */
 #endif /* HAVE_OPENSSL */

--- 1.28/vio/viossl.c	2005-11-21 13:08:39 +01:00
+++ 1.29/vio/viossl.c	2007-01-29 14:31:47 +01:00
@@ -416,15 +416,4 @@
 }
 
 
-void vio_ssl_timeout(Vio *vio __attribute__((unused)),
-		     uint which __attribute__((unused)),
-                     uint timeout __attribute__((unused)))
-{
-#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));
-#endif /* __WIN__ */
-}
 #endif /* HAVE_OPENSSL */
Thread
bk commit into 4.1 tree (msvensson:1.2599) BUG#22943msvensson29 Jan