Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
a1b98a76
Commit
a1b98a76
authored
5 years ago
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redis_server_protocol: fix bug that arena is local
parent
627526f0
master
0.9.8-rc01
0.9.7
0.9.7-rc03
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
redis_protocol.cpp
src/brpc/policy/redis_protocol.cpp
+8
-9
redis_command.cpp
src/brpc/redis_command.cpp
+4
-3
No files found.
src/brpc/policy/redis_protocol.cpp
View file @
a1b98a76
...
@@ -74,15 +74,15 @@ public:
...
@@ -74,15 +74,15 @@ public:
int
batched_size
;
int
batched_size
;
RedisCommandParser
parser
;
RedisCommandParser
parser
;
butil
::
Arena
arena
;
};
};
int
ConsumeCommand
(
RedisConnContext
*
ctx
,
int
ConsumeCommand
(
RedisConnContext
*
ctx
,
const
std
::
vector
<
const
char
*>&
commands
,
const
std
::
vector
<
const
char
*>&
commands
,
const
std
::
string
&
next_command
,
const
std
::
string
&
next_command
,
butil
::
Arena
*
arena
,
bool
flush_back
,
bool
flush_back
,
butil
::
IOBufAppender
*
appender
)
{
butil
::
IOBufAppender
*
appender
)
{
RedisReply
output
(
arena
);
RedisReply
output
(
&
ctx
->
arena
);
RedisCommandHandler
::
Result
result
=
RedisCommandHandler
::
OK
;
RedisCommandHandler
::
Result
result
=
RedisCommandHandler
::
OK
;
if
(
ctx
->
transaction_handler
)
{
if
(
ctx
->
transaction_handler
)
{
result
=
ctx
->
transaction_handler
->
Run
(
commands
,
&
output
,
flush_back
);
result
=
ctx
->
transaction_handler
->
Run
(
commands
,
&
output
,
flush_back
);
...
@@ -169,31 +169,29 @@ ParseResult ParseRedisMessage(butil::IOBuf* source, Socket* socket,
...
@@ -169,31 +169,29 @@ ParseResult ParseRedisMessage(butil::IOBuf* source, Socket* socket,
ctx
->
redis_service
=
rs
;
ctx
->
redis_service
=
rs
;
socket
->
reset_parsing_context
(
ctx
);
socket
->
reset_parsing_context
(
ctx
);
}
}
butil
::
Arena
arena
;
std
::
vector
<
const
char
*>
current_commands
;
std
::
vector
<
const
char
*>
current_commands
;
butil
::
IOBufAppender
appender
;
butil
::
IOBufAppender
appender
;
ParseError
err
=
PARSE_OK
;
ParseError
err
=
PARSE_OK
;
err
=
ctx
->
parser
.
Consume
(
*
source
,
&
current_commands
,
&
arena
);
err
=
ctx
->
parser
.
Consume
(
*
source
,
&
current_commands
,
&
ctx
->
arena
);
if
(
err
!=
PARSE_OK
)
{
if
(
err
!=
PARSE_OK
)
{
return
MakeParseError
(
err
);
return
MakeParseError
(
err
);
}
}
while
(
true
)
{
while
(
true
)
{
std
::
vector
<
const
char
*>
next_commands
;
std
::
vector
<
const
char
*>
next_commands
;
err
=
ctx
->
parser
.
Consume
(
*
source
,
&
next_commands
,
&
arena
);
err
=
ctx
->
parser
.
Consume
(
*
source
,
&
next_commands
,
&
ctx
->
arena
);
if
(
err
!=
PARSE_OK
)
{
if
(
err
!=
PARSE_OK
)
{
break
;
break
;
}
}
// next_commands must have at least one element, otherwise parse.Consume()
// next_commands must have at least one element, otherwise parse.Consume()
// should return error.
// should return error.
if
(
ConsumeCommand
(
ctx
,
current_commands
,
next_commands
[
0
],
&
arena
,
if
(
ConsumeCommand
(
ctx
,
current_commands
,
next_commands
[
0
],
false
,
&
appender
)
!=
0
)
{
false
,
&
appender
)
!=
0
)
{
return
MakeParseError
(
PARSE_ERROR_ABSOLUTELY_WRONG
);
return
MakeParseError
(
PARSE_ERROR_ABSOLUTELY_WRONG
);
}
}
current_commands
.
swap
(
next_commands
);
current_commands
.
swap
(
next_commands
);
}
}
if
(
ConsumeCommand
(
ctx
,
current_commands
,
""
,
&
arena
,
if
(
ConsumeCommand
(
ctx
,
current_commands
,
""
,
true
/* must be last message
*/
,
&
appender
)
!=
0
)
{
true
/*must be the last message
*/
,
&
appender
)
!=
0
)
{
return
MakeParseError
(
PARSE_ERROR_ABSOLUTELY_WRONG
);
return
MakeParseError
(
PARSE_ERROR_ABSOLUTELY_WRONG
);
}
}
butil
::
IOBuf
sendbuf
;
butil
::
IOBuf
sendbuf
;
...
@@ -203,6 +201,7 @@ ParseResult ParseRedisMessage(butil::IOBuf* source, Socket* socket,
...
@@ -203,6 +201,7 @@ ParseResult ParseRedisMessage(butil::IOBuf* source, Socket* socket,
wopt
.
ignore_eovercrowded
=
true
;
wopt
.
ignore_eovercrowded
=
true
;
LOG_IF
(
WARNING
,
socket
->
Write
(
&
sendbuf
,
&
wopt
)
!=
0
)
LOG_IF
(
WARNING
,
socket
->
Write
(
&
sendbuf
,
&
wopt
)
!=
0
)
<<
"Fail to send redis reply"
;
<<
"Fail to send redis reply"
;
ctx
->
arena
.
clear
();
return
MakeParseError
(
err
);
return
MakeParseError
(
err
);
}
else
{
}
else
{
// NOTE(gejun): PopPipelinedInfo() is actually more contended than what
// NOTE(gejun): PopPipelinedInfo() is actually more contended than what
...
...
This diff is collapsed.
Click to expand it.
src/brpc/redis_command.cpp
View file @
a1b98a76
...
@@ -345,9 +345,10 @@ butil::Status RedisCommandByComponents(butil::IOBuf* output,
...
@@ -345,9 +345,10 @@ butil::Status RedisCommandByComponents(butil::IOBuf* output,
return
butil
::
Status
::
OK
();
return
butil
::
Status
::
OK
();
}
}
RedisCommandParser
::
RedisCommandParser
()
{
RedisCommandParser
::
RedisCommandParser
()
Reset
();
:
_parsing_array
(
false
)
}
,
_length
(
0
)
,
_index
(
0
)
{}
ParseError
RedisCommandParser
::
Consume
(
butil
::
IOBuf
&
buf
,
ParseError
RedisCommandParser
::
Consume
(
butil
::
IOBuf
&
buf
,
std
::
vector
<
const
char
*>*
commands
,
std
::
vector
<
const
char
*>*
commands
,
...
...
This diff is collapsed.
Click to expand it.
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