You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by lo...@apache.org on 2022/10/24 02:13:26 UTC

[incubator-brpc] branch master updated: fix arena cleared early when parse redis message

This is an automated email from the ASF dual-hosted git repository.

lorinlee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new 03ad6bc4 fix arena cleared early when parse redis message
     new 5d898930 Merge pull request #1959 from dorothy00dd2/fix-redis
03ad6bc4 is described below

commit 03ad6bc4e197f90efc32fa825de16dcfc1dac906
Author: jiumei <ji...@xiaohongshu.com>
AuthorDate: Wed Oct 19 20:18:17 2022 +0800

    fix arena cleared early when parse redis message
---
 src/brpc/policy/redis_protocol.cpp | 4 +++-
 src/brpc/redis_command.cpp         | 4 ++++
 src/brpc/redis_command.h           | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/brpc/policy/redis_protocol.cpp b/src/brpc/policy/redis_protocol.cpp
index 67e52133..94524e8b 100644
--- a/src/brpc/policy/redis_protocol.cpp
+++ b/src/brpc/policy/redis_protocol.cpp
@@ -190,7 +190,9 @@ ParseResult ParseRedisMessage(butil::IOBuf* source, Socket* socket,
         wopt.ignore_eovercrowded = true;
         LOG_IF(WARNING, socket->Write(&sendbuf, &wopt) != 0)
             << "Fail to send redis reply";
-        ctx->arena.clear();
+        if(ctx->parser.ParsedArgsSize() == 0) {
+            ctx->arena.clear();
+        }
         return MakeParseError(err);
     } else {
         // NOTE(gejun): PopPipelinedInfo() is actually more contended than what
diff --git a/src/brpc/redis_command.cpp b/src/brpc/redis_command.cpp
index 2396e457..82f79505 100644
--- a/src/brpc/redis_command.cpp
+++ b/src/brpc/redis_command.cpp
@@ -361,6 +361,10 @@ RedisCommandParser::RedisCommandParser()
     , _length(0)
     , _index(0) {}
 
+size_t RedisCommandParser::ParsedArgsSize() {
+    return _args.size();
+}
+
 ParseError RedisCommandParser::Consume(butil::IOBuf& buf,
                                        std::vector<butil::StringPiece>* args,
                                        butil::Arena* arena) {
diff --git a/src/brpc/redis_command.h b/src/brpc/redis_command.h
index fc883995..5ddfb8e9 100644
--- a/src/brpc/redis_command.h
+++ b/src/brpc/redis_command.h
@@ -53,6 +53,7 @@ public:
     // in `arena'.
     ParseError Consume(butil::IOBuf& buf, std::vector<butil::StringPiece>* args,
                        butil::Arena* arena);
+    size_t ParsedArgsSize();
 
 private:
     // Reset parser to the initial state.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org