Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: brpc support higher version of protobuf #1679

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/brpc/esp_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ EspMessage* EspMessage::New() const {
return new EspMessage;
}

#if GOOGLE_PROTOBUF_VERSION >= 3006000
EspMessage* EspMessage::New(::google::protobuf::Arena* arena) const {
return CreateMaybeMessage<EspMessage>(arena);
}
#endif

void EspMessage::Clear() {
head.body_len = 0;
body.clear();
Expand Down
3 changes: 3 additions & 0 deletions src/brpc/esp_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class EspMessage : public ::google::protobuf::Message {
// implements Message ----------------------------------------------

EspMessage* New() const;
#if GOOGLE_PROTOBUF_VERSION >= 3006000
EspMessage* New(::google::protobuf::Arena* arena) const override;
#endif
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const EspMessage& from);
Expand Down
13 changes: 13 additions & 0 deletions src/brpc/memcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ MemcacheRequest* MemcacheRequest::New() const {
return new MemcacheRequest;
}

#if GOOGLE_PROTOBUF_VERSION >= 3006000
MemcacheRequest* MemcacheRequest::New(::google::protobuf::Arena* arena) const {
return CreateMaybeMessage<MemcacheRequest>(arena);
}
#endif

void MemcacheRequest::Clear() {
_buf.clear();
_pipelined_count = 0;
Expand Down Expand Up @@ -207,6 +213,13 @@ MemcacheResponse* MemcacheResponse::New() const {
return new MemcacheResponse;
}

#if GOOGLE_PROTOBUF_VERSION >= 3006000
MemcacheResponse*
MemcacheResponse::New(::google::protobuf::Arena* arena) const {
return CreateMaybeMessage<MemcacheResponse>(arena);
}
#endif

void MemcacheResponse::Clear() {
}

Expand Down
6 changes: 6 additions & 0 deletions src/brpc/memcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class MemcacheRequest : public ::google::protobuf::Message {

// Protobuf methods.
MemcacheRequest* New() const;
#if GOOGLE_PROTOBUF_VERSION >= 3006000
MemcacheRequest* New(::google::protobuf::Arena* arena) const override;
#endif
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const MemcacheRequest& from);
Expand Down Expand Up @@ -200,6 +203,9 @@ class MemcacheResponse : public ::google::protobuf::Message {
// implements Message ----------------------------------------------

MemcacheResponse* New() const;
#if GOOGLE_PROTOBUF_VERSION >= 3006000
MemcacheResponse* New(::google::protobuf::Arena* arena) const override;
#endif
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const MemcacheResponse& from);
Expand Down
6 changes: 6 additions & 0 deletions src/brpc/nshead_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ NsheadMessage* NsheadMessage::New() const {
return new NsheadMessage;
}

#if GOOGLE_PROTOBUF_VERSION >= 3006000
NsheadMessage* NsheadMessage::New(::google::protobuf::Arena* arena) const {
return CreateMaybeMessage<NsheadMessage>(arena);
}
#endif

void NsheadMessage::Clear() {
memset(&head, 0, sizeof(head));
body.clear();
Expand Down
3 changes: 3 additions & 0 deletions src/brpc/nshead_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class NsheadMessage : public ::google::protobuf::Message {
// implements Message ----------------------------------------------

NsheadMessage* New() const;
#if GOOGLE_PROTOBUF_VERSION >= 3006000
NsheadMessage* New(::google::protobuf::Arena* arena) const override;
#endif
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const NsheadMessage& from);
Expand Down
4 changes: 4 additions & 0 deletions src/brpc/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ BUTIL_FORCE_INLINE bool ParsePbFromZeroCopyStreamInlined(
// According to source code of pb, SetTotalBytesLimit is not a simple set,
// avoid calling the function when the limit is definitely unreached.
if (PB_TOTAL_BYETS_LIMITS < FLAGS_max_body_size) {
#if GOOGLE_PROTOBUF_VERSION >= 3006000
decoder.SetTotalBytesLimit(INT_MAX);
#else
decoder.SetTotalBytesLimit(INT_MAX, -1);
#endif
}
return msg->ParseFromCodedStream(&decoder) && decoder.ConsumedEntireMessage();
}
Expand Down
12 changes: 12 additions & 0 deletions src/brpc/redis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ RedisRequest* RedisRequest::New() const {
return new RedisRequest;
}

#if GOOGLE_PROTOBUF_VERSION >= 3006000
RedisRequest* RedisRequest::New(::google::protobuf::Arena* arena) const {
return CreateMaybeMessage<RedisRequest>(arena);
}
#endif

void RedisRequest::Clear() {
_ncommand = 0;
_has_error = false;
Expand Down Expand Up @@ -271,6 +277,12 @@ RedisResponse* RedisResponse::New() const {
return new RedisResponse;
}

#if GOOGLE_PROTOBUF_VERSION >= 3006000
RedisResponse* RedisResponse::New(::google::protobuf::Arena* arena) const {
return CreateMaybeMessage<RedisResponse>(arena);
}
#endif

void RedisResponse::Clear() {
_first_reply.Reset();
_other_replies = NULL;
Expand Down
6 changes: 6 additions & 0 deletions src/brpc/redis.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class RedisRequest : public ::google::protobuf::Message {

// Protobuf methods.
RedisRequest* New() const;
#if GOOGLE_PROTOBUF_VERSION >= 3006000
RedisRequest* New(::google::protobuf::Arena* arena) const override;
#endif
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const RedisRequest& from);
Expand Down Expand Up @@ -178,6 +181,9 @@ class RedisResponse : public ::google::protobuf::Message {
// implements Message ----------------------------------------------

RedisResponse* New() const;
#if GOOGLE_PROTOBUF_VERSION >= 3006000
RedisResponse* New(::google::protobuf::Arena* arena) const override;
#endif
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const RedisResponse& from);
Expand Down
7 changes: 7 additions & 0 deletions src/brpc/serialized_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ SerializedRequest* SerializedRequest::New() const {
return new SerializedRequest;
}

#if GOOGLE_PROTOBUF_VERSION >= 3006000
SerializedRequest*
SerializedRequest::New(::google::protobuf::Arena* arena) const {
return CreateMaybeMessage<SerializedRequest>(arena);
}
#endif

void SerializedRequest::Clear() {
_serialized.clear();
}
Expand Down
3 changes: 3 additions & 0 deletions src/brpc/serialized_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class SerializedRequest : public ::google::protobuf::Message {
// implements Message ----------------------------------------------

SerializedRequest* New() const;
#if GOOGLE_PROTOBUF_VERSION >= 3006000
SerializedRequest* New(::google::protobuf::Arena* arena) const override;
#endif
void CopyFrom(const ::google::protobuf::Message& from);
void CopyFrom(const SerializedRequest& from);
void Clear();
Expand Down
7 changes: 7 additions & 0 deletions src/brpc/thrift_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ ThriftFramedMessage* ThriftFramedMessage::New() const {
return new ThriftFramedMessage;
}

#if GOOGLE_PROTOBUF_VERSION >= 3006000
ThriftFramedMessage*
ThriftFramedMessage::New(::google::protobuf::Arena* arena) const {
return CreateMaybeMessage<ThriftFramedMessage>(arena);
}
#endif

void ThriftFramedMessage::Clear() {
body.clear();
if (_own_raw_instance) {
Expand Down
3 changes: 3 additions & 0 deletions src/brpc/thrift_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ friend class ThriftStub;
// implements Message ----------------------------------------------

ThriftFramedMessage* New() const;
#if GOOGLE_PROTOBUF_VERSION >= 3006000
ThriftFramedMessage* New(::google::protobuf::Arena* arena) const override;
#endif
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const ThriftFramedMessage& from);
Expand Down