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
c334f4fe
Commit
c334f4fe
authored
Oct 17, 2016
by
vinchen
Committed by
Kristian Nielsen
Oct 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the code style for read_binlog_speed_limit
parent
ef77847c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
97 deletions
+66
-97
include/my_sys.h
include/my_sys.h
+0
-1
mysys/my_getsystime.c
mysys/my_getsystime.c
+0
-31
sql/net_serv.cc
sql/net_serv.cc
+57
-56
sql/slave.cc
sql/slave.cc
+9
-9
No files found.
include/my_sys.h
View file @
c334f4fe
...
...
@@ -939,7 +939,6 @@ void my_time_init(void);
extern
my_hrtime_t
my_hrtime
(
void
);
extern
ulonglong
my_interval_timer
(
void
);
extern
ulonglong
my_getcputime
(
void
);
extern
ulonglong
my_micro_time
();
#define microsecond_interval_timer() (my_interval_timer()/1000)
#define hrtime_to_time(X) ((X).val/HRTIME_RESOLUTION)
...
...
mysys/my_getsystime.c
View file @
c334f4fe
...
...
@@ -131,34 +131,3 @@ ulonglong my_getcputime()
#endif
/* CLOCK_THREAD_CPUTIME_ID */
return
0
;
}
/**
Return time in microseconds.
@remark This function is to be used to measure performance in
micro seconds. As it's not defined whats the start time
for the clock, this function us only useful to measure
time between two moments.
@retval Value in microseconds from some undefined point in time.
*/
ulonglong
my_micro_time
()
{
#ifdef _WIN32
ulonglong
newtime
;
GetSystemTimeAsFileTime
((
FILETIME
*
)
&
newtime
);
newtime
-=
OFFSET_TO_EPOC
;
return
(
newtime
/
10
);
#else
ulonglong
newtime
;
struct
timeval
t
;
/*
The following loop is here because gettimeofday may fail on some systems
*/
while
(
gettimeofday
(
&
t
,
NULL
)
!=
0
)
{}
newtime
=
(
ulonglong
)
t
.
tv_sec
*
1000000
+
t
.
tv_usec
;
return
newtime
;
#endif
}
sql/net_serv.cc
View file @
c334f4fe
...
...
@@ -1155,16 +1155,17 @@ my_net_read_packet(NET *net, my_bool read_from_server)
size_t
total_length
=
0
;
do
{
net
->
where_b
+=
len
;
total_length
+=
len
;
len
=
my_real_read
(
net
,
&
complen
,
0
);
net
->
where_b
+=
len
;
total_length
+=
len
;
len
=
my_real_read
(
net
,
&
complen
,
0
);
}
while
(
len
==
MAX_PACKET_LENGTH
);
if
(
len
!=
packet_error
)
len
+=
total_length
;
len
+=
total_length
;
net
->
where_b
=
save_pos
;
}
net
->
read_pos
=
net
->
buff
+
net
->
where_b
;
if
(
len
!=
packet_error
)
{
if
(
len
!=
packet_error
)
{
net
->
read_pos
[
len
]
=
0
;
/* Safeguard for mysql_use_result */
net
->
real_network_read_len
=
len
;
}
...
...
@@ -1185,7 +1186,7 @@ my_net_read_packet(NET *net, my_bool read_from_server)
{
buf_length
=
net
->
buf_length
;
/* Data left in old packet */
first_packet_offset
=
start_of_packet
=
(
net
->
buf_length
-
net
->
remain_in_buf
);
net
->
remain_in_buf
);
/* Restore the character that was overwritten by the end 0 */
net
->
buff
[
start_of_packet
]
=
net
->
save_char
;
}
...
...
@@ -1200,72 +1201,72 @@ my_net_read_packet(NET *net, my_bool read_from_server)
if
(
buf_length
-
start_of_packet
>=
NET_HEADER_SIZE
)
{
read_length
=
uint3korr
(
net
->
buff
+
start_of_packet
);
if
(
!
read_length
)
{
/* End of multi-byte packet */
start_of_packet
+=
NET_HEADER_SIZE
;
break
;
}
if
(
read_length
+
NET_HEADER_SIZE
<=
buf_length
-
start_of_packet
)
{
if
(
multi_byte_packet
)
{
/* Remove packet header for second packet */
memmove
(
net
->
buff
+
first_packet_offset
+
start_of_packet
,
net
->
buff
+
first_packet_offset
+
start_of_packet
+
NET_HEADER_SIZE
,
buf_length
-
start_of_packet
);
start_of_packet
+=
read_length
;
buf_length
-=
NET_HEADER_SIZE
;
}
else
start_of_packet
+=
read_length
+
NET_HEADER_SIZE
;
read_length
=
uint3korr
(
net
->
buff
+
start_of_packet
);
if
(
!
read_length
)
{
/* End of multi-byte packet */
start_of_packet
+=
NET_HEADER_SIZE
;
break
;
}
if
(
read_length
+
NET_HEADER_SIZE
<=
buf_length
-
start_of_packet
)
{
if
(
multi_byte_packet
)
{
/* Remove packet header for second packet */
memmove
(
net
->
buff
+
first_packet_offset
+
start_of_packet
,
net
->
buff
+
first_packet_offset
+
start_of_packet
+
NET_HEADER_SIZE
,
buf_length
-
start_of_packet
);
start_of_packet
+=
read_length
;
buf_length
-=
NET_HEADER_SIZE
;
}
else
start_of_packet
+=
read_length
+
NET_HEADER_SIZE
;
if
(
read_length
!=
MAX_PACKET_LENGTH
)
/* last package */
{
multi_byte_packet
=
0
;
/* No last zero len packet */
break
;
}
multi_byte_packet
=
NET_HEADER_SIZE
;
/* Move data down to read next data packet after current one */
if
(
first_packet_offset
)
{
memmove
(
net
->
buff
,
net
->
buff
+
first_packet_offset
,
buf_length
-
first_packet_offset
);
buf_length
-=
first_packet_offset
;
start_of_packet
-=
first_packet_offset
;
first_packet_offset
=
0
;
}
continue
;
}
if
(
read_length
!=
MAX_PACKET_LENGTH
)
/* last package */
{
multi_byte_packet
=
0
;
/* No last zero len packet */
break
;
}
multi_byte_packet
=
NET_HEADER_SIZE
;
/* Move data down to read next data packet after current one */
if
(
first_packet_offset
)
{
memmove
(
net
->
buff
,
net
->
buff
+
first_packet_offset
,
buf_length
-
first_packet_offset
);
buf_length
-=
first_packet_offset
;
start_of_packet
-=
first_packet_offset
;
first_packet_offset
=
0
;
}
continue
;
}
}
/* Move data down to read next data packet after current one */
if
(
first_packet_offset
)
{
memmove
(
net
->
buff
,
net
->
buff
+
first_packet_offset
,
buf_length
-
first_packet_offset
);
buf_length
-=
first_packet_offset
;
start_of_packet
-=
first_packet_offset
;
first_packet_offset
=
0
;
memmove
(
net
->
buff
,
net
->
buff
+
first_packet_offset
,
buf_length
-
first_packet_offset
);
buf_length
-=
first_packet_offset
;
start_of_packet
-=
first_packet_offset
;
first_packet_offset
=
0
;
}
net
->
where_b
=
buf_length
;
if
((
packet_len
=
my_real_read
(
net
,
&
complen
,
read_from_server
))
==
packet_error
)
==
packet_error
)
{
MYSQL_NET_READ_DONE
(
1
,
0
);
return
packet_error
;
return
packet_error
;
}
read_from_server
=
0
;
if
(
my_uncompress
(
net
->
buff
+
net
->
where_b
,
packet_len
,
&
complen
))
&
complen
))
{
net
->
error
=
2
;
/* caller will close socket */
net
->
error
=
2
;
/* caller will close socket */
net
->
last_errno
=
ER_NET_UNCOMPRESS_ERROR
;
MYSQL_SERVER_my_error
(
ER_NET_UNCOMPRESS_ERROR
,
MYF
(
0
));
MYSQL_SERVER_my_error
(
ER_NET_UNCOMPRESS_ERROR
,
MYF
(
0
));
MYSQL_NET_READ_DONE
(
1
,
0
);
return
packet_error
;
return
packet_error
;
}
buf_length
+=
complen
;
net
->
real_network_read_len
+=
packet_len
;
...
...
@@ -1275,7 +1276,7 @@ my_net_read_packet(NET *net, my_bool read_from_server)
net
->
buf_length
=
buf_length
;
net
->
remain_in_buf
=
(
ulong
)
(
buf_length
-
start_of_packet
);
len
=
((
ulong
)
(
start_of_packet
-
first_packet_offset
)
-
NET_HEADER_SIZE
-
multi_byte_packet
);
multi_byte_packet
);
net
->
save_char
=
net
->
read_pos
[
len
];
/* Must be saved */
net
->
read_pos
[
len
]
=
0
;
/* Safeguard for mysql_use_result */
}
...
...
sql/slave.cc
View file @
c334f4fe
...
...
@@ -4419,7 +4419,7 @@ pthread_handler_t handle_slave_io(void *arg)
mi
->
slave_running
=
MYSQL_SLAVE_RUN_READING
;
DBUG_ASSERT
(
mi
->
last_error
().
number
==
0
);
ulonglong
lastchecktime
=
my_
micro_time
()
/
1000
;
ulonglong
lastchecktime
=
my_
hrtime
().
val
;
ulonglong
tokenamount
=
opt_read_binlog_speed_limit
*
1024
;
while
(
!
io_slave_killed
(
mi
))
{
...
...
@@ -4481,24 +4481,24 @@ Stopping slave I/O thread due to out-of-memory error from master");
/* Control the binlog read speed of master when read_binlog_speed_limit is non-zero
*/
ulonglong
read_binlog_speed_limit
=
opt_read_binlog_speed_limit
;
if
(
read_binlog_speed_limit
)
{
ulonglong
read_binlog_speed_limit
_in_bytes
=
opt_read_binlog_speed_limit
*
1024
;
if
(
read_binlog_speed_limit
_in_bytes
)
{
/* prevent the tokenamount become a large value,
for example, the IO thread doesn't work for a long time
*/
if
(
tokenamount
>
read_binlog_speed_limit
*
1024
*
2
)
if
(
tokenamount
>
read_binlog_speed_limit
_in_bytes
*
2
)
{
lastchecktime
=
my_
micro_time
()
/
1000
;
tokenamount
=
read_binlog_speed_limit
*
1024
*
2
;
lastchecktime
=
my_
hrtime
().
val
;
tokenamount
=
read_binlog_speed_limit
_in_bytes
*
2
;
}
do
{
ulonglong
currenttime
=
my_
micro_time
()
/
1000
;
tokenamount
+=
(
currenttime
-
lastchecktime
)
*
read_binlog_speed_limit
*
1024
/
1000
;
ulonglong
currenttime
=
my_
hrtime
().
val
;
tokenamount
+=
(
currenttime
-
lastchecktime
)
*
read_binlog_speed_limit
_in_bytes
/
(
1000
*
1000
)
;
lastchecktime
=
currenttime
;
if
(
tokenamount
<
network_read_len
)
{
ulonglong
micro_sleeptime
=
1000
*
1000
*
(
network_read_len
-
tokenamount
)
/
(
read_binlog_speed_limit
*
1024
)
;
ulonglong
micro_sleeptime
=
1000
*
1000
*
(
network_read_len
-
tokenamount
)
/
read_binlog_speed_limit_in_bytes
;
my_sleep
(
micro_sleeptime
>
1000
?
micro_sleeptime
:
1000
);
// at least sleep 1000 micro second
}
}
while
(
tokenamount
<
network_read_len
);
...
...
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