diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2018-08-11 22:54:14 +0100 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2018-08-11 22:54:14 +0100 |
commit | fdf4a5b7bc044ea6d26d8cb1e6835fada53c5f34 (patch) | |
tree | 77f24d9b067c78013034bdc7c95a5f13bdb86243 /sql/sys_vars.cc | |
parent | 7a022d706155cb2ac00936d6829883b40af7f147 (diff) | |
download | mariadb-git-fdf4a5b7bc044ea6d26d8cb1e6835fada53c5f34.tar.gz |
MDEV-16277 tcp_nodelay session variable to enable / disable Nagle algorithm
Diffstat (limited to 'sql/sys_vars.cc')
-rw-r--r-- | sql/sys_vars.cc | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 3ac84fb61cc..75a962939ae 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4039,6 +4039,16 @@ static bool fix_sql_log_bin_after_update(sys_var *self, THD *thd, return FALSE; } +static bool check_session_only_variable(sys_var *self, THD *,set_var *var) +{ + if (unlikely(var->type == OPT_GLOBAL)) + { + my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), self->name.str, "SESSION"); + return true; + } + return false; +} + /** This function checks if the sql_log_bin can be changed, what is possible if: @@ -4054,20 +4064,17 @@ static bool fix_sql_log_bin_after_update(sys_var *self, THD *thd, static bool check_sql_log_bin(sys_var *self, THD *thd, set_var *var) { if (check_has_super(self, thd, var)) - return TRUE; + return true; - if (unlikely(var->type == OPT_GLOBAL)) - { - my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), self->name.str, "SESSION"); - return TRUE; - } + if (check_session_only_variable(self, thd, var)) + return true; if (unlikely(error_if_in_trans_or_substatement(thd, ER_STORED_FUNCTION_PREVENTS_SWITCH_SQL_LOG_BIN, ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SQL_LOG_BIN))) - return TRUE; + return true; - return FALSE; + return false; } static Sys_var_mybool Sys_log_binlog( @@ -5579,6 +5586,27 @@ static Sys_var_int Sys_keepalive_probes( BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL)); + +static bool update_tcp_nodelay(sys_var *self, THD *thd, + enum_var_type type) +{ + DBUG_ASSERT(thd); + + Vio *vio = thd->net.vio; + if (vio) + return (MY_TEST(vio_nodelay(vio, thd->variables.tcp_nodelay))); + + return false; +} + +static Sys_var_mybool Sys_tcp_nodelay( + "tcp_nodelay", + "Set option TCP_NODELAY (disable Nagle's algorithm) on socket", + SESSION_VAR(tcp_nodelay), CMD_LINE(OPT_ARG), + DEFAULT(TRUE),NO_MUTEX_GUARD, NOT_IN_BINLOG, + ON_CHECK(check_session_only_variable), + ON_UPDATE(update_tcp_nodelay)); + static Sys_var_charptr Sys_ignore_db_dirs( "ignore_db_dirs", "Specifies a directory to add to the ignore list when collecting " |