diff options
-rw-r--r-- | sql/sql_parse.cc | 3 | ||||
-rw-r--r-- | sql/sys_vars.cc | 21 | ||||
-rw-r--r-- | vio/viosocket.c | 22 |
3 files changed, 23 insertions, 23 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 05f3c85e9be..4bd346a6d63 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1638,8 +1638,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, } if (thd->variables.batch_mode && - !thd->killed && !thd->is_error() && - vio_io_wait(thd->net.vio, VIO_IO_EVENT_READ, 0) > 0) + !thd->killed && !thd->is_error()) { /* More commands follow, skip flush */ thd->get_stmt_da()->set_skip_flush(); diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 913e1c8bdc7..d3a1fd7d68c 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -5236,29 +5236,28 @@ static Sys_var_mybool Sys_query_cache_strip_comments( DEFAULT(FALSE)); +extern "C" int vio_set_nodelay(Vio *vio, int nodelay); static bool fix_batch_mode(sys_var *self, THD *thd, enum_var_type type) { +#ifndef EMBEDDED_SERVER if (type == OPT_SESSION) { - my_bool set_batch_mode= thd->variables.batch_mode; - if (set_batch_mode) + int err = vio_set_nodelay(thd->net.vio, thd->variables.batch_mode ? 0:1); + if (err) { - my_bool has_more_data - = (my_bool) vio_io_wait(thd->net.vio, VIO_IO_EVENT_READ, 0) > 0; - thd->get_stmt_da()->set_skip_flush(has_more_data); - } - else - { - thd->get_stmt_da()->set_skip_flush(FALSE); + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, + "Could not %s Nagle's algorithm, socket error %d", + thd->variables.batch_mode?"enable":"disable", socket_errno); } } +#endif return false; } static Sys_var_mybool Sys_batch_mode( "batch_mode", - "Client sends multiple queries without waiting for response", - SESSION_VAR(batch_mode), CMD_LINE(OPT_ARG), + "Improve the efficiency of TCP/IP networks by reducing the number of packets that need to be sent over the network via Nagle's algoritm", + SESSION_ONLY(batch_mode), CMD_LINE(OPT_ARG), DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_batch_mode)); diff --git a/vio/viosocket.c b/vio/viosocket.c index a33de48c020..07848a66ec7 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -448,6 +448,17 @@ int vio_socket_timeout(Vio *vio, DBUG_RETURN(ret); } +int vio_set_nodelay(Vio * vio, int nodelay) +{ + if (vio->type == VIO_TYPE_NAMEDPIPE || vio->type == VIO_TYPE_SHARED_MEMORY) + { + return; + } + return mysql_socket_setsockopt(vio->mysql_socket, IPPROTO_TCP, TCP_NODELAY, + IF_WIN((const char*), (void*)) &nodelay, + sizeof(nodelay)); +} + int vio_fastsend(Vio * vio __attribute__((unused))) { @@ -468,16 +479,7 @@ int vio_fastsend(Vio * vio __attribute__((unused))) #endif /* IPTOS_THROUGHPUT */ if (!r) { -#ifdef __WIN__ - BOOL nodelay= 1; -#else - int nodelay = 1; -#endif - - r= mysql_socket_setsockopt(vio->mysql_socket, IPPROTO_TCP, TCP_NODELAY, - IF_WIN((const char*), (void*)) &nodelay, - sizeof(nodelay)); - + r= vio_set_nodelay(vio, 1); } if (r) { |