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
6b72b04a
Commit
6b72b04a
authored
Jul 17, 2019
by
antirez
Browse files
Rio: when in error condition avoid doing the operation.
parent
5189db3d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/rio.h
View file @
6b72b04a
...
@@ -102,6 +102,7 @@ typedef struct _rio rio;
...
@@ -102,6 +102,7 @@ typedef struct _rio rio;
* if needed. */
* if needed. */
static
inline
size_t
rioWrite
(
rio
*
r
,
const
void
*
buf
,
size_t
len
)
{
static
inline
size_t
rioWrite
(
rio
*
r
,
const
void
*
buf
,
size_t
len
)
{
if
(
r
->
flags
&
RIO_FLAG_WRITE_ERROR
)
return
0
;
while
(
len
)
{
while
(
len
)
{
size_t
bytes_to_write
=
(
r
->
max_processing_chunk
&&
r
->
max_processing_chunk
<
len
)
?
r
->
max_processing_chunk
:
len
;
size_t
bytes_to_write
=
(
r
->
max_processing_chunk
&&
r
->
max_processing_chunk
<
len
)
?
r
->
max_processing_chunk
:
len
;
if
(
r
->
update_cksum
)
r
->
update_cksum
(
r
,
buf
,
bytes_to_write
);
if
(
r
->
update_cksum
)
r
->
update_cksum
(
r
,
buf
,
bytes_to_write
);
...
@@ -117,6 +118,7 @@ static inline size_t rioWrite(rio *r, const void *buf, size_t len) {
...
@@ -117,6 +118,7 @@ static inline size_t rioWrite(rio *r, const void *buf, size_t len) {
}
}
static
inline
size_t
rioRead
(
rio
*
r
,
void
*
buf
,
size_t
len
)
{
static
inline
size_t
rioRead
(
rio
*
r
,
void
*
buf
,
size_t
len
)
{
if
(
r
->
flags
&
RIO_FLAG_READ_ERROR
)
return
0
;
while
(
len
)
{
while
(
len
)
{
size_t
bytes_to_read
=
(
r
->
max_processing_chunk
&&
r
->
max_processing_chunk
<
len
)
?
r
->
max_processing_chunk
:
len
;
size_t
bytes_to_read
=
(
r
->
max_processing_chunk
&&
r
->
max_processing_chunk
<
len
)
?
r
->
max_processing_chunk
:
len
;
if
(
r
->
read
(
r
,
buf
,
bytes_to_read
)
==
0
)
{
if
(
r
->
read
(
r
,
buf
,
bytes_to_read
)
==
0
)
{
...
...
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