Skip to content

Commit 9018c4c

Browse files
committed
Bugfix: NsheadService::_status may be null
1 parent a54b607 commit 9018c4c

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

src/brpc/nshead_service.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@ namespace brpc {
2626
BAIDU_CASSERT(sizeof(nshead_t) == 36, sizeof_nshead_must_be_36);
2727

2828
NsheadService::NsheadService() : _additional_space(0) {
29-
_status = new (std::nothrow) MethodStatus;
30-
LOG_IF(FATAL, _status == NULL) << "Fail to new MethodStatus";
29+
_status = new MethodStatus;
3130
}
3231

3332
NsheadService::NsheadService(const NsheadServiceOptions& options)
3433
: _status(NULL), _additional_space(options.additional_space) {
3534
if (options.generate_status) {
36-
_status = new (std::nothrow) MethodStatus;
37-
LOG_IF(FATAL, _status == NULL) << "Fail to new MethodStatus";
35+
_status = new MethodStatus;
3836
}
3937
}
4038

src/brpc/rpc_pb_message_factory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ namespace internal {
6565
// For more details, see `google::protobuf::ArenaOptions'.
6666
template<size_t StartBlockSize, size_t MaxBlockSize>
6767
struct ArenaRpcPBMessages : public RpcPBMessages {
68-
struct ArenaOptionsWrapper {
68+
class ArenaOptionsWrapper {
6969
public:
7070
ArenaOptionsWrapper() {
7171
options.start_block_size = StartBlockSize;

src/brpc/server.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ friend class Controller;
714714

715715
template <typename T>
716716
int SetServiceMaxConcurrency(T* service) {
717-
if (NULL != service) {
717+
if (NULL != service && NULL != service->_status) {
718718
const AdaptiveMaxConcurrency* amc = &service->_max_concurrency;
719719
if (amc->type() == AdaptiveMaxConcurrency::UNLIMITED) {
720720
amc = &_options.method_max_concurrency;

src/brpc/thrift_service.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
namespace brpc {
2424

2525
ThriftService::ThriftService() {
26-
_status = new (std::nothrow) MethodStatus;
27-
LOG_IF(FATAL, _status == NULL) << "Fail to new MethodStatus";
26+
_status = new MethodStatus;
2827
}
2928

3029
ThriftService::~ThriftService() {

0 commit comments

Comments
 (0)