Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
a4038164
Unverified
Commit
a4038164
authored
Jul 29, 2021
by
Ewg-c
Committed by
GitHub
Jul 29, 2021
Browse files
Minor refactoring for rioConnRead and adding errno (#9280)
minor refactoring for rioConnRead and adding errno
parent
8bf433dc
Changes
2
Show whitespace changes
Inline
Side-by-side
src/replication.c
View file @
a4038164
...
@@ -1756,10 +1756,10 @@ void readSyncBulkPayload(connection *conn) {
...
@@ -1756,10 +1756,10 @@ void readSyncBulkPayload(connection *conn) {
if
(
rdbLoadRio
(
&
rdb
,
RDBFLAGS_REPLICATION
,
&
rsi
)
!=
C_OK
)
{
if
(
rdbLoadRio
(
&
rdb
,
RDBFLAGS_REPLICATION
,
&
rsi
)
!=
C_OK
)
{
/* RDB loading failed. */
/* RDB loading failed. */
stopLoading
(
0
);
serverLog
(
LL_WARNING
,
serverLog
(
LL_WARNING
,
"Failed trying to load the MASTER synchronization DB "
"Failed trying to load the MASTER synchronization DB "
"from socket"
);
"from socket: %s"
,
strerror
(
errno
));
stopLoading
(
0
);
cancelReplicationHandshake
(
1
);
cancelReplicationHandshake
(
1
);
rioFreeConn
(
&
rdb
,
NULL
);
rioFreeConn
(
&
rdb
,
NULL
);
...
...
src/rio.c
View file @
a4038164
...
@@ -187,6 +187,14 @@ static size_t rioConnRead(rio *r, void *buf, size_t len) {
...
@@ -187,6 +187,14 @@ static size_t rioConnRead(rio *r, void *buf, size_t len) {
r
->
io
.
conn
.
pos
=
0
;
r
->
io
.
conn
.
pos
=
0
;
}
}
/* Make sure the caller didn't request to read past the limit.
* If they didn't we'll buffer till the limit, if they did, we'll
* return an error. */
if
(
r
->
io
.
conn
.
read_limit
!=
0
&&
r
->
io
.
conn
.
read_limit
<
r
->
io
.
conn
.
read_so_far
+
len
)
{
errno
=
EOVERFLOW
;
return
0
;
}
/* If we don't already have all the data in the sds, read more */
/* If we don't already have all the data in the sds, read more */
while
(
len
>
sdslen
(
r
->
io
.
conn
.
buf
)
-
r
->
io
.
conn
.
pos
)
{
while
(
len
>
sdslen
(
r
->
io
.
conn
.
buf
)
-
r
->
io
.
conn
.
pos
)
{
size_t
buffered
=
sdslen
(
r
->
io
.
conn
.
buf
)
-
r
->
io
.
conn
.
pos
;
size_t
buffered
=
sdslen
(
r
->
io
.
conn
.
buf
)
-
r
->
io
.
conn
.
pos
;
...
@@ -198,15 +206,7 @@ static size_t rioConnRead(rio *r, void *buf, size_t len) {
...
@@ -198,15 +206,7 @@ static size_t rioConnRead(rio *r, void *buf, size_t len) {
if
(
r
->
io
.
conn
.
read_limit
!=
0
&&
if
(
r
->
io
.
conn
.
read_limit
!=
0
&&
r
->
io
.
conn
.
read_so_far
+
buffered
+
toread
>
r
->
io
.
conn
.
read_limit
)
r
->
io
.
conn
.
read_so_far
+
buffered
+
toread
>
r
->
io
.
conn
.
read_limit
)
{
{
/* Make sure the caller didn't request to read past the limit.
* If they didn't we'll buffer till the limit, if they did, we'll
* return an error. */
if
(
r
->
io
.
conn
.
read_limit
>=
r
->
io
.
conn
.
read_so_far
+
len
)
toread
=
r
->
io
.
conn
.
read_limit
-
r
->
io
.
conn
.
read_so_far
-
buffered
;
toread
=
r
->
io
.
conn
.
read_limit
-
r
->
io
.
conn
.
read_so_far
-
buffered
;
else
{
errno
=
EOVERFLOW
;
return
0
;
}
}
}
int
retval
=
connRead
(
r
->
io
.
conn
.
conn
,
int
retval
=
connRead
(
r
->
io
.
conn
.
conn
,
(
char
*
)
r
->
io
.
conn
.
buf
+
sdslen
(
r
->
io
.
conn
.
buf
),
(
char
*
)
r
->
io
.
conn
.
buf
+
sdslen
(
r
->
io
.
conn
.
buf
),
...
...
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