Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
de4fb877
Commit
de4fb877
authored
Nov 30, 2017
by
zhaozhao.zz
Committed by
antirez
Jan 09, 2018
Browse files
aof: fix the short write
parent
1fade3d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/aof.c
View file @
de4fb877
...
@@ -266,6 +266,27 @@ int startAppendOnly(void) {
...
@@ -266,6 +266,27 @@ int startAppendOnly(void) {
return
C_OK
;
return
C_OK
;
}
}
ssize_t
safe_write
(
int
fd
,
const
char
*
buf
,
size_t
len
)
{
ssize_t
nwritten
=
0
,
totwritten
=
0
;
while
(
len
)
{
nwritten
=
write
(
fd
,
buf
,
len
);
if
(
nwritten
<
0
)
{
if
(
errno
==
EINTR
)
{
continue
;
}
return
totwritten
?
totwritten
:
-
1
;
}
len
-=
nwritten
;
buf
+=
nwritten
;
totwritten
+=
nwritten
;
}
return
totwritten
;
}
/* Write the append only file buffer on disk.
/* Write the append only file buffer on disk.
*
*
* Since we are required to write the AOF before replying to the client,
* Since we are required to write the AOF before replying to the client,
...
@@ -323,7 +344,7 @@ void flushAppendOnlyFile(int force) {
...
@@ -323,7 +344,7 @@ void flushAppendOnlyFile(int force) {
* or alike */
* or alike */
latencyStartMonitor
(
latency
);
latencyStartMonitor
(
latency
);
nwritten
=
write
(
server
.
aof_fd
,
server
.
aof_buf
,
sdslen
(
server
.
aof_buf
));
nwritten
=
safe_
write
(
server
.
aof_fd
,
server
.
aof_buf
,
sdslen
(
server
.
aof_buf
));
latencyEndMonitor
(
latency
);
latencyEndMonitor
(
latency
);
/* We want to capture different events for delayed writes:
/* We want to capture different events for delayed writes:
* when the delay happens with a pending fsync, or with a saving child
* when the delay happens with a pending fsync, or with a saving child
...
...
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