Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
fdf4a5b7
Commit
fdf4a5b7
authored
Aug 11, 2018
by
Vladislav Vaintroub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-16277 tcp_nodelay session variable to enable / disable Nagle algorithm
parent
7a022d70
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
21 deletions
+66
-21
include/violite.h
include/violite.h
+1
-0
sql/sql_class.h
sql/sql_class.h
+1
-0
sql/sys_vars.cc
sql/sys_vars.cc
+36
-8
vio/viosocket.c
vio/viosocket.c
+28
-13
No files found.
include/violite.h
View file @
fdf4a5b7
...
@@ -89,6 +89,7 @@ size_t vio_write(Vio *vio, const uchar * buf, size_t size);
...
@@ -89,6 +89,7 @@ size_t vio_write(Vio *vio, const uchar * buf, size_t size);
int
vio_blocking
(
Vio
*
vio
,
my_bool
onoff
,
my_bool
*
old_mode
);
int
vio_blocking
(
Vio
*
vio
,
my_bool
onoff
,
my_bool
*
old_mode
);
my_bool
vio_is_blocking
(
Vio
*
vio
);
my_bool
vio_is_blocking
(
Vio
*
vio
);
/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible */
/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible */
int
vio_nodelay
(
Vio
*
vio
,
my_bool
on
);
int
vio_fastsend
(
Vio
*
vio
);
int
vio_fastsend
(
Vio
*
vio
);
/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible */
/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible */
int
vio_keepalive
(
Vio
*
vio
,
my_bool
onoff
);
int
vio_keepalive
(
Vio
*
vio
,
my_bool
onoff
);
...
...
sql/sql_class.h
View file @
fdf4a5b7
...
@@ -717,6 +717,7 @@ typedef struct system_variables
...
@@ -717,6 +717,7 @@ typedef struct system_variables
ulong
session_track_transaction_info
;
ulong
session_track_transaction_info
;
my_bool
session_track_schema
;
my_bool
session_track_schema
;
my_bool
session_track_state_change
;
my_bool
session_track_state_change
;
my_bool
tcp_nodelay
;
ulong
threadpool_priority
;
ulong
threadpool_priority
;
...
...
sql/sys_vars.cc
View file @
fdf4a5b7
...
@@ -4039,6 +4039,16 @@ static bool fix_sql_log_bin_after_update(sys_var *self, THD *thd,
...
@@ -4039,6 +4039,16 @@ static bool fix_sql_log_bin_after_update(sys_var *self, THD *thd,
return
FALSE
;
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,
This function checks if the sql_log_bin can be changed,
what is possible if:
what is possible if:
...
@@ -4054,20 +4064,17 @@ static bool fix_sql_log_bin_after_update(sys_var *self, THD *thd,
...
@@ -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
)
static
bool
check_sql_log_bin
(
sys_var
*
self
,
THD
*
thd
,
set_var
*
var
)
{
{
if
(
check_has_super
(
self
,
thd
,
var
))
if
(
check_has_super
(
self
,
thd
,
var
))
return
TRUE
;
return
true
;
if
(
unlikely
(
var
->
type
==
OPT_GLOBAL
))
if
(
check_session_only_variable
(
self
,
thd
,
var
))
{
return
true
;
my_error
(
ER_INCORRECT_GLOBAL_LOCAL_VAR
,
MYF
(
0
),
self
->
name
.
str
,
"SESSION"
);
return
TRUE
;
}
if
(
unlikely
(
error_if_in_trans_or_substatement
(
thd
,
if
(
unlikely
(
error_if_in_trans_or_substatement
(
thd
,
ER_STORED_FUNCTION_PREVENTS_SWITCH_SQL_LOG_BIN
,
ER_STORED_FUNCTION_PREVENTS_SWITCH_SQL_LOG_BIN
,
ER_INSIDE_TRANSACTION_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
(
static
Sys_var_mybool
Sys_log_binlog
(
...
@@ -5579,6 +5586,27 @@ static Sys_var_int Sys_keepalive_probes(
...
@@ -5579,6 +5586,27 @@ static Sys_var_int Sys_keepalive_probes(
BLOCK_SIZE
(
1
),
BLOCK_SIZE
(
1
),
NO_MUTEX_GUARD
,
NOT_IN_BINLOG
,
ON_CHECK
(
NULL
));
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
(
static
Sys_var_charptr
Sys_ignore_db_dirs
(
"ignore_db_dirs"
,
"ignore_db_dirs"
,
"Specifies a directory to add to the ignore list when collecting "
"Specifies a directory to add to the ignore list when collecting "
...
...
vio/viosocket.c
View file @
fdf4a5b7
...
@@ -435,8 +435,34 @@ int vio_socket_timeout(Vio *vio,
...
@@ -435,8 +435,34 @@ int vio_socket_timeout(Vio *vio,
DBUG_RETURN
(
ret
);
DBUG_RETURN
(
ret
);
}
}
/* Set TCP_NODELAY (disable Nagle's algorithm */
int
vio_nodelay
(
Vio
*
vio
,
my_bool
on
)
{
int
r
;
int
no_delay
=
MY_TEST
(
on
);
DBUG_ENTER
(
"vio_nodelay"
);
if
(
vio
->
type
==
VIO_TYPE_NAMEDPIPE
||
vio
->
type
==
VIO_TYPE_SHARED_MEMORY
)
{
DBUG_RETURN
(
0
);
}
r
=
mysql_socket_setsockopt
(
vio
->
mysql_socket
,
IPPROTO_TCP
,
TCP_NODELAY
,
IF_WIN
((
const
char
*
),
(
void
*
))
&
no_delay
,
sizeof
(
no_delay
));
if
(
r
)
{
DBUG_PRINT
(
"warning"
,
(
"Couldn't set socket option for fast send, error %d"
,
socket_errno
));
r
=
-
1
;
}
DBUG_PRINT
(
"exit"
,
(
"%d"
,
r
));
DBUG_RETURN
(
r
);
}
int
vio_fastsend
(
Vio
*
vio
__attribute__
((
unused
))
)
int
vio_fastsend
(
Vio
*
vio
)
{
{
int
r
=
0
;
int
r
=
0
;
DBUG_ENTER
(
"vio_fastsend"
);
DBUG_ENTER
(
"vio_fastsend"
);
...
@@ -454,18 +480,7 @@ int vio_fastsend(Vio * vio __attribute__((unused)))
...
@@ -454,18 +480,7 @@ int vio_fastsend(Vio * vio __attribute__((unused)))
}
}
#endif
/* IPTOS_THROUGHPUT */
#endif
/* IPTOS_THROUGHPUT */
if
(
!
r
)
if
(
!
r
)
{
r
=
vio_nodelay
(
vio
,
TRUE
);
#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
));
}
if
(
r
)
if
(
r
)
{
{
DBUG_PRINT
(
"warning"
,
DBUG_PRINT
(
"warning"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment