Skip to content

Commit d394d66

Browse files
author
mtaylor@qualinost.(none)
committed
Merge bk-internal.mysql.com:/home/bk/mysql-5.0-maint
into qualinost.(none):/home/mtaylor/src/mysql-5.0-maint
2 parents f8f11eb + 07df8fd commit d394d66

File tree

10 files changed

+84
-32
lines changed

10 files changed

+84
-32
lines changed

cmd-line-utils/readline/display.c

+12
Original file line numberDiff line numberDiff line change
@@ -524,14 +524,26 @@ rl_redisplay ()
524524
wrap_offset = prompt_invis_chars_first_line = 0;
525525
}
526526

527+
#if defined (HANDLE_MULTIBYTE)
527528
#define CHECK_INV_LBREAKS() \
528529
do { \
529530
if (newlines >= (inv_lbsize - 2)) \
530531
{ \
531532
inv_lbsize *= 2; \
532533
inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
534+
_rl_wrapped_line = (int *)xrealloc (_rl_wrapped_line, inv_lbsize * sizeof (int)); \
533535
} \
534536
} while (0)
537+
#else
538+
#define CHECK_INV_LBREAKS() \
539+
do { \
540+
if (newlines >= (inv_lbsize - 2)) \
541+
{ \
542+
inv_lbsize *= 2; \
543+
inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
544+
} \
545+
} while (0)
546+
#endif
535547

536548
#if defined (HANDLE_MULTIBYTE)
537549
#define CHECK_LPOS() \

sql-common/client.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -2044,11 +2044,17 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
20442044
goto error;
20452045
}
20462046
vio_keepalive(net->vio,TRUE);
2047-
/* Override local client variables */
2047+
2048+
/* If user set read_timeout, let it override the default */
20482049
if (mysql->options.read_timeout)
20492050
net->read_timeout= mysql->options.read_timeout;
2051+
vio_timeout(net->vio, 0, net->read_timeout);
2052+
2053+
/* If user set write_timeout, let it override the default */
20502054
if (mysql->options.write_timeout)
20512055
net->write_timeout= mysql->options.write_timeout;
2056+
vio_timeout(net->vio, 1, net->write_timeout);
2057+
20522058
if (mysql->options.max_allowed_packet)
20532059
net->max_packet_size= mysql->options.max_allowed_packet;
20542060

sql/mysql_priv.h

+3
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ void kill_one_thread(THD *thd, ulong id, bool only_kill_query);
8989
bool net_request_file(NET* net, const char* fname);
9090
char* query_table_status(THD *thd,const char *db,const char *table_name);
9191

92+
void net_set_write_timeout(NET *net, uint timeout);
93+
void net_set_read_timeout(NET *net, uint timeout);
94+
9295
#define x_free(A) { my_free((gptr) (A),MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); }
9396
#define safeFree(x) { if(x) { my_free((gptr) x,MYF(0)); x = NULL; } }
9497
#define PREV_BITS(type,A) ((type) (((type) 1 << (A)) -1))

sql/mysqld.cc

+2-8
Original file line numberDiff line numberDiff line change
@@ -3886,10 +3886,9 @@ static bool read_init_file(char *file_name)
38863886

38873887
static void create_new_thread(THD *thd)
38883888
{
3889+
NET *net=&thd->net;
38893890
DBUG_ENTER("create_new_thread");
38903891

3891-
NET *net=&thd->net; // For easy ref
3892-
net->read_timeout = (uint) connect_timeout;
38933892
if (protocol_version > 9)
38943893
net->return_errno=1;
38953894

@@ -4183,12 +4182,7 @@ pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused)))
41834182
}
41844183
if (sock == unix_sock)
41854184
thd->security_ctx->host=(char*) my_localhost;
4186-
#ifdef __WIN__
4187-
/* Set default wait_timeout */
4188-
ulong wait_timeout= global_system_variables.net_wait_timeout * 1000;
4189-
(void) setsockopt(new_sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&wait_timeout,
4190-
sizeof(wait_timeout));
4191-
#endif
4185+
41924186
create_new_thread(thd);
41934187
}
41944188

sql/net_serv.cc

+25-2
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ net_real_write(NET *net,const char *packet,ulong len)
606606
thr_alarm(&alarmed,(uint) net->write_timeout,&alarm_buff);
607607
#else
608608
alarmed=0;
609-
vio_timeout(net->vio, 1, net->write_timeout);
609+
/* Write timeout is set in net_set_write_timeout */
610610
#endif /* NO_ALARM */
611611

612612
pos=(char*) packet; end=pos+len;
@@ -799,7 +799,7 @@ my_real_read(NET *net, ulong *complen)
799799
if (net_blocking)
800800
thr_alarm(&alarmed,net->read_timeout,&alarm_buff);
801801
#else
802-
vio_timeout(net->vio, 0, net->read_timeout);
802+
/* Read timeout is set in net_set_read_timeout */
803803
#endif /* NO_ALARM */
804804

805805
pos = net->buff + net->where_b; /* net->packet -4 */
@@ -1110,3 +1110,26 @@ my_net_read(NET *net)
11101110
return len;
11111111
}
11121112

1113+
1114+
void net_set_read_timeout(NET *net, uint timeout)
1115+
{
1116+
DBUG_ENTER("net_set_read_timeout");
1117+
DBUG_PRINT("enter", ("timeout: %d", timeout));
1118+
net->read_timeout= timeout;
1119+
#ifdef NO_ALARM
1120+
vio_timeout(net->vio, 0, timeout);
1121+
#endif
1122+
DBUG_VOID_RETURN;
1123+
}
1124+
1125+
1126+
void net_set_write_timeout(NET *net, uint timeout)
1127+
{
1128+
DBUG_ENTER("net_set_write_timeout");
1129+
DBUG_PRINT("enter", ("timeout: %d", timeout));
1130+
net->write_timeout= timeout;
1131+
#ifdef NO_ALARM
1132+
vio_timeout(net->vio, 1, timeout);
1133+
#endif
1134+
DBUG_VOID_RETURN;
1135+
}

sql/repl_failsafe.cc

+6-3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static Slave_log_event* find_slave_event(IO_CACHE* log,
5656
functions like register_slave()) are working.
5757
*/
5858

59+
#if NOT_USED
5960
static int init_failsafe_rpl_thread(THD* thd)
6061
{
6162
DBUG_ENTER("init_failsafe_rpl_thread");
@@ -96,7 +97,7 @@ static int init_failsafe_rpl_thread(THD* thd)
9697
thd->set_time();
9798
DBUG_RETURN(0);
9899
}
99-
100+
#endif
100101

101102
void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status)
102103
{
@@ -570,12 +571,14 @@ HOSTS";
570571
}
571572

572573

574+
#if NOT_USED
573575
int find_recovery_captain(THD* thd, MYSQL* mysql)
574576
{
575577
return 0;
576578
}
579+
#endif
577580

578-
581+
#if NOT_USED
579582
pthread_handler_t handle_failsafe_rpl(void *arg)
580583
{
581584
DBUG_ENTER("handle_failsafe_rpl");
@@ -623,7 +626,7 @@ pthread_handler_t handle_failsafe_rpl(void *arg)
623626
pthread_exit(0);
624627
DBUG_RETURN(0);
625628
}
626-
629+
#endif
627630

628631
bool show_slave_hosts(THD* thd)
629632
{

sql/set_var.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1273,14 +1273,14 @@ static int check_completion_type(THD *thd, set_var *var)
12731273
static void fix_net_read_timeout(THD *thd, enum_var_type type)
12741274
{
12751275
if (type != OPT_GLOBAL)
1276-
thd->net.read_timeout=thd->variables.net_read_timeout;
1276+
net_set_read_timeout(&thd->net, thd->variables.net_read_timeout);
12771277
}
12781278

12791279

12801280
static void fix_net_write_timeout(THD *thd, enum_var_type type)
12811281
{
12821282
if (type != OPT_GLOBAL)
1283-
thd->net.write_timeout=thd->variables.net_write_timeout;
1283+
net_set_write_timeout(&thd->net, thd->variables.net_write_timeout);
12841284
}
12851285

12861286
static void fix_net_retry_count(THD *thd, enum_var_type type)

sql/slave.cc

-1
Original file line numberDiff line numberDiff line change
@@ -2901,7 +2901,6 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type)
29012901
*/
29022902
thd->variables.max_allowed_packet= global_system_variables.max_allowed_packet
29032903
+ MAX_LOG_EVENT_HEADER; /* note, incr over the global not session var */
2904-
thd->net.read_timeout = slave_net_timeout;
29052904
thd->slave_thread = 1;
29062905
set_slave_thread_options(thd);
29072906
thd->client_capabilities = CLIENT_LOCAL_FILES;

sql/sql_parse.cc

+24-12
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ static int check_connection(THD *thd)
965965
return(ER_HANDSHAKE_ERROR);
966966
}
967967
DBUG_PRINT("info", ("IO layer change in progress..."));
968-
if (sslaccept(ssl_acceptor_fd, net->vio, thd->variables.net_wait_timeout))
968+
if (sslaccept(ssl_acceptor_fd, net->vio, net->read_timeout))
969969
{
970970
DBUG_PRINT("error", ("Failed to accept new SSL connection"));
971971
inc_host_errors(&thd->remote.sin_addr);
@@ -994,7 +994,6 @@ static int check_connection(THD *thd)
994994
if ((thd->client_capabilities & CLIENT_TRANSACTIONS) &&
995995
opt_using_transactions)
996996
net->return_status= &thd->server_status;
997-
net->read_timeout=(uint) thd->variables.net_read_timeout;
998997

999998
char *user= end;
1000999
char *passwd= strend(user)+1;
@@ -1138,6 +1137,10 @@ pthread_handler_t handle_one_connection(void *arg)
11381137
Security_context *sctx= thd->security_ctx;
11391138
net->no_send_error= 0;
11401139

1140+
/* Use "connect_timeout" value during connection phase */
1141+
net_set_read_timeout(net, connect_timeout);
1142+
net_set_write_timeout(net, connect_timeout);
1143+
11411144
if ((error=check_connection(thd)))
11421145
{ // Wrong permissions
11431146
if (error > 0)
@@ -1180,6 +1183,10 @@ pthread_handler_t handle_one_connection(void *arg)
11801183
thd->init_for_queries();
11811184
}
11821185

1186+
/* Connect completed, set read/write timeouts back to tdefault */
1187+
net_set_read_timeout(net, thd->variables.net_read_timeout);
1188+
net_set_write_timeout(net, thd->variables.net_write_timeout);
1189+
11831190
while (!net->error && net->vio != 0 &&
11841191
!(thd->killed == THD::KILL_CONNECTION))
11851192
{
@@ -1486,7 +1493,7 @@ int end_trans(THD *thd, enum enum_mysql_completiontype completion)
14861493
#ifndef EMBEDDED_LIBRARY
14871494

14881495
/*
1489-
Read one command from socket and execute it (query or simple command).
1496+
Read one command from connection and execute it (query or simple command).
14901497
This function is called in loop from thread function.
14911498
SYNOPSIS
14921499
do_command()
@@ -1497,24 +1504,26 @@ int end_trans(THD *thd, enum enum_mysql_completiontype completion)
14971504

14981505
bool do_command(THD *thd)
14991506
{
1500-
char *packet;
1501-
uint old_timeout;
1507+
char *packet= 0;
15021508
ulong packet_length;
1503-
NET *net;
1509+
NET *net= &thd->net;
15041510
enum enum_server_command command;
15051511
DBUG_ENTER("do_command");
15061512

1507-
net= &thd->net;
15081513
/*
15091514
indicator of uninitialized lex => normal flow of errors handling
15101515
(see my_message_sql)
15111516
*/
15121517
thd->lex->current_select= 0;
15131518

1514-
packet=0;
1515-
old_timeout=net->read_timeout;
1516-
/* Wait max for 8 hours */
1517-
net->read_timeout=(uint) thd->variables.net_wait_timeout;
1519+
/*
1520+
This thread will do a blocking read from the client which
1521+
will be interrupted when the next command is received from
1522+
the client, the connection is closed or "net_wait_timeout"
1523+
number of seconds has passed
1524+
*/
1525+
net_set_read_timeout(net, thd->variables.net_wait_timeout);
1526+
15181527
thd->clear_error(); // Clear error message
15191528

15201529
net_new_transaction(net);
@@ -1543,7 +1552,10 @@ bool do_command(THD *thd)
15431552
vio_description(net->vio), command,
15441553
command_name[command]));
15451554
}
1546-
net->read_timeout=old_timeout; // restore it
1555+
1556+
/* Restore read timeout value */
1557+
net_set_read_timeout(net, thd->variables.net_read_timeout);
1558+
15471559
/*
15481560
packet_length contains length of data, as it was stored in packet
15491561
header. In case of malformed header, packet_length can be zero.

sql/sql_repl.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ static int send_file(THD *thd)
9191
The client might be slow loading the data, give him wait_timeout to do
9292
the job
9393
*/
94-
old_timeout = thd->net.read_timeout;
95-
thd->net.read_timeout = thd->variables.net_wait_timeout;
94+
old_timeout= net->read_timeout;
95+
net_set_read_timeout(net, thd->variables.net_wait_timeout);
9696

9797
/*
9898
We need net_flush here because the client will not know it needs to send
@@ -136,7 +136,7 @@ static int send_file(THD *thd)
136136
error = 0;
137137

138138
err:
139-
thd->net.read_timeout = old_timeout;
139+
net_set_read_timeout(net, old_timeout);
140140
if (fd >= 0)
141141
(void) my_close(fd, MYF(0));
142142
if (errmsg)

0 commit comments

Comments
 (0)