diff options
author | unknown <msvensson@pilot.mysql.com> | 2007-01-29 14:31:48 +0100 |
---|---|---|
committer | unknown <msvensson@pilot.mysql.com> | 2007-01-29 14:31:48 +0100 |
commit | a195ad5ea26227dac0d5f503b9e37717b2bc40be (patch) | |
tree | 439ceec10fe0ab45b030eb00f2e47e06330862a3 /sql/sql_parse.cc | |
parent | b95f107371606a6771e28447750372e172513d95 (diff) | |
download | mariadb-git-a195ad5ea26227dac0d5f503b9e37717b2bc40be.tar.gz |
Bug#22943 syscall pruning in libmysql
- Set the timeout values only where needed
sql/mysql_priv.h:
Add new functions for setting read and write timeout on "net"
sql/mysqld.cc:
- 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:
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:
Put unused code within "#if NOT_USED"
sql/set_var.cc:
Use 'net_set_*_timeout' when adjusting timeout value
on the current connection
sql/slave.cc:
The read timeout used when connecting to master server is set
using 'mysql_options' in 'connect_to_master' function
sql/sql_parse.cc:
- 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:
Set "read_timeout" to "wait_timeout" while ask other mysqld to send file
sql-common/client.c:
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.
vio/vio.c:
Use 'vio_timeout' for setting timeout also on an SSL connection
since they both use sockets
vio/viossl.c:
Remove 'vio_ssl_timeout' function
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 07064113209..808e08e4b21 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -867,7 +867,7 @@ static int check_connection(THD *thd) 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 @@ static int check_connection(THD *thd) 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 @@ pthread_handler_decl(handle_one_connection,arg) 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 @@ pthread_handler_decl(handle_one_connection,arg) 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 @@ err: #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 @@ err: 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 @@ bool do_command(THD *thd) 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. |