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

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


The following commit(s) were added to refs/heads/master by this push:
     new 8f9d12a0 Bugfix: NsheadService::_status may be null (#3162)
8f9d12a0 is described below

commit 8f9d12a033218aaa1dc72f60196567f4e2bbdef4
Author: Bright Chen <[email protected]>
AuthorDate: Sun Nov 23 11:30:24 2025 +0800

    Bugfix: NsheadService::_status may be null (#3162)
---
 src/brpc/nshead_service.cpp       | 6 ++----
 src/brpc/rpc_pb_message_factory.h | 2 +-
 src/brpc/server.h                 | 2 +-
 src/brpc/thrift_service.cpp       | 3 +--
 4 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/brpc/nshead_service.cpp b/src/brpc/nshead_service.cpp
index 0f043e23..0371baae 100644
--- a/src/brpc/nshead_service.cpp
+++ b/src/brpc/nshead_service.cpp
@@ -26,15 +26,13 @@ namespace brpc {
 BAIDU_CASSERT(sizeof(nshead_t) == 36, sizeof_nshead_must_be_36);
 
 NsheadService::NsheadService() : _additional_space(0) {
-    _status = new (std::nothrow) MethodStatus;
-    LOG_IF(FATAL, _status == NULL) << "Fail to new MethodStatus";
+    _status = new MethodStatus;
 }
 
 NsheadService::NsheadService(const NsheadServiceOptions& options)
     : _status(NULL), _additional_space(options.additional_space) {
     if (options.generate_status) {
-        _status = new (std::nothrow) MethodStatus;
-        LOG_IF(FATAL, _status == NULL) << "Fail to new MethodStatus";
+        _status = new MethodStatus;
     }
 }
 
diff --git a/src/brpc/rpc_pb_message_factory.h 
b/src/brpc/rpc_pb_message_factory.h
index e65c8f14..20d27a0f 100644
--- a/src/brpc/rpc_pb_message_factory.h
+++ b/src/brpc/rpc_pb_message_factory.h
@@ -65,7 +65,7 @@ namespace internal {
 // For more details, see `google::protobuf::ArenaOptions'.
 template<size_t StartBlockSize, size_t MaxBlockSize>
 struct ArenaRpcPBMessages : public RpcPBMessages {
-    struct ArenaOptionsWrapper {
+    class ArenaOptionsWrapper {
     public:
         ArenaOptionsWrapper() {
             options.start_block_size = StartBlockSize;
diff --git a/src/brpc/server.h b/src/brpc/server.h
index 2cf34dbd..f833325c 100644
--- a/src/brpc/server.h
+++ b/src/brpc/server.h
@@ -714,7 +714,7 @@ friend class Controller;
 
     template <typename T>
     int SetServiceMaxConcurrency(T* service) {
-        if (NULL != service) {
+        if (NULL != service && NULL != service->_status) {
             const AdaptiveMaxConcurrency* amc = &service->_max_concurrency;
             if (amc->type() == AdaptiveMaxConcurrency::UNLIMITED) {
                 amc = &_options.method_max_concurrency;
diff --git a/src/brpc/thrift_service.cpp b/src/brpc/thrift_service.cpp
index 283ea48b..24b24390 100644
--- a/src/brpc/thrift_service.cpp
+++ b/src/brpc/thrift_service.cpp
@@ -23,8 +23,7 @@
 namespace brpc {
 
 ThriftService::ThriftService() {
-    _status = new (std::nothrow) MethodStatus;
-    LOG_IF(FATAL, _status == NULL) << "Fail to new MethodStatus";
+    _status = new MethodStatus;
 }
 
 ThriftService::~ThriftService() {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to