You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by xi...@apache.org on 2026/08/19 05:26:25 UTC
(brpc) branch master updated: Refactor NULL with nullptr in test (#3464)
This is an automated email from the ASF dual-hosted git repository.
wasphin 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 c9778ca1 Refactor NULL with nullptr in test (#3464)
c9778ca1 is described below
commit c9778ca1a364e397d2f4bb2a926e55b79f427df5
Author: Bright Chen <ch...@foxmail.com>
AuthorDate: Wed Aug 19 13:26:18 2026 +0800
Refactor NULL with nullptr in test (#3464)
---
test/allocator_unittest.cc | 20 +-
test/at_exit_unittest.cc | 16 +-
test/baidu_thread_local_unittest.cpp | 46 ++--
test/baidu_time_unittest.cpp | 2 +-
test/bounded_queue_unittest.cc | 4 +-
test/brpc_block_pool_unittest.cpp | 26 +--
test/brpc_builtin_service_unittest.cpp | 52 ++---
test/brpc_channel_unittest.cpp | 256 ++++++++++-----------
test/brpc_checksum_unittest.cpp | 16 +-
test/brpc_coroutine_unittest.cpp | 2 +-
test/brpc_couchbase_unittest.cpp | 2 +-
test/brpc_esp_protocol_unittest.cpp | 8 +-
test/brpc_event_dispatcher_unittest.cpp | 16 +-
test/brpc_extension_unittest.cpp | 2 +-
test/brpc_grpc_protocol_unittest.cpp | 18 +-
test/brpc_h2_unsent_message_unittest.cpp | 4 +-
test/brpc_hpack_unittest.cpp | 10 +-
test/brpc_http_message_unittest.cpp | 22 +-
test/brpc_http_rpc_protocol_unittest.cpp | 180 +++++++--------
test/brpc_hulu_pbrpc_protocol_unittest.cpp | 20 +-
test/brpc_input_messenger_unittest.cpp | 20 +-
test/brpc_interceptor_unittest.cpp | 4 +-
test/brpc_load_balancer_unittest.cpp | 64 +++---
test/brpc_mcpack2pb_unittest.cpp | 8 +-
test/brpc_memcache_unittest.cpp | 20 +-
test/brpc_mongo_protocol_unittest.cpp | 2 +-
test/brpc_mysql_auth_handshake_unittest.cpp | 50 ++---
test/brpc_mysql_auth_packet_unittest.cpp | 2 +-
test/brpc_mysql_connection_type_unittest.cpp | 12 +-
test/brpc_mysql_pool_concurrency_unittest.cpp | 136 ++++++------
test/brpc_mysql_prepared_integration_unittest.cpp | 38 ++--
test/brpc_mysql_txn_integration_unittest.cpp | 26 +--
test/brpc_naming_service_filter_unittest.cpp | 2 +-
test/brpc_naming_service_unittest.cpp | 8 +-
test/brpc_nova_pbrpc_protocol_unittest.cpp | 14 +-
test/brpc_p2c_ewma_load_balancer_unittest.cpp | 44 ++--
test/brpc_prometheus_metrics_unittest.cpp | 4 +-
test/brpc_proto_unittest.cpp | 10 +-
test/brpc_protobuf_json_unittest.cpp | 50 ++---
test/brpc_public_pbrpc_protocol_unittest.cpp | 16 +-
test/brpc_rdma_unittest.cpp | 144 ++++++------
test/brpc_redis_cluster_unittest.cpp | 96 ++++----
test/brpc_redis_unittest.cpp | 50 ++---
test/brpc_rtmp_unittest.cpp | 12 +-
test/brpc_server_unittest.cpp | 258 +++++++++++-----------
test/brpc_socket_map_unittest.cpp | 8 +-
test/brpc_socket_unittest.cpp | 120 +++++-----
test/brpc_sofa_pbrpc_protocol_unittest.cpp | 24 +-
test/brpc_ssl_unittest.cpp | 84 +++----
test/brpc_streaming_rpc_unittest.cpp | 112 +++++-----
test/brpc_ubring_unittest.cpp | 4 +-
test/bthread_butex_unittest.cpp | 64 +++---
test/bthread_cond_bug_unittest.cpp | 4 +-
test/bthread_cond_unittest.cpp | 98 ++++----
test/bthread_countdown_event_unittest.cpp | 6 +-
test/bthread_dispatcher_unittest.cpp | 28 +--
test/bthread_execution_queue_unittest.cpp | 60 ++---
test/bthread_fd_unittest.cpp | 96 ++++----
test/bthread_futex_unittest.cpp | 22 +-
test/bthread_id_unittest.cpp | 134 +++++------
test/bthread_key_unittest.cpp | 134 +++++------
test/bthread_list_unittest.cpp | 6 +-
test/bthread_mutex_unittest.cpp | 78 +++----
test/bthread_once_unittest.cpp | 24 +-
test/bthread_ping_pong_unittest.cpp | 22 +-
test/bthread_priority_queue_unittest.cpp | 28 +--
test/bthread_rwlock_unittest.cpp | 156 ++++++-------
test/bthread_sched_yield_unittest.cpp | 12 +-
test/bthread_semaphore_unittest.cpp | 46 ++--
test/bthread_setconcurrency_unittest.cpp | 34 +--
test/bthread_timer_thread_unittest.cpp | 22 +-
test/bthread_unittest.cpp | 186 ++++++++--------
test/bthread_work_stealing_queue_unittest.cpp | 14 +-
test/bvar_agent_group_unittest.cpp | 12 +-
test/bvar_lock_timer_unittest.cpp | 22 +-
test/bvar_multi_dimension_unittest.cpp | 36 +--
test/bvar_percentile_unittest.cpp | 2 +-
test/bvar_recorder_unittest.cpp | 2 +-
test/bvar_reducer_unittest.cpp | 12 +-
test/bvar_sampler_unittest.cpp | 6 +-
test/bvar_variable_unittest.cpp | 6 +-
test/condition_variable_unittest.cc | 4 +-
test/crash_logging_unittest.cc | 4 +-
test/endpoint_unittest.cpp | 26 +--
test/environment_unittest.cc | 16 +-
test/file_unittest.cc | 4 +-
test/file_util_unittest.cc | 16 +-
test/flat_map_unittest.cpp | 38 ++--
test/fuzzing/fuzz_baidu_rpc.cpp | 4 +-
test/fuzzing/fuzz_common.h | 2 +-
test/fuzzing/fuzz_couchbase.cpp | 4 +-
test/fuzzing/fuzz_esp.cpp | 4 +-
test/fuzzing/fuzz_hulu.cpp | 4 +-
test/fuzzing/fuzz_memcache.cpp | 4 +-
test/fuzzing/fuzz_mongo.cpp | 4 +-
test/fuzzing/fuzz_shead.cpp | 4 +-
test/fuzzing/fuzz_sofa.cpp | 4 +-
test/fuzzing/fuzz_streaming.cpp | 4 +-
test/fuzzing/fuzz_thrift.cpp | 2 +-
test/iobuf_unittest.cpp | 70 +++---
test/lazy_instance_unittest.cc | 2 +-
test/linked_list_unittest.cc | 6 +-
test/linked_ptr_unittest.cc | 16 +-
test/logging_unittest.cc | 22 +-
test/memory_unittest.cc | 28 +--
test/mpsc_queue_unittest.cc | 24 +-
test/multiprocess_func_list.h | 2 +-
test/object_pool_unittest.cpp | 16 +-
test/popen_unittest.cpp | 8 +-
test/recordio_unittest.cpp | 10 +-
test/ref_counted_memory_unittest.cc | 2 +-
test/ref_counted_unittest.cc | 2 +-
test/resource_pool_unittest.cpp | 16 +-
test/safe_sprintf_unittest.cc | 4 +-
test/scoped_locale.cc | 4 +-
test/scoped_ptr_unittest.cc | 8 +-
test/scoped_vector_unittest.cc | 2 +-
test/security_unittest.cc | 12 +-
test/shared_memory_unittest.cc | 14 +-
test/singleton_unittest.cc | 4 +-
test/stack_container_unittest.cc | 2 +-
test/string_number_conversions_unittest.cc | 2 +-
test/string_piece_unittest.cc | 20 +-
test/string_splitter_unittest.cpp | 16 +-
test/string_util_unittest.cc | 10 +-
test/synchronous_event_unittest.cpp | 2 +-
test/thread_key_unittest.cpp | 74 +++----
test/thread_local_storage_unittest.cc | 4 +-
test/thread_local_unittest.cc | 22 +-
test/time_unittest.cc | 4 +-
test/weak_ptr_unittest.cc | 16 +-
131 files changed, 2064 insertions(+), 2064 deletions(-)
diff --git a/test/allocator_unittest.cc b/test/allocator_unittest.cc
index dd4fe6d0..37a3f2e6 100644
--- a/test/allocator_unittest.cc
+++ b/test/allocator_unittest.cc
@@ -276,9 +276,9 @@ static void TestAtomicOps() {
static void TestCalloc(size_t n, size_t s, bool ok) {
char* p = reinterpret_cast<char*>(calloc(n, s));
if (!ok) {
- EXPECT_EQ(NULL, p) << "calloc(n, s) should not succeed";
+ EXPECT_EQ(nullptr, p) << "calloc(n, s) should not succeed";
} else {
- EXPECT_NE(reinterpret_cast<void*>(NULL), p) <<
+ EXPECT_NE(static_cast<void*>(nullptr), p) <<
"calloc(n, s) should succeed";
for (size_t i = 0; i < n*s; i++) {
EXPECT_EQ('\0', p[i]);
@@ -301,7 +301,7 @@ static void TestOneNewWithoutExceptions(void* (*func)(size_t),
// success test
try {
void* ptr = (*func)(kNotTooBig);
- EXPECT_NE(reinterpret_cast<void*>(NULL), ptr) <<
+ EXPECT_NE(static_cast<void*>(nullptr), ptr) <<
"allocation should not have failed.";
} catch(...) {
EXPECT_EQ(0, 1) << "allocation threw unexpected exception.";
@@ -310,7 +310,7 @@ static void TestOneNewWithoutExceptions(void* (*func)(size_t),
// failure test
try {
void* rv = (*func)(kTooBig);
- EXPECT_EQ(NULL, rv);
+ EXPECT_EQ(nullptr, rv);
EXPECT_FALSE(should_throw) << "allocation should have thrown.";
} catch(...) {
EXPECT_TRUE(should_throw) << "allocation threw unexpected exception.";
@@ -422,7 +422,7 @@ TEST(Allocators, Realloc2) {
EXPECT_TRUE(Valid(dst, min(src_size, dst_size)));
Fill(dst, dst_size);
EXPECT_TRUE(Valid(dst, dst_size));
- if (dst != NULL) free(dst);
+ if (dst != nullptr) free(dst);
}
}
@@ -449,12 +449,12 @@ TEST(Allocators, Realloc2) {
}
TEST(Allocators, ReallocZero) {
- // Test that realloc to zero does not return NULL.
+ // Test that realloc to zero does not return nullptr.
for (int size = 0; size >= 0; size = NextSize(size)) {
char* ptr = reinterpret_cast<char*>(malloc(size));
- EXPECT_NE(static_cast<char*>(NULL), ptr);
+ EXPECT_NE(static_cast<char*>(nullptr), ptr);
ptr = reinterpret_cast<char*>(realloc(ptr, 0));
- EXPECT_NE(static_cast<char*>(NULL), ptr);
+ EXPECT_NE(static_cast<char*>(nullptr), ptr);
if (ptr)
free(ptr);
}
@@ -466,7 +466,7 @@ TEST(Allocators, Recalloc) {
for (int src_size = 0; src_size >= 0; src_size = NextSize(src_size)) {
for (int dst_size = 0; dst_size >= 0; dst_size = NextSize(dst_size)) {
unsigned char* src =
- reinterpret_cast<unsigned char*>(_recalloc(NULL, 1, src_size));
+ reinterpret_cast<unsigned char*>(_recalloc(nullptr, 1, src_size));
EXPECT_TRUE(IsZeroed(src, src_size));
Fill(src, src_size);
unsigned char* dst =
@@ -474,7 +474,7 @@ TEST(Allocators, Recalloc) {
EXPECT_TRUE(Valid(dst, min(src_size, dst_size)));
Fill(dst, dst_size);
EXPECT_TRUE(Valid(dst, dst_size));
- if (dst != NULL)
+ if (dst != nullptr)
free(dst);
}
}
diff --git a/test/at_exit_unittest.cc b/test/at_exit_unittest.cc
index 997c0b68..80a08ed3 100644
--- a/test/at_exit_unittest.cc
+++ b/test/at_exit_unittest.cc
@@ -29,7 +29,7 @@ void ExpectCounter1IsZero(void* unused) {
}
void ExpectParamIsNull(void* param) {
- EXPECT_EQ(static_cast<void*>(NULL), param);
+ EXPECT_EQ(static_cast<void*>(nullptr), param);
}
void ExpectParamIsCounter(void* param) {
@@ -47,9 +47,9 @@ class AtExitTest : public testing::Test {
TEST_F(AtExitTest, Basic) {
ZeroTestCounters();
- butil::AtExitManager::RegisterCallback(&IncrementTestCounter1, NULL);
- butil::AtExitManager::RegisterCallback(&IncrementTestCounter2, NULL);
- butil::AtExitManager::RegisterCallback(&IncrementTestCounter1, NULL);
+ butil::AtExitManager::RegisterCallback(&IncrementTestCounter1, nullptr);
+ butil::AtExitManager::RegisterCallback(&IncrementTestCounter2, nullptr);
+ butil::AtExitManager::RegisterCallback(&IncrementTestCounter1, nullptr);
EXPECT_EQ(0, g_test_counter_1);
EXPECT_EQ(0, g_test_counter_2);
@@ -60,9 +60,9 @@ TEST_F(AtExitTest, Basic) {
TEST_F(AtExitTest, LIFOOrder) {
ZeroTestCounters();
- butil::AtExitManager::RegisterCallback(&IncrementTestCounter1, NULL);
- butil::AtExitManager::RegisterCallback(&ExpectCounter1IsZero, NULL);
- butil::AtExitManager::RegisterCallback(&IncrementTestCounter2, NULL);
+ butil::AtExitManager::RegisterCallback(&IncrementTestCounter1, nullptr);
+ butil::AtExitManager::RegisterCallback(&ExpectCounter1IsZero, nullptr);
+ butil::AtExitManager::RegisterCallback(&IncrementTestCounter2, nullptr);
EXPECT_EQ(0, g_test_counter_1);
EXPECT_EQ(0, g_test_counter_2);
@@ -72,7 +72,7 @@ TEST_F(AtExitTest, LIFOOrder) {
}
TEST_F(AtExitTest, Param) {
- butil::AtExitManager::RegisterCallback(&ExpectParamIsNull, NULL);
+ butil::AtExitManager::RegisterCallback(&ExpectParamIsNull, nullptr);
butil::AtExitManager::RegisterCallback(&ExpectParamIsCounter,
&g_test_counter_1);
butil::AtExitManager::ProcessCallbacksNow();
diff --git a/test/baidu_thread_local_unittest.cpp b/test/baidu_thread_local_unittest.cpp
index 4cc629f3..2d242648 100644
--- a/test/baidu_thread_local_unittest.cpp
+++ b/test/baidu_thread_local_unittest.cpp
@@ -22,7 +22,7 @@
namespace {
-BAIDU_THREAD_LOCAL int * dummy = NULL;
+BAIDU_THREAD_LOCAL int * dummy = nullptr;
const size_t NTHREAD = 8;
static bool processed[NTHREAD+1];
static bool deleted[NTHREAD+1];
@@ -70,15 +70,15 @@ void* foo(void* arg) {
x = arg;
usleep(10000);
printf("x=%p\n", x);
- return NULL;
+ return nullptr;
}
TEST_F(BaiduThreadLocalTest, thread_local_keyword) {
pthread_t th[2];
- pthread_create(&th[0], NULL, foo, (void*)1);
- pthread_create(&th[1], NULL, foo, (void*)2);
- pthread_join(th[0], NULL);
- pthread_join(th[1], NULL);
+ pthread_create(&th[0], nullptr, foo, (void*)1);
+ pthread_create(&th[1], nullptr, foo, (void*)2);
+ pthread_join(th[0], nullptr);
+ pthread_join(th[1], nullptr);
}
void* yell(void*) {
@@ -89,7 +89,7 @@ void* yell(void*) {
EXPECT_EQ(p, butil::get_thread_local<YellObj>());
EXPECT_EQ(2, YellObj::nc);
EXPECT_EQ(0, YellObj::nd);
- return NULL;
+ return nullptr;
}
TEST_F(BaiduThreadLocalTest, get_thread_local) {
@@ -103,8 +103,8 @@ TEST_F(BaiduThreadLocalTest, get_thread_local) {
ASSERT_EQ(1, YellObj::nc);
ASSERT_EQ(0, YellObj::nd);
pthread_t th;
- ASSERT_EQ(0, pthread_create(&th, NULL, yell, NULL));
- pthread_join(th, NULL);
+ ASSERT_EQ(0, pthread_create(&th, nullptr, yell, nullptr));
+ pthread_join(th, nullptr);
EXPECT_EQ(2, YellObj::nc);
EXPECT_EQ(1, YellObj::nd);
}
@@ -113,7 +113,7 @@ void delete_dummy(void* arg) {
*(bool*)arg = true;
if (dummy) {
delete dummy;
- dummy = NULL;
+ dummy = nullptr;
} else {
printf("dummy is NULL\n");
}
@@ -122,15 +122,15 @@ void delete_dummy(void* arg) {
void* proc_dummy(void* arg) {
bool *p = (bool*)arg;
*p = true;
- EXPECT_TRUE(dummy == NULL);
+ EXPECT_TRUE(dummy == nullptr);
dummy = new int(p - processed);
butil::thread_atexit(delete_dummy, deleted + (p - processed));
- return NULL;
+ return nullptr;
}
TEST_F(BaiduThreadLocalTest, sanity) {
errno = 0;
- ASSERT_EQ(-1, butil::thread_atexit(NULL));
+ ASSERT_EQ(-1, butil::thread_atexit(nullptr));
ASSERT_EQ(EINVAL, errno);
processed[NTHREAD] = false;
@@ -141,18 +141,18 @@ TEST_F(BaiduThreadLocalTest, sanity) {
for (size_t i = 0; i < NTHREAD; ++i) {
processed[i] = false;
deleted[i] = false;
- ASSERT_EQ(0, pthread_create(&th[i], NULL, proc_dummy, processed + i));
+ ASSERT_EQ(0, pthread_create(&th[i], nullptr, proc_dummy, processed + i));
}
for (size_t i = 0; i < NTHREAD; ++i) {
- ASSERT_EQ(0, pthread_join(th[i], NULL));
+ ASSERT_EQ(0, pthread_join(th[i], nullptr));
ASSERT_TRUE(processed[i]);
ASSERT_TRUE(deleted[i]);
}
}
-static std::ostringstream* oss = NULL;
+static std::ostringstream* oss = nullptr;
inline std::ostringstream& get_oss() {
- if (oss == NULL) {
+ if (oss == nullptr) {
oss = new std::ostringstream;
}
return *oss;
@@ -181,8 +181,8 @@ static void check_result() {
}
TEST_F(BaiduThreadLocalTest, call_order_and_cancel) {
- butil::thread_atexit_cancel(NULL);
- butil::thread_atexit_cancel(NULL, NULL);
+ butil::thread_atexit_cancel(nullptr);
+ butil::thread_atexit_cancel(nullptr, nullptr);
ASSERT_EQ(0, butil::thread_atexit(check_result));
@@ -192,12 +192,12 @@ TEST_F(BaiduThreadLocalTest, call_order_and_cancel) {
ASSERT_EQ(0, butil::thread_atexit(fun3, (void*)1));
ASSERT_EQ(0, butil::thread_atexit(fun3, (void*)1));
ASSERT_EQ(0, butil::thread_atexit(fun3, (void*)2));
- ASSERT_EQ(0, butil::thread_atexit(fun4, NULL));
+ ASSERT_EQ(0, butil::thread_atexit(fun4, nullptr));
- butil::thread_atexit_cancel(NULL);
- butil::thread_atexit_cancel(NULL, NULL);
+ butil::thread_atexit_cancel(nullptr);
+ butil::thread_atexit_cancel(nullptr, nullptr);
butil::thread_atexit_cancel(fun1);
- butil::thread_atexit_cancel(fun3, NULL);
+ butil::thread_atexit_cancel(fun3, nullptr);
butil::thread_atexit_cancel(fun3, (void*)1);
}
diff --git a/test/baidu_time_unittest.cpp b/test/baidu_time_unittest.cpp
index d5741895..72448b07 100644
--- a/test/baidu_time_unittest.cpp
+++ b/test/baidu_time_unittest.cpp
@@ -89,7 +89,7 @@ TEST(BaiduTimeTest, cost_of_timer) {
t1.start();
for (size_t i = 0; i < N; ++i) {
- time(NULL);
+ time(nullptr);
}
t1.stop();
printf("time(NULL) takes %" PRId64 "ns\n", t1.n_elapsed() / N);
diff --git a/test/bounded_queue_unittest.cc b/test/bounded_queue_unittest.cc
index 556e84ed..4185f386 100644
--- a/test/bounded_queue_unittest.cc
+++ b/test/bounded_queue_unittest.cc
@@ -29,8 +29,8 @@ TEST(BoundedQueueTest, sanity) {
butil::BoundedQueue<int> q(storage, sizeof(storage), butil::NOT_OWN_STORAGE);
ASSERT_EQ(0ul, q.size());
ASSERT_TRUE(q.empty());
- ASSERT_TRUE(NULL == q.top());
- ASSERT_TRUE(NULL == q.bottom());
+ ASSERT_TRUE(nullptr == q.top());
+ ASSERT_TRUE(nullptr == q.bottom());
for (int i = 1; i <= N; ++i) {
if (i % 2 == 0) {
ASSERT_TRUE(q.push(i));
diff --git a/test/brpc_block_pool_unittest.cpp b/test/brpc_block_pool_unittest.cpp
index f65f2a00..28b9d553 100644
--- a/test/brpc_block_pool_unittest.cpp
+++ b/test/brpc_block_pool_unittest.cpp
@@ -60,30 +60,30 @@ TEST_F(BlockPoolTest, single_thread) {
void* buf[num];
for (size_t i = 0; i < num; ++i) {
buf[i] = AllocBlock(GetBlockSize(0));
- EXPECT_TRUE(buf[i] != NULL);
+ EXPECT_TRUE(buf[i] != nullptr);
EXPECT_EQ(0, GetBlockType(buf[i]));
}
for (size_t i = 0; i < num; ++i) {
DeallocBlock(buf[i]);
- buf[i] = NULL;
+ buf[i] = nullptr;
}
for (size_t i = 0; i < num; ++i) {
buf[i] = AllocBlock(GetBlockSize(0) + 1);
- EXPECT_TRUE(buf[i] != NULL);
+ EXPECT_TRUE(buf[i] != nullptr);
EXPECT_EQ(1, GetBlockType(buf[i]));
}
for (int i = num - 1; i >= 0; --i) {
DeallocBlock(buf[i]);
- buf[i] = NULL;
+ buf[i] = nullptr;
}
for (size_t i = 0; i < num; ++i) {
buf[i] = AllocBlock(GetBlockSize(2));
- EXPECT_TRUE(buf[i] != NULL);
+ EXPECT_TRUE(buf[i] != nullptr);
EXPECT_EQ(2, GetBlockType(buf[i]));
}
for (int i = num - 1; i >= 0; --i) {
DeallocBlock(buf[i]);
- buf[i] = NULL;
+ buf[i] = nullptr;
}
DestroyBlockPool();
@@ -95,12 +95,12 @@ static void* AllocAndDealloc(void* arg) {
int iterations = 1000;
while (iterations > 0) {
void* buf = AllocBlock(len);
- EXPECT_TRUE(buf != NULL);
+ EXPECT_TRUE(buf != nullptr);
EXPECT_EQ(i % 3, GetBlockType(buf));
DeallocBlock(buf);
--iterations;
}
- return NULL;
+ return nullptr;
}
TEST_F(BlockPoolTest, multiple_thread) {
@@ -137,7 +137,7 @@ TEST_F(BlockPoolTest, extend) {
void* buf[num];
for (size_t i = 0; i < num; ++i) {
buf[i] = AllocBlock(65537);
- EXPECT_TRUE(buf[i] != NULL);
+ EXPECT_TRUE(buf[i] != nullptr);
}
EXPECT_EQ(16, GetRegionNum());
for (size_t i = 0; i < num; ++i) {
@@ -160,7 +160,7 @@ TEST_F(BlockPoolTest, memory_not_enough) {
void* buf[num];
for (size_t i = 0; i < num; ++i) {
buf[i] = AllocBlock(65537);
- EXPECT_TRUE(buf[i] != NULL);
+ EXPECT_TRUE(buf[i] != nullptr);
}
EXPECT_EQ(2, GetRegionNum());
void* tmp = AllocBlock(65536);
@@ -182,15 +182,15 @@ TEST_F(BlockPoolTest, invalid_use) {
EXPECT_TRUE(InitBlockPool(DummyCallback));
void* buf = AllocBlock(0);
- EXPECT_EQ(NULL, buf);
+ EXPECT_EQ(nullptr, buf);
EXPECT_EQ(EINVAL, errno);
buf = AllocBlock(GetBlockSize(2) + 1);
- EXPECT_EQ(NULL, buf);
+ EXPECT_EQ(nullptr, buf);
EXPECT_EQ(EINVAL, errno);
errno = 0;
- DeallocBlock(NULL);
+ DeallocBlock(nullptr);
EXPECT_EQ(EINVAL, errno);
DestroyBlockPool();
diff --git a/test/brpc_builtin_service_unittest.cpp b/test/brpc_builtin_service_unittest.cpp
index da4d6f10..e4f61e70 100644
--- a/test/brpc_builtin_service_unittest.cpp
+++ b/test/brpc_builtin_service_unittest.cpp
@@ -236,7 +236,7 @@ protected:
SetUpController(&cntl, use_html);
butil::EndPoint ep;
ASSERT_EQ(0, str2endpoint("127.0.0.1:9798", &ep));
- ASSERT_EQ(0, _server.Start(ep, NULL));
+ ASSERT_EQ(0, _server.Start(ep, nullptr));
int self_port = -1;
const int cfd = tcp_connect(ep, &self_port);
ASSERT_GT(cfd, 0);
@@ -388,9 +388,9 @@ protected:
brpc::SERVER_OWNS_SERVICE));
butil::EndPoint ep;
ASSERT_EQ(0, str2endpoint("127.0.0.1:9748", &ep));
- ASSERT_EQ(0, _server.Start(ep, NULL));
+ ASSERT_EQ(0, _server.Start(ep, nullptr));
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init(ep, NULL));
+ ASSERT_EQ(0, channel.Init(ep, nullptr));
test::EchoService_Stub stub(&channel);
int64_t log_id = 1234567890;
char querystr_buf[128];
@@ -402,7 +402,7 @@ protected:
brpc::Controller echo_cntl;
echo_req.set_message("hello");
echo_cntl.set_log_id(++log_id);
- stub.Echo(&echo_cntl, &echo_req, &echo_res, NULL);
+ stub.Echo(&echo_cntl, &echo_req, &echo_res, nullptr);
EXPECT_FALSE(echo_cntl.Failed());
// Wait for level db to commit span information
@@ -426,7 +426,7 @@ protected:
echo_req.set_message("hello");
echo_req.set_sleep_us(150000);
echo_cntl.set_log_id(++log_id);
- stub.Echo(&echo_cntl, &echo_req, &echo_res, NULL);
+ stub.Echo(&echo_cntl, &echo_req, &echo_res, nullptr);
EXPECT_FALSE(echo_cntl.Failed());
// Wait for level db to commit span information
@@ -450,7 +450,7 @@ protected:
std::string request_str(1500, 'a');
echo_req.set_message(request_str);
echo_cntl.set_log_id(++log_id);
- stub.Echo(&echo_cntl, &echo_req, &echo_res, NULL);
+ stub.Echo(&echo_cntl, &echo_req, &echo_res, nullptr);
EXPECT_FALSE(echo_cntl.Failed());
// Wait for level db to commit span information
@@ -473,7 +473,7 @@ protected:
brpc::Controller echo_cntl;
echo_req.set_message("hello");
echo_cntl.set_log_id(++log_id);
- stub.Echo(&echo_cntl, &echo_req, &echo_res, NULL);
+ stub.Echo(&echo_cntl, &echo_req, &echo_res, nullptr);
EXPECT_FALSE(echo_cntl.Failed());
// Wait for level db to commit span information
@@ -560,7 +560,7 @@ TEST_F(BuiltinServiceTest, customized_health) {
ASSERT_EQ(0, chan.Init("127.0.0.1:9798", &copt));
brpc::Controller cntl;
cntl.http_request().uri() = "/health";
- chan.CallMethod(NULL, &cntl, &req, &res, NULL);
+ chan.CallMethod(nullptr, &cntl, &req, &res, nullptr);
EXPECT_FALSE(cntl.Failed()) << cntl.ErrorText();
EXPECT_EQ("i'm ok", cntl.response_attachment());
}
@@ -597,14 +597,14 @@ TEST_F(BuiltinServiceTest, normal_grpc_health) {
brpc::Channel chan;
ASSERT_EQ(0, chan.Init("127.0.0.1:9798", &copt));
grpc::health::v1::Health_Stub stub(&chan);
- stub.Check(&cntl, &request, &response, NULL);
+ stub.Check(&cntl, &request, &response, nullptr);
EXPECT_FALSE(cntl.Failed()) << cntl.ErrorText();
EXPECT_EQ(response.status(), grpc::health::v1::HealthCheckResponse_ServingStatus_SERVING);
response.Clear();
brpc::Controller cntl1;
cntl1.http_request().uri() = "/grpc.health.v1.Health/Check";
- chan.CallMethod(NULL, &cntl1, &request, &response, NULL);
+ chan.CallMethod(nullptr, &cntl1, &request, &response, nullptr);
EXPECT_FALSE(cntl.Failed()) << cntl.ErrorText();
EXPECT_EQ(response.status(), grpc::health::v1::HealthCheckResponse_ServingStatus_SERVING);
}
@@ -626,7 +626,7 @@ TEST_F(BuiltinServiceTest, customized_grpc_health) {
ASSERT_EQ(0, chan.Init("127.0.0.1:9798", &copt));
grpc::health::v1::Health_Stub stub(&chan);
- stub.Check(&cntl, &request, &response, NULL);
+ stub.Check(&cntl, &request, &response, nullptr);
EXPECT_FALSE(cntl.Failed()) << cntl.ErrorText();
EXPECT_EQ(response.status(), grpc::health::v1::HealthCheckResponse_ServingStatus_UNKNOWN);
@@ -653,7 +653,7 @@ TEST_F(BuiltinServiceTest, list) {
void* sleep_thread(void*) {
sleep(1);
- return NULL;
+ return nullptr;
}
TEST_F(BuiltinServiceTest, threads) {
@@ -663,12 +663,12 @@ TEST_F(BuiltinServiceTest, threads) {
brpc::Controller cntl;
ClosureChecker done;
pthread_t tid;
- ASSERT_EQ(0, pthread_create(&tid, NULL, sleep_thread, NULL));
+ ASSERT_EQ(0, pthread_create(&tid, nullptr, sleep_thread, nullptr));
service.default_method(&cntl, &req, &res, &done);
EXPECT_FALSE(cntl.Failed());
// Doesn't work under gcc 4.8.2
// CheckContent(cntl, "sleep_thread");
- pthread_join(tid, NULL);
+ pthread_join(tid, nullptr);
}
TEST_F(BuiltinServiceTest, vlog) {
@@ -693,7 +693,7 @@ TEST_F(BuiltinServiceTest, bad_method) {
TEST_F(BuiltinServiceTest, vars) {
// Start server to show bvars inside
- ASSERT_EQ(0, _server.Start("127.0.0.1:9798", NULL));
+ ASSERT_EQ(0, _server.Start("127.0.0.1:9798", nullptr));
brpc::VarsService service;
brpc::VarsRequest req;
brpc::VarsResponse res;
@@ -734,7 +734,7 @@ TEST_F(BuiltinServiceTest, pprof) {
ClosureChecker done;
brpc::Controller cntl;
cntl.http_request().uri().SetQuery("seconds", "1");
- service.profile(&cntl, NULL, NULL, &done);
+ service.profile(&cntl, nullptr, nullptr, &done);
// Just for loading symbols in gperftools/profiler.h
ProfilerFlush();
EXPECT_FALSE(cntl.Failed()) << cntl.ErrorText();
@@ -743,28 +743,28 @@ TEST_F(BuiltinServiceTest, pprof) {
{
ClosureChecker done;
brpc::Controller cntl;
- service.heap(&cntl, NULL, NULL, &done);
+ service.heap(&cntl, nullptr, nullptr, &done);
const int rc = getenv("TCMALLOC_SAMPLE_PARAMETER") != nullptr ? 0 : brpc::ENOMETHOD;
EXPECT_EQ(rc, cntl.ErrorCode()) << cntl.ErrorText();
}
{
ClosureChecker done;
brpc::Controller cntl;
- service.growth(&cntl, NULL, NULL, &done);
+ service.growth(&cntl, nullptr, nullptr, &done);
// linked tcmalloc in UT
EXPECT_EQ(0, cntl.ErrorCode()) << cntl.ErrorText();
}
{
ClosureChecker done;
brpc::Controller cntl;
- service.symbol(&cntl, NULL, NULL, &done);
+ service.symbol(&cntl, nullptr, nullptr, &done);
EXPECT_FALSE(cntl.Failed());
CheckContent(cntl, "num_symbols");
}
{
ClosureChecker done;
brpc::Controller cntl;
- service.cmdline(&cntl, NULL, NULL, &done);
+ service.cmdline(&cntl, nullptr, nullptr, &done);
EXPECT_FALSE(cntl.Failed());
CheckContent(cntl, "brpc_builtin_service_unittest");
}
@@ -832,7 +832,7 @@ TEST_F(BuiltinServiceTest, ids) {
}
{
bthread_id_t id;
- EXPECT_EQ(0, bthread_id_create(&id, NULL, NULL));
+ EXPECT_EQ(0, bthread_id_create(&id, nullptr, nullptr));
ClosureChecker done;
brpc::Controller cntl;
std::string id_string;
@@ -846,7 +846,7 @@ TEST_F(BuiltinServiceTest, ids) {
void* dummy_bthread(void*) {
bthread_usleep(1000000);
- return NULL;
+ return nullptr;
}
@@ -858,7 +858,7 @@ void* bthread_trace(void*) {
while (!g_bthread_trace_stop) {
bthread_usleep(1000 * 100);
}
- return NULL;
+ return nullptr;
}
#endif // BRPC_BTHREAD_TRACER
@@ -919,7 +919,7 @@ TEST_F(BuiltinServiceTest, bthreads) {
}
{
bthread_t th;
- EXPECT_EQ(0, bthread_start_background(&th, NULL, dummy_bthread, NULL));
+ EXPECT_EQ(0, bthread_start_background(&th, nullptr, dummy_bthread, nullptr));
ClosureChecker done;
brpc::Controller cntl;
std::string id_string;
@@ -934,7 +934,7 @@ TEST_F(BuiltinServiceTest, bthreads) {
bool ok = false, check_all_ok = false;
for (int i = 0; i < 10; ++i) {
bthread_t th;
- EXPECT_EQ(0, bthread_start_background(&th, NULL, bthread_trace, NULL));
+ EXPECT_EQ(0, bthread_start_background(&th, nullptr, bthread_trace, nullptr));
while (!g_bthread_trace_start) {
bthread_usleep(1000 * 10);
}
@@ -952,7 +952,7 @@ TEST_F(BuiltinServiceTest, bthreads) {
content.find("bthread_trace") != std::string::npos;
check_all_ok = check_all_bthreads(th, true) && check_all_bthreads(th, false);
g_bthread_trace_stop = true;
- bthread_join(th, NULL);
+ bthread_join(th, nullptr);
// the `bthread_trace` bthread should not be queried now
EXPECT_TRUE(!check_all_bthreads(th, true) && !check_all_bthreads(th, false));
if (ok && check_all_ok) {
diff --git a/test/brpc_channel_unittest.cpp b/test/brpc_channel_unittest.cpp
index 6f4540d6..997859ef 100644
--- a/test/brpc_channel_unittest.cpp
+++ b/test/brpc_channel_unittest.cpp
@@ -71,7 +71,7 @@ namespace {
void* RunClosure(void* arg) {
google::protobuf::Closure* done = (google::protobuf::Closure*)arg;
done->Run();
- return NULL;
+ return nullptr;
}
void MarkCalled(bool* called) {
@@ -127,7 +127,7 @@ static bool VerifyMyRequest(const brpc::InputMessageBase* msg_base) {
if (meta.has_authentication_data()) {
// Credential MUST only appear in the first packet
- EXPECT_TRUE(NULL == ptr->auth_context());
+ EXPECT_TRUE(nullptr == ptr->auth_context());
EXPECT_EQ(meta.authentication_data(), MOCK_CREDENTIAL);
MyAuthenticator authenticator;
return authenticator.VerifyCredential(
@@ -267,8 +267,8 @@ protected:
{ brpc::policy::ParseRpcMessage,
brpc::SerializeRequestDefault,
brpc::policy::PackRpcRequest,
- NULL, ProcessRpcRequest,
- VerifyMyRequest, NULL, NULL,
+ nullptr, ProcessRpcRequest,
+ VerifyMyRequest, nullptr, nullptr,
brpc::CONNECTION_TYPE_ALL, "baidu_std" };
ASSERT_EQ(0, RegisterProtocol((brpc::ProtocolType)30, dummy_protocol));
}
@@ -321,7 +321,7 @@ protected:
int64_t, brpc::Controller*, brpc::RpcPBMessages*, const brpc::Server*,
brpc::MethodStatus*, int64_t, std::shared_ptr<brpc::Span>>(
&brpc::policy::SendRpcResponse, meta.correlation_id(), cntl,
- messages, &ts->_dummy, NULL, -1, nullptr);
+ messages, &ts->_dummy, nullptr, -1, nullptr);
ts->_svc.CallMethod(method, cntl, req, res, done);
}
@@ -334,7 +334,7 @@ protected:
return -1;
}
}
- if (_messenger.StartAccept(listening_fd, -1, NULL, false) != 0) {
+ if (_messenger.StartAccept(listening_fd, -1, nullptr, false) != 0) {
return -1;
}
return 0;
@@ -348,7 +348,7 @@ protected:
void SetUpChannel(brpc::Channel* channel,
bool single_server,
bool short_connection,
- const brpc::Authenticator* auth = NULL,
+ const brpc::Authenticator* auth = nullptr,
std::string connection_group = std::string(),
bool use_backup_request_policy = false,
brpc::ProtocolType protocol = brpc::PROTOCOL_BAIDU_STD) {
@@ -374,7 +374,7 @@ protected:
brpc::Controller* cntl,
test::EchoRequest* req, test::EchoResponse* res,
bool async, bool destroy = false) {
- google::protobuf::Closure* done = NULL;
+ google::protobuf::Closure* done = nullptr;
brpc::CallId sync_id = { 0 };
if (async) {
sync_id = cntl->call_id();
@@ -394,7 +394,7 @@ protected:
brpc::Controller* cntl,
test::ComboRequest* req, test::ComboResponse* res,
bool async, bool destroy = false) {
- google::protobuf::Closure* done = NULL;
+ google::protobuf::Closure* done = nullptr;
brpc::CallId sync_id = { 0 };
if (async) {
sync_id = cntl->call_id();
@@ -441,7 +441,7 @@ protected:
SetUpChannel(&subchans[i], single_server, short_connection);
ASSERT_EQ(0, channel.AddChannel(
&subchans[i], brpc::DOESNT_OWN_CHANNEL,
- NULL, NULL));
+ nullptr, nullptr));
}
brpc::Controller cntl;
@@ -469,7 +469,7 @@ protected:
for (size_t i = 0; i < NCHANS; ++i) {
brpc::Channel* subchan = new brpc::Channel;
SetUpChannel(subchan, single_server, short_connection);
- ASSERT_EQ(0, channel.AddChannel(subchan, NULL)) << "i=" << i;
+ ASSERT_EQ(0, channel.AddChannel(subchan, nullptr)) << "i=" << i;
}
brpc::Controller cntl;
@@ -504,9 +504,9 @@ protected:
<< single_server << ", " << async << ", " << short_connection;
const uint64_t receiving_socket_id = res.receiving_socket_id();
EXPECT_EQ(0, cntl.sub_count());
- EXPECT_TRUE(NULL == cntl.sub(-1));
- EXPECT_TRUE(NULL == cntl.sub(0));
- EXPECT_TRUE(NULL == cntl.sub(1));
+ EXPECT_TRUE(nullptr == cntl.sub(-1));
+ EXPECT_TRUE(nullptr == cntl.sub(0));
+ EXPECT_TRUE(nullptr == cntl.sub(1));
EXPECT_EQ("received " + std::string(__FUNCTION__), res.message());
if (short_connection) {
// Sleep to let `_messenger' detect `Socket' being `SetFailed'
@@ -534,7 +534,7 @@ protected:
// A different connection_group does not reuse the connection
brpc::Channel channel3;
SetUpChannel(&channel3, single_server, short_connection,
- NULL, "another_group");
+ nullptr, "another_group");
cntl.Reset();
req.Clear();
res.Clear();
@@ -549,7 +549,7 @@ protected:
// note that the leading/trailing spaces should be trimed.
brpc::Channel channel4;
SetUpChannel(&channel4, single_server, short_connection,
- NULL, " another_group ");
+ nullptr, " another_group ");
cntl.Reset();
req.Clear();
res.Clear();
@@ -601,7 +601,7 @@ protected:
dynamic_cast<const test::ComboRequest*>(req_base);
test::ComboResponse* res = dynamic_cast<test::ComboResponse*>(res_base);
if (method->name() != "ComboEcho" ||
- res == NULL || req == NULL ||
+ res == nullptr || req == nullptr ||
req->requests_size() <= channel_index) {
return brpc::SubCall::Bad();
}
@@ -649,7 +649,7 @@ protected:
SetUpChannel(&subchans[i], single_server, short_connection);
ASSERT_EQ(0, channel.AddChannel(
&subchans[i], brpc::DOESNT_OWN_CHANNEL,
- new SetCode, NULL));
+ new SetCode, nullptr));
}
brpc::Controller cntl;
test::EchoRequest req;
@@ -700,7 +700,7 @@ protected:
subchan,
// subchan should be deleted (for only once)
((i % 2) ? brpc::DOESNT_OWN_CHANNEL : brpc::OWNS_CHANNEL),
- set_code, NULL));
+ set_code, nullptr));
}
ASSERT_EQ((int)NCHANS, set_code->ref_count());
brpc::Controller cntl;
@@ -747,7 +747,7 @@ protected:
for (size_t i = 0; i < NCHANS; ++i) {
brpc::Channel* subchan = new brpc::Channel;
SetUpChannel(subchan, single_server, short_connection);
- ASSERT_EQ(0, channel.AddChannel(subchan, NULL)) << "i=" << i;
+ ASSERT_EQ(0, channel.AddChannel(subchan, nullptr)) << "i=" << i;
}
brpc::Controller cntl;
test::EchoRequest req;
@@ -790,7 +790,7 @@ protected:
SetUpChannel(&subchans[i], single_server, short_connection);
ASSERT_EQ(0, channel.AddChannel(
&subchans[i], brpc::DOESNT_OWN_CHANNEL,
- new SetCodeOnEven, NULL));
+ new SetCodeOnEven, nullptr));
}
brpc::Controller cntl;
test::EchoRequest req;
@@ -804,7 +804,7 @@ protected:
EXPECT_EQ(NCHANS, (size_t)cntl.sub_count());
for (int i = 0; i < cntl.sub_count(); ++i) {
if (i % 2) {
- EXPECT_TRUE(NULL == cntl.sub(i)) << "i=" << i;
+ EXPECT_TRUE(nullptr == cntl.sub(i)) << "i=" << i;
} else {
EXPECT_TRUE(cntl.sub(i) && !cntl.sub(i)->Failed()) << "i=" << i;
}
@@ -904,7 +904,7 @@ protected:
for (size_t i = 0; i < NCHANS; ++i) {
SetUpChannel(&subchans[i], single_server, short_connection);
ASSERT_EQ(0, channel.AddChannel(
- &subchans[i], brpc::DOESNT_OWN_CHANNEL, fast_call_mapper, NULL));
+ &subchans[i], brpc::DOESNT_OWN_CHANNEL, fast_call_mapper, nullptr));
}
brpc::Controller cntl;
test::EchoRequest req;
@@ -952,7 +952,7 @@ protected:
}
LOG(INFO) << "Start to cancel cid=" << arg->cid.value;
brpc::StartCancel(arg->cid);
- return NULL;
+ return nullptr;
}
@@ -993,7 +993,7 @@ protected:
SetUpChannel(&subchans[i], single_server, short_connection);
ASSERT_EQ(0, channel.AddChannel(
&subchans[i], brpc::DOESNT_OWN_CHANNEL,
- NULL, NULL));
+ nullptr, nullptr));
}
brpc::Controller cntl;
@@ -1006,8 +1006,8 @@ protected:
CallMethod(&channel, &cntl, &req, &res, async);
EXPECT_EQ(ECANCELED, cntl.ErrorCode()) << cntl.ErrorText();
EXPECT_EQ(NCHANS, (size_t)cntl.sub_count());
- EXPECT_TRUE(NULL == cntl.sub(1));
- EXPECT_TRUE(NULL == cntl.sub(0));
+ EXPECT_TRUE(nullptr == cntl.sub(1));
+ EXPECT_TRUE(nullptr == cntl.sub(0));
StopAndJoin();
}
@@ -1021,11 +1021,11 @@ protected:
const size_t NCHANS = 8;
brpc::SelectiveChannel channel;
- ASSERT_EQ(0, channel.Init("rr", NULL));
+ ASSERT_EQ(0, channel.Init("rr", nullptr));
for (size_t i = 0; i < NCHANS; ++i) {
brpc::Channel* subchan = new brpc::Channel;
SetUpChannel(subchan, single_server, short_connection);
- ASSERT_EQ(0, channel.AddChannel(subchan, NULL)) << "i=" << i;
+ ASSERT_EQ(0, channel.AddChannel(subchan, nullptr)) << "i=" << i;
}
brpc::Controller cntl;
@@ -1058,18 +1058,18 @@ protected:
ASSERT_TRUE(cid.value != 0);
pthread_t th;
CancelerArg carg = { 10000, cid };
- ASSERT_EQ(0, pthread_create(&th, NULL, Canceler, &carg));
+ ASSERT_EQ(0, pthread_create(&th, nullptr, Canceler, &carg));
req.set_sleep_us(carg.sleep_before_cancel_us * 2);
butil::Timer tm;
tm.start();
CallMethod(&channel, &cntl, &req, &res, async);
tm.stop();
EXPECT_LT(labs(tm.u_elapsed() - carg.sleep_before_cancel_us), 10000);
- ASSERT_EQ(0, pthread_join(th, NULL));
+ ASSERT_EQ(0, pthread_join(th, nullptr));
EXPECT_EQ(ECANCELED, cntl.ErrorCode());
EXPECT_EQ(0, cntl.sub_count());
- EXPECT_TRUE(NULL == cntl.sub(1));
- EXPECT_TRUE(NULL == cntl.sub(0));
+ EXPECT_TRUE(nullptr == cntl.sub(1));
+ EXPECT_TRUE(nullptr == cntl.sub(0));
StopAndJoin();
}
@@ -1088,7 +1088,7 @@ protected:
SetUpChannel(&subchans[i], single_server, short_connection);
ASSERT_EQ(0, channel.AddChannel(
&subchans[i], brpc::DOESNT_OWN_CHANNEL,
- NULL, NULL));
+ nullptr, nullptr));
}
brpc::Controller cntl;
@@ -1099,14 +1099,14 @@ protected:
ASSERT_TRUE(cid.value != 0);
pthread_t th;
CancelerArg carg = { 10000, cid };
- ASSERT_EQ(0, pthread_create(&th, NULL, Canceler, &carg));
+ ASSERT_EQ(0, pthread_create(&th, nullptr, Canceler, &carg));
req.set_sleep_us(carg.sleep_before_cancel_us * 2);
butil::Timer tm;
tm.start();
CallMethod(&channel, &cntl, &req, &res, async);
tm.stop();
EXPECT_LT(labs(tm.u_elapsed() - carg.sleep_before_cancel_us), 10000);
- ASSERT_EQ(0, pthread_join(th, NULL));
+ ASSERT_EQ(0, pthread_join(th, nullptr));
EXPECT_EQ(ECANCELED, cntl.ErrorCode());
EXPECT_EQ(NCHANS, (size_t)cntl.sub_count());
for (int i = 0; i < cntl.sub_count(); ++i) {
@@ -1126,11 +1126,11 @@ protected:
const size_t NCHANS = 8;
brpc::SelectiveChannel channel;
- ASSERT_EQ(0, channel.Init("rr", NULL));
+ ASSERT_EQ(0, channel.Init("rr", nullptr));
for (size_t i = 0; i < NCHANS; ++i) {
brpc::Channel* subchan = new brpc::Channel;
SetUpChannel(subchan, single_server, short_connection);
- ASSERT_EQ(0, channel.AddChannel(subchan, NULL)) << "i=" << i;
+ ASSERT_EQ(0, channel.AddChannel(subchan, nullptr)) << "i=" << i;
}
brpc::Controller cntl;
@@ -1141,14 +1141,14 @@ protected:
ASSERT_TRUE(cid.value != 0);
pthread_t th;
CancelerArg carg = { 10000, cid };
- ASSERT_EQ(0, pthread_create(&th, NULL, Canceler, &carg));
+ ASSERT_EQ(0, pthread_create(&th, nullptr, Canceler, &carg));
req.set_sleep_us(carg.sleep_before_cancel_us * 2);
butil::Timer tm;
tm.start();
CallMethod(&channel, &cntl, &req, &res, async);
tm.stop();
EXPECT_LT(labs(tm.u_elapsed() - carg.sleep_before_cancel_us), 10000);
- ASSERT_EQ(0, pthread_join(th, NULL));
+ ASSERT_EQ(0, pthread_join(th, nullptr));
EXPECT_EQ(ECANCELED, cntl.ErrorCode());
EXPECT_EQ(1, cntl.sub_count());
EXPECT_EQ(ECANCELED, cntl.sub(0)->ErrorCode());
@@ -1193,7 +1193,7 @@ protected:
SetUpChannel(&subchans[i], single_server, short_connection);
ASSERT_EQ(0, channel.AddChannel(
&subchans[i], brpc::DOESNT_OWN_CHANNEL,
- NULL, NULL));
+ nullptr, nullptr));
}
brpc::Controller cntl;
@@ -1272,7 +1272,7 @@ protected:
SetUpChannel(&subchans[i], single_server, short_connection);
ASSERT_EQ(0, channel.AddChannel(
&subchans[i], brpc::DOESNT_OWN_CHANNEL,
- NULL, NULL));
+ nullptr, nullptr));
}
brpc::Controller cntl;
@@ -1293,11 +1293,11 @@ protected:
const size_t NCHANS = 8;
brpc::SelectiveChannel channel;
- ASSERT_EQ(0, channel.Init("rr", NULL));
+ ASSERT_EQ(0, channel.Init("rr", nullptr));
for (size_t i = 0; i < NCHANS; ++i) {
brpc::Channel* subchan = new brpc::Channel;
SetUpChannel(subchan, single_server, short_connection);
- ASSERT_EQ(0, channel.AddChannel(subchan, NULL)) << "i=" << i;
+ ASSERT_EQ(0, channel.AddChannel(subchan, nullptr)) << "i=" << i;
}
brpc::Controller cntl;
@@ -1348,7 +1348,7 @@ protected:
SetUpChannel(&subchans[i], single_server, short_connection);
ASSERT_EQ(0, channel.AddChannel(
&subchans[i], brpc::DOESNT_OWN_CHANNEL,
- NULL, NULL));
+ nullptr, nullptr));
}
brpc::Controller cntl;
@@ -1398,7 +1398,7 @@ protected:
SetUpChannel(&subchans[i], single_server, short_connection);
ASSERT_EQ(0, channel.AddChannel(
&subchans[i], brpc::DOESNT_OWN_CHANNEL,
- ((i % 2) ? new MakeTheRequestTimeout : NULL), NULL));
+ ((i % 2) ? new MakeTheRequestTimeout : nullptr), nullptr));
}
brpc::Controller cntl;
@@ -1432,11 +1432,11 @@ protected:
const size_t NCHANS = 8;
brpc::SelectiveChannel channel;
- ASSERT_EQ(0, channel.Init("rr", NULL));
+ ASSERT_EQ(0, channel.Init("rr", nullptr));
for (size_t i = 0; i < NCHANS; ++i) {
brpc::Channel* subchan = new brpc::Channel;
SetUpChannel(subchan, single_server, short_connection);
- ASSERT_EQ(0, channel.AddChannel(subchan, NULL)) << "i=" << i;
+ ASSERT_EQ(0, channel.AddChannel(subchan, nullptr)) << "i=" << i;
}
brpc::Controller cntl;
@@ -1467,11 +1467,11 @@ protected:
const size_t NCHANS = 8;
brpc::SelectiveChannel channel;
- ASSERT_EQ(0, channel.Init("rr", NULL));
+ ASSERT_EQ(0, channel.Init("rr", nullptr));
for (size_t i = 0; i < NCHANS; ++i) {
brpc::Channel* subchan = new brpc::Channel;
SetUpChannel(subchan, single_server, short_connection);
- ASSERT_EQ(0, channel.AddChannel(subchan, NULL)) << "i=" << i;
+ ASSERT_EQ(0, channel.AddChannel(subchan, nullptr)) << "i=" << i;
}
brpc::Controller cntl;
@@ -1512,11 +1512,11 @@ protected:
const size_t NCHANS = 8;
brpc::SelectiveChannel channel;
- ASSERT_EQ(0, channel.Init("rr", NULL));
+ ASSERT_EQ(0, channel.Init("rr", nullptr));
for (size_t i = 0; i < NCHANS; ++i) {
brpc::Channel* subchan = new brpc::Channel;
SetUpChannel(subchan, false, false);
- ASSERT_EQ(0, channel.AddChannel(subchan, NULL)) << "i=" << i;
+ ASSERT_EQ(0, channel.AddChannel(subchan, nullptr)) << "i=" << i;
}
const int kRounds = 150;
@@ -1592,7 +1592,7 @@ protected:
SetUpChannel(&subchans[i], single_server, short_connection);
ASSERT_EQ(0, channel.AddChannel(
&subchans[i], brpc::DOESNT_OWN_CHANNEL,
- NULL, NULL));
+ nullptr, nullptr));
}
brpc::Controller cntl;
@@ -1624,7 +1624,7 @@ protected:
for (size_t i = 0; i < NCHANS; ++i) {
brpc::Channel* subchan = new brpc::Channel;
SetUpChannel(subchan, single_server, short_connection);
- ASSERT_EQ(0, channel.AddChannel(subchan, NULL)) << "i=" << i;
+ ASSERT_EQ(0, channel.AddChannel(subchan, nullptr)) << "i=" << i;
}
brpc::Controller cntl;
@@ -1675,7 +1675,7 @@ protected:
SetUpChannel(&subchans[i], single_server, short_connection);
ASSERT_EQ(0, channel.AddChannel(
&subchans[i], brpc::DOESNT_OWN_CHANNEL,
- NULL, NULL));
+ nullptr, nullptr));
}
brpc::Controller cntl;
@@ -1699,11 +1699,11 @@ protected:
const size_t NCHANS = 5;
brpc::SelectiveChannel channel;
- ASSERT_EQ(0, channel.Init("rr", NULL));
+ ASSERT_EQ(0, channel.Init("rr", nullptr));
for (size_t i = 0; i < NCHANS; ++i) {
brpc::Channel* subchan = new brpc::Channel;
SetUpChannel(subchan, single_server, short_connection);
- ASSERT_EQ(0, channel.AddChannel(subchan, NULL)) << "i=" << i;
+ ASSERT_EQ(0, channel.AddChannel(subchan, nullptr)) << "i=" << i;
}
brpc::Controller cntl;
@@ -1759,7 +1759,7 @@ protected:
brpc::Channel* subchan = new brpc::Channel();
SetUpChannel(subchan, single_server, short_connection);
ASSERT_EQ(0, channel->AddChannel(
- subchan, brpc::OWNS_CHANNEL, NULL, NULL));
+ subchan, brpc::OWNS_CHANNEL, nullptr, nullptr));
}
brpc::Controller cntl;
@@ -1787,11 +1787,11 @@ protected:
const size_t NCHANS = 5;
ASSERT_EQ(0, StartAccept(_ep));
brpc::SelectiveChannel* channel = new brpc::SelectiveChannel;
- ASSERT_EQ(0, channel->Init("rr", NULL));
+ ASSERT_EQ(0, channel->Init("rr", nullptr));
for (size_t i = 0; i < NCHANS; ++i) {
brpc::Channel* subchan = new brpc::Channel();
SetUpChannel(subchan, single_server, short_connection);
- ASSERT_EQ(0, channel->AddChannel(subchan, NULL));
+ ASSERT_EQ(0, channel->AddChannel(subchan, nullptr));
}
brpc::Controller cntl;
@@ -1875,11 +1875,11 @@ protected:
google::protobuf::Closure* thrd_func =
brpc::NewCallback(
this, &ChannelTest::RPCThread, (brpc::ChannelBase*)&channel, async);
- EXPECT_EQ(0, pthread_create(&tids[i], NULL,
+ EXPECT_EQ(0, pthread_create(&tids[i], nullptr,
RunClosure, thrd_func));
}
for (int i = 0; i < NUM; ++i) {
- pthread_join(tids[i], NULL);
+ pthread_join(tids[i], nullptr);
}
if (short_connection) {
@@ -1906,7 +1906,7 @@ protected:
SetUpChannel(&subchans[i], single_server, short_connection, &auth);
ASSERT_EQ(0, channel.AddChannel(
&subchans[i], brpc::DOESNT_OWN_CHANNEL,
- NULL, NULL));
+ nullptr, nullptr));
}
const int NUM = 10;
@@ -1915,11 +1915,11 @@ protected:
google::protobuf::Closure* thrd_func =
brpc::NewCallback(
this, &ChannelTest::RPCThread, (brpc::ChannelBase*)&channel, async);
- EXPECT_EQ(0, pthread_create(&tids[i], NULL,
+ EXPECT_EQ(0, pthread_create(&tids[i], nullptr,
RunClosure, thrd_func));
}
for (int i = 0; i < NUM; ++i) {
- pthread_join(tids[i], NULL);
+ pthread_join(tids[i], nullptr);
}
if (short_connection) {
@@ -1941,11 +1941,11 @@ protected:
const size_t NCHANS = 5;
brpc::SelectiveChannel channel;
- ASSERT_EQ(0, channel.Init("rr", NULL));
+ ASSERT_EQ(0, channel.Init("rr", nullptr));
for (size_t i = 0; i < NCHANS; ++i) {
brpc::Channel* subchan = new brpc::Channel;
SetUpChannel(subchan, single_server, short_connection, &auth);
- ASSERT_EQ(0, channel.AddChannel(subchan, NULL)) << "i=" << i;
+ ASSERT_EQ(0, channel.AddChannel(subchan, nullptr)) << "i=" << i;
}
const int NUM = 10;
@@ -1954,11 +1954,11 @@ protected:
google::protobuf::Closure* thrd_func =
brpc::NewCallback(
this, &ChannelTest::RPCThread, (brpc::ChannelBase*)&channel, async);
- EXPECT_EQ(0, pthread_create(&tids[i], NULL,
+ EXPECT_EQ(0, pthread_create(&tids[i], nullptr,
RunClosure, thrd_func));
}
for (int i = 0; i < NUM; ++i) {
- pthread_join(tids[i], NULL);
+ pthread_join(tids[i], nullptr);
}
if (short_connection) {
@@ -2080,7 +2080,7 @@ protected:
auto args = static_cast<TestRetryBackoffInfo*>(void_args);
args->channel_test->TestRetryBackoff(args->async, args->short_connection,
args->fixed_backoff, false);
- return NULL;
+ return nullptr;
}
void TestRetryBackoff(bool async, bool short_connection, bool fixed_backoff,
@@ -2203,7 +2203,7 @@ protected:
<< std::endl;
brpc::Channel channel;
- SetUpChannel(&channel, single_server, short_connection, NULL, "", true);
+ SetUpChannel(&channel, single_server, short_connection, nullptr, "", true);
const int RETRY_NUM = 1;
test::EchoRequest req;
@@ -2285,21 +2285,21 @@ TEST_F(ChannelTest, intrusive_ptr_sanity) {
TEST_F(ChannelTest, init_as_single_server) {
{
brpc::Channel channel;
- ASSERT_EQ(-1, channel.Init("127.0.0.1:12345:asdf", NULL));
- ASSERT_EQ(-1, channel.Init("127.0.0.1:99999", NULL));
- ASSERT_EQ(0, channel.Init("127.0.0.1:8888", NULL));
+ ASSERT_EQ(-1, channel.Init("127.0.0.1:12345:asdf", nullptr));
+ ASSERT_EQ(-1, channel.Init("127.0.0.1:99999", nullptr));
+ ASSERT_EQ(0, channel.Init("127.0.0.1:8888", nullptr));
}
{
brpc::Channel channel;
- ASSERT_EQ(-1, channel.Init("127.0.0.1asdf", 12345, NULL));
- ASSERT_EQ(-1, channel.Init("127.0.0.1", 99999, NULL));
- ASSERT_EQ(0, channel.Init("127.0.0.1", 8888, NULL));
+ ASSERT_EQ(-1, channel.Init("127.0.0.1asdf", 12345, nullptr));
+ ASSERT_EQ(-1, channel.Init("127.0.0.1", 99999, nullptr));
+ ASSERT_EQ(0, channel.Init("127.0.0.1", 8888, nullptr));
}
butil::EndPoint ep;
brpc::Channel channel;
ASSERT_EQ(0, str2endpoint("127.0.0.1:8888", &ep));
- ASSERT_EQ(0, channel.Init(ep, NULL));
+ ASSERT_EQ(0, channel.Init(ep, nullptr));
ASSERT_TRUE(channel.SingleServer());
ASSERT_EQ(ep, channel._server_address);
@@ -2310,7 +2310,7 @@ TEST_F(ChannelTest, init_as_single_server) {
const int NUM = 10;
brpc::Channel channels[NUM];
for (int i = 0; i < 10; ++i) {
- ASSERT_EQ(0, channels[i].Init(ep, NULL));
+ ASSERT_EQ(0, channels[i].Init(ep, nullptr));
// Share the same server socket
ASSERT_EQ(id, channels[i]._server_id);
}
@@ -2318,12 +2318,12 @@ TEST_F(ChannelTest, init_as_single_server) {
TEST_F(ChannelTest, init_using_unknown_naming_service) {
brpc::Channel channel;
- ASSERT_EQ(-1, channel.Init("unknown://unknown", "unknown", NULL));
+ ASSERT_EQ(-1, channel.Init("unknown://unknown", "unknown", nullptr));
}
TEST_F(ChannelTest, init_using_unexist_fns) {
brpc::Channel channel;
- ASSERT_EQ(-1, channel.Init("fiLe://no_such_file", "rr", NULL));
+ ASSERT_EQ(-1, channel.Init("fiLe://no_such_file", "rr", nullptr));
}
TEST_F(ChannelTest, init_using_empty_fns) {
@@ -2338,7 +2338,7 @@ TEST_F(ChannelTest, init_using_empty_fns) {
ASSERT_EQ(0, server_list.save("blahblah"));
// No valid address.
- ASSERT_EQ(-1, channel.Init(naming_url.c_str(), "rr", NULL));
+ ASSERT_EQ(-1, channel.Init(naming_url.c_str(), "rr", nullptr));
}
TEST_F(ChannelTest, init_using_empty_lns) {
@@ -2356,12 +2356,12 @@ TEST_F(ChannelTest, init_using_naming_service) {
ASSERT_EQ(0, server_list.save("127.0.0.1:8888"));
std::string naming_url = std::string("filE://") + server_list.fname();
// Rr are intended to test case-insensitivity.
- ASSERT_EQ(0, channel->Init(naming_url.c_str(), "Rr", NULL));
+ ASSERT_EQ(0, channel->Init(naming_url.c_str(), "Rr", nullptr));
ASSERT_FALSE(channel->SingleServer());
brpc::LoadBalancerWithNaming* lb =
dynamic_cast<brpc::LoadBalancerWithNaming*>(channel->_lb.get());
- ASSERT_TRUE(lb != NULL);
+ ASSERT_TRUE(lb != nullptr);
brpc::NamingServiceThread* ns = lb->_nsthread_ptr.get();
{
@@ -2369,10 +2369,10 @@ TEST_F(ChannelTest, init_using_naming_service) {
brpc::Channel channels[NUM];
for (int i = 0; i < NUM; ++i) {
// Share the same naming thread
- ASSERT_EQ(0, channels[i].Init(naming_url.c_str(), "rr", NULL));
+ ASSERT_EQ(0, channels[i].Init(naming_url.c_str(), "rr", nullptr));
brpc::LoadBalancerWithNaming* lb2 =
dynamic_cast<brpc::LoadBalancerWithNaming*>(channels[i]._lb.get());
- ASSERT_TRUE(lb2 != NULL);
+ ASSERT_TRUE(lb2 != nullptr);
ASSERT_EQ(ns, lb2->_nsthread_ptr.get());
}
}
@@ -2508,7 +2508,7 @@ TEST_F(ChannelTest, uninitialized_selective_channel) {
req.set_message(__FUNCTION__);
brpc::Controller sync_cntl;
- ::test::EchoService::Stub(&channel).Echo(&sync_cntl, &req, &res, NULL);
+ ::test::EchoService::Stub(&channel).Echo(&sync_cntl, &req, &res, nullptr);
EXPECT_EQ(EINVAL, sync_cntl.ErrorCode()) << sync_cntl.ErrorText();
brpc::Controller async_cntl;
@@ -2522,7 +2522,7 @@ TEST_F(ChannelTest, uninitialized_selective_channel) {
TEST_F(ChannelTest, empty_selective_channel) {
brpc::SelectiveChannel channel;
- ASSERT_EQ(0, channel.Init("rr", NULL));
+ ASSERT_EQ(0, channel.Init("rr", nullptr));
brpc::Controller cntl;
test::EchoRequest req;
@@ -2548,7 +2548,7 @@ TEST_F(ChannelTest, returns_bad_parallel) {
brpc::Channel* subchan = new brpc::Channel();
SetUpChannel(subchan, true, false);
ASSERT_EQ(0, channel.AddChannel(
- subchan, brpc::OWNS_CHANNEL, new BadCall, NULL));
+ subchan, brpc::OWNS_CHANNEL, new BadCall, nullptr));
}
brpc::Controller cntl;
@@ -2575,7 +2575,7 @@ TEST_F(ChannelTest, skip_all_channels) {
brpc::Channel* subchan = new brpc::Channel();
SetUpChannel(subchan, true, false);
ASSERT_EQ(0, channel.AddChannel(
- subchan, brpc::OWNS_CHANNEL, new SkipCall, NULL));
+ subchan, brpc::OWNS_CHANNEL, new SkipCall, nullptr));
}
brpc::Controller cntl;
@@ -2587,7 +2587,7 @@ TEST_F(ChannelTest, skip_all_channels) {
EXPECT_EQ(ECANCELED, cntl.ErrorCode()) << cntl.ErrorText();
EXPECT_EQ((int)NCHANS, cntl.sub_count());
for (int i = 0; i < cntl.sub_count(); ++i) {
- EXPECT_TRUE(NULL == cntl.sub(i)) << "i=" << i;
+ EXPECT_TRUE(nullptr == cntl.sub(i)) << "i=" << i;
}
}
@@ -2620,8 +2620,8 @@ TEST_F(ChannelTest, http_header_parallel_channels) {
brpc::ParallelChannel channel;
for (size_t i = 0; i < NCHANS; ++i) {
brpc::Channel* sub_chan = new brpc::Channel();
- SetUpChannel(sub_chan, true, false, NULL, "", false, brpc::PROTOCOL_HTTP);
- ASSERT_EQ(0, channel.AddChannel(sub_chan, brpc::OWNS_CHANNEL, new EchoHttpHeader, NULL));
+ SetUpChannel(sub_chan, true, false, nullptr, "", false, brpc::PROTOCOL_HTTP);
+ ASSERT_EQ(0, channel.AddChannel(sub_chan, brpc::OWNS_CHANNEL, new EchoHttpHeader, nullptr));
}
brpc::Controller cntl;
@@ -2635,7 +2635,7 @@ TEST_F(ChannelTest, http_header_parallel_channels) {
ASSERT_EQ((int)NCHANS, cntl.sub_count());
for (int i = 0; i < cntl.sub_count(); ++i) {
const brpc::Controller* sub_cntl = cntl.sub(i);
- ASSERT_TRUE(NULL != sub_cntl) << "i=" << i;
+ ASSERT_TRUE(nullptr != sub_cntl) << "i=" << i;
ASSERT_EQ(std::to_string(i), *sub_cntl->http_response().GetHeader(ECHO_HTTP_HEADER));
}
}
@@ -3014,7 +3014,7 @@ TEST_F(ChannelTest, retry_backoff) {
new TestRetryBackoffInfo(this, j, k, l));
// Retry backoff in bthread.
bthread_start_background(&th, &attr, TestRetryBackoffBthread, test_retry_backoff.get());
- bthread_join(th, NULL);
+ bthread_join(th, nullptr);
} else {
// Retry backoff in pthread.
TestRetryBackoff(j, k, l, true);
@@ -3049,17 +3049,17 @@ TEST_F(ChannelTest, selective_channel_ignores_late_subdone_after_timeout) {
DelayedCloseEchoService service;
brpc::Server server;
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start("127.0.0.1:0", NULL));
+ ASSERT_EQ(0, server.Start("127.0.0.1:0", nullptr));
brpc::SelectiveChannel channel;
- ASSERT_EQ(0, channel.Init("rr", NULL));
+ ASSERT_EQ(0, channel.Init("rr", nullptr));
brpc::ChannelOptions options;
options.timeout_ms = 100;
for (int i = 0; i < 2; ++i) {
brpc::Channel* sub_channel = new brpc::Channel;
ASSERT_EQ(0, sub_channel->Init(server.listen_address(), &options));
- ASSERT_EQ(0, channel.AddChannel(sub_channel, NULL));
+ ASSERT_EQ(0, channel.AddChannel(sub_channel, nullptr));
}
brpc::Controller cntl;
@@ -3088,7 +3088,7 @@ TEST_F(ChannelTest, selective_channel_ignores_late_subdone_after_timeout) {
}
TEST_F(ChannelTest, multiple_threads_single_channel) {
- srand(time(NULL));
+ srand(time(nullptr));
ASSERT_EQ(0, StartAccept(_ep));
MyAuthenticator auth;
const int NUM = 10;
@@ -3106,18 +3106,18 @@ TEST_F(ChannelTest, multiple_threads_single_channel) {
<< " async=" << async << std::endl;
brpc::Channel channel;
SetUpChannel(&channel, single_server,
- short_connection, (need_auth ? &auth : NULL));
+ short_connection, (need_auth ? &auth : nullptr));
for (int i = 0; i < NUM; ++i) {
google::protobuf::Closure* thrd_func =
brpc::NewCallback(
this, &ChannelTest::RPCThread,
(brpc::ChannelBase*)&channel,
(bool)async, COUNT);
- EXPECT_EQ(0, pthread_create(&tids[i], NULL,
+ EXPECT_EQ(0, pthread_create(&tids[i], nullptr,
RunClosure, thrd_func));
}
for (int i = 0; i < NUM; ++i) {
- pthread_join(tids[i], NULL);
+ pthread_join(tids[i], nullptr);
}
}
}
@@ -3125,7 +3125,7 @@ TEST_F(ChannelTest, multiple_threads_single_channel) {
}
TEST_F(ChannelTest, multiple_threads_multiple_channels) {
- srand(time(NULL));
+ srand(time(nullptr));
ASSERT_EQ(0, StartAccept(_ep));
MyAuthenticator auth;
const int NUM = 10;
@@ -3148,12 +3148,12 @@ TEST_F(ChannelTest, multiple_threads_multiple_channels) {
ChannelTest, ChannelTest*,
bool, bool, bool, const brpc::Authenticator*, int>
(this, &ChannelTest::RPCThread, single_server,
- async, short_connection, (need_auth ? &auth : NULL), COUNT);
- EXPECT_EQ(0, pthread_create(&tids[i], NULL,
+ async, short_connection, (need_auth ? &auth : nullptr), COUNT);
+ EXPECT_EQ(0, pthread_create(&tids[i], nullptr,
RunClosure, thrd_func));
}
for (int i = 0; i < NUM; ++i) {
- pthread_join(tids[i], NULL);
+ pthread_join(tids[i], nullptr);
}
}
}
@@ -3202,7 +3202,7 @@ TEST_F(ChannelTest, sizeof) {
brpc::Channel g_chan;
TEST_F(ChannelTest, global_channel_should_quit_successfully) {
- g_chan.Init("bns://qa-pbrpc.SAT.tjyx", "rr", NULL);
+ g_chan.Init("bns://qa-pbrpc.SAT.tjyx", "rr", nullptr);
}
TEST_F(ChannelTest, unused_call_id) {
@@ -3306,49 +3306,49 @@ class RateLimitedBackupPolicyTest : public ::testing::Test {};
TEST_F(RateLimitedBackupPolicyTest, InvalidBackupRequestMs) {
brpc::RateLimitedBackupPolicyOptions opts;
opts.backup_request_ms = -2;
- ASSERT_EQ(NULL, brpc::CreateRateLimitedBackupPolicy(opts));
+ ASSERT_EQ(nullptr, brpc::CreateRateLimitedBackupPolicy(opts));
}
TEST_F(RateLimitedBackupPolicyTest, InvalidMaxBackupRatioZero) {
brpc::RateLimitedBackupPolicyOptions opts;
opts.backup_request_ms = 100;
opts.max_backup_ratio = 0.0;
- ASSERT_EQ(NULL, brpc::CreateRateLimitedBackupPolicy(opts));
+ ASSERT_EQ(nullptr, brpc::CreateRateLimitedBackupPolicy(opts));
}
TEST_F(RateLimitedBackupPolicyTest, InvalidMaxBackupRatioNegative) {
brpc::RateLimitedBackupPolicyOptions opts;
opts.backup_request_ms = 100;
opts.max_backup_ratio = -0.1;
- ASSERT_EQ(NULL, brpc::CreateRateLimitedBackupPolicy(opts));
+ ASSERT_EQ(nullptr, brpc::CreateRateLimitedBackupPolicy(opts));
}
TEST_F(RateLimitedBackupPolicyTest, InvalidMaxBackupRatioAboveOne) {
brpc::RateLimitedBackupPolicyOptions opts;
opts.backup_request_ms = 100;
opts.max_backup_ratio = 1.001;
- ASSERT_EQ(NULL, brpc::CreateRateLimitedBackupPolicy(opts));
+ ASSERT_EQ(nullptr, brpc::CreateRateLimitedBackupPolicy(opts));
}
TEST_F(RateLimitedBackupPolicyTest, InvalidWindowSizeTooSmall) {
brpc::RateLimitedBackupPolicyOptions opts;
opts.backup_request_ms = 100;
opts.window_size_seconds = 0;
- ASSERT_EQ(NULL, brpc::CreateRateLimitedBackupPolicy(opts));
+ ASSERT_EQ(nullptr, brpc::CreateRateLimitedBackupPolicy(opts));
}
TEST_F(RateLimitedBackupPolicyTest, InvalidWindowSizeTooLarge) {
brpc::RateLimitedBackupPolicyOptions opts;
opts.backup_request_ms = 100;
opts.window_size_seconds = 3601;
- ASSERT_EQ(NULL, brpc::CreateRateLimitedBackupPolicy(opts));
+ ASSERT_EQ(nullptr, brpc::CreateRateLimitedBackupPolicy(opts));
}
TEST_F(RateLimitedBackupPolicyTest, InvalidUpdateIntervalTooSmall) {
brpc::RateLimitedBackupPolicyOptions opts;
opts.backup_request_ms = 100;
opts.update_interval_seconds = 0;
- ASSERT_EQ(NULL, brpc::CreateRateLimitedBackupPolicy(opts));
+ ASSERT_EQ(nullptr, brpc::CreateRateLimitedBackupPolicy(opts));
}
TEST_F(RateLimitedBackupPolicyTest, ValidMinusOneBackupRequestMsInherits) {
@@ -3356,8 +3356,8 @@ TEST_F(RateLimitedBackupPolicyTest, ValidMinusOneBackupRequestMsInherits) {
opts.backup_request_ms = -1;
std::unique_ptr<brpc::BackupRequestPolicy> p(
brpc::CreateRateLimitedBackupPolicy(opts));
- ASSERT_TRUE(p != NULL);
- ASSERT_EQ(-1, p->GetBackupRequestMs(NULL));
+ ASSERT_TRUE(p != nullptr);
+ ASSERT_EQ(-1, p->GetBackupRequestMs(nullptr));
}
TEST_F(RateLimitedBackupPolicyTest, ValidMaxRatioAtBoundary) {
@@ -3366,12 +3366,12 @@ TEST_F(RateLimitedBackupPolicyTest, ValidMaxRatioAtBoundary) {
opts.max_backup_ratio = 1.0;
std::unique_ptr<brpc::BackupRequestPolicy> p(
brpc::CreateRateLimitedBackupPolicy(opts));
- ASSERT_TRUE(p != NULL);
+ ASSERT_TRUE(p != nullptr);
// With max_backup_ratio=1.0 and true cold start (total==0, backup==0),
// ShouldAllow() sets ratio=0.0 (free pass). The conservative ratio=1.0
// path only applies when backup>0 but total==0 (latency spike with no
// completions yet). At absolute cold start DoBackup() must return true.
- ASSERT_TRUE(p->DoBackup(NULL)); // cold start: ratio=0.0 < 1.0, allow
+ ASSERT_TRUE(p->DoBackup(nullptr)); // cold start: ratio=0.0 < 1.0, allow
}
TEST_F(RateLimitedBackupPolicyTest, ColdStartAllowsBackup) {
@@ -3381,8 +3381,8 @@ TEST_F(RateLimitedBackupPolicyTest, ColdStartAllowsBackup) {
opts.update_interval_seconds = 1;
std::unique_ptr<brpc::BackupRequestPolicy> p(
brpc::CreateRateLimitedBackupPolicy(opts));
- ASSERT_TRUE(p != NULL);
- ASSERT_TRUE(p->DoBackup(NULL));
+ ASSERT_TRUE(p != nullptr);
+ ASSERT_TRUE(p->DoBackup(nullptr));
}
// After the first backup fires (backup_count=1, total_count=0), once the
@@ -3397,14 +3397,14 @@ TEST_F(RateLimitedBackupPolicyTest, AfterColdStartBackupSuppressedUntilRpcComple
opts.update_interval_seconds = 1;
std::unique_ptr<brpc::BackupRequestPolicy> p(
brpc::CreateRateLimitedBackupPolicy(opts));
- ASSERT_TRUE(p != NULL);
+ ASSERT_TRUE(p != nullptr);
// First call fires (cold start: total=0, backup=0 → ratio=0.0 → allow).
- ASSERT_TRUE(p->DoBackup(NULL));
+ ASSERT_TRUE(p->DoBackup(nullptr));
// Wait for the update interval to elapse so the ratio refreshes.
// After refresh: total=0 but backup=1 → conservative path sets ratio=1.0,
// which is >= max_backup_ratio (0.1), so DoBackup() must return false.
bthread_usleep(1200000); // 1.2s > update_interval_seconds=1
- ASSERT_FALSE(p->DoBackup(NULL));
+ ASSERT_FALSE(p->DoBackup(nullptr));
}
// After the ratio rises above the threshold, calling OnRPCEnd() many times
@@ -3418,24 +3418,24 @@ TEST_F(RateLimitedBackupPolicyTest, OnRPCEndDrivesRatioDownAndReAllows) {
opts.update_interval_seconds = 1;
std::unique_ptr<brpc::BackupRequestPolicy> p(
brpc::CreateRateLimitedBackupPolicy(opts));
- ASSERT_TRUE(p != NULL);
+ ASSERT_TRUE(p != nullptr);
// Fire many backup decisions so backup_count >> total_count,
// pushing the ratio above max_backup_ratio.
for (int i = 0; i < 20; ++i) {
- p->DoBackup(NULL);
+ p->DoBackup(nullptr);
}
// Wait for update interval so the ratio is refreshed above threshold.
bthread_usleep(1200000); // 1.2s
- ASSERT_FALSE(p->DoBackup(NULL));
+ ASSERT_FALSE(p->DoBackup(nullptr));
// Now complete many more RPCs than backups fired to bring ratio below 0.5.
// 20 backup decisions already counted; need total_count > 20/0.5 = 40.
for (int i = 0; i < 50; ++i) {
- p->OnRPCEnd(NULL);
+ p->OnRPCEnd(nullptr);
}
// Wait for the ratio cache to refresh.
bthread_usleep(1200000); // 1.2s
// Ratio is now ~20/50 = 0.4 < max_backup_ratio (0.5), so backup is re-allowed.
- ASSERT_TRUE(p->DoBackup(NULL));
+ ASSERT_TRUE(p->DoBackup(nullptr));
}
} //namespace
diff --git a/test/brpc_checksum_unittest.cpp b/test/brpc_checksum_unittest.cpp
index f8b86b33..7d5a2665 100644
--- a/test/brpc_checksum_unittest.cpp
+++ b/test/brpc_checksum_unittest.cpp
@@ -43,10 +43,10 @@ TEST_F(ChecksumAttachmentTest, verify_succeeds_when_body_only) {
butil::IOBuf body;
body.append("request body");
- brpc::ChecksumIn compute_in{&body, &cntl, NULL};
+ brpc::ChecksumIn compute_in{&body, &cntl, nullptr};
brpc::policy::Crc32cCompute(compute_in);
- brpc::ChecksumIn verify_in{&body, &cntl, NULL};
+ brpc::ChecksumIn verify_in{&body, &cntl, nullptr};
EXPECT_TRUE(brpc::policy::Crc32cVerify(verify_in));
}
@@ -94,7 +94,7 @@ TEST_F(ChecksumAttachmentTest, verify_fails_when_attachment_dropped) {
// ...but receiver (e.g. due to a mismatched
// request/response_checksum_attachment() setting) verifies body only.
- brpc::ChecksumIn verify_in{&body, &cntl, NULL};
+ brpc::ChecksumIn verify_in{&body, &cntl, nullptr};
EXPECT_FALSE(brpc::policy::Crc32cVerify(verify_in));
}
@@ -152,7 +152,7 @@ class ChecksumAttachmentEndToEndTest : public ::testing::Test {
protected:
void SetUp() override {
ASSERT_EQ(0, server_.AddService(&svc_, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server_.Start(port_, NULL));
+ ASSERT_EQ(0, server_.Start(port_, nullptr));
brpc::ChannelOptions options;
ASSERT_EQ(0, channel_.Init(butil::EndPoint(butil::my_ip(), port_),
&options));
@@ -180,7 +180,7 @@ TEST_F(ChecksumAttachmentEndToEndTest, request_checksum_with_attachment) {
test::EchoRequest req;
test::EchoResponse res;
req.set_message(__FUNCTION__);
- test::EchoService::Stub(&channel_).Echo(&cntl, &req, &res, NULL);
+ test::EchoService::Stub(&channel_).Echo(&cntl, &req, &res, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
EXPECT_EQ("received " + std::string(__FUNCTION__), res.message());
@@ -196,7 +196,7 @@ TEST_F(ChecksumAttachmentEndToEndTest, response_checksum_with_attachment) {
test::EchoRequest req;
test::EchoResponse res;
req.set_message(__FUNCTION__);
- test::EchoService::Stub(&channel_).Echo(&cntl, &req, &res, NULL);
+ test::EchoService::Stub(&channel_).Echo(&cntl, &req, &res, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
EXPECT_EQ("received " + std::string(__FUNCTION__), res.message());
@@ -214,7 +214,7 @@ TEST_F(ChecksumAttachmentEndToEndTest, both_directions_checksum_with_attachment)
test::EchoRequest req;
test::EchoResponse res;
req.set_message(__FUNCTION__);
- test::EchoService::Stub(&channel_).Echo(&cntl, &req, &res, NULL);
+ test::EchoService::Stub(&channel_).Echo(&cntl, &req, &res, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
EXPECT_EQ("received " + std::string(__FUNCTION__), res.message());
@@ -234,7 +234,7 @@ TEST_F(ChecksumAttachmentEndToEndTest, checksum_without_attachment_still_works)
test::EchoRequest req;
test::EchoResponse res;
req.set_message(__FUNCTION__);
- test::EchoService::Stub(&channel_).Echo(&cntl, &req, &res, NULL);
+ test::EchoService::Stub(&channel_).Echo(&cntl, &req, &res, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
EXPECT_EQ("received " + std::string(__FUNCTION__), res.message());
diff --git a/test/brpc_coroutine_unittest.cpp b/test/brpc_coroutine_unittest.cpp
index 1df2c3a0..0d549560 100644
--- a/test/brpc_coroutine_unittest.cpp
+++ b/test/brpc_coroutine_unittest.cpp
@@ -182,7 +182,7 @@ TEST_F(CoroutineTest, coroutine) {
brpc::Server server;
EchoServiceImpl service;
server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE);
- ASSERT_EQ(0, server.Start(ep, NULL));
+ ASSERT_EQ(0, server.Start(ep, nullptr));
brpc::Channel channel;
brpc::ChannelOptions options;
diff --git a/test/brpc_couchbase_unittest.cpp b/test/brpc_couchbase_unittest.cpp
index febf31c5..f6c81908 100644
--- a/test/brpc_couchbase_unittest.cpp
+++ b/test/brpc_couchbase_unittest.cpp
@@ -57,7 +57,7 @@ TEST_F(CouchbaseUnitTest, RejectOversizedResponseBeforeBufferingBody) {
couchbase_buf.append(&couchbase_header, sizeof(couchbase_header));
EXPECT_EQ(brpc::PARSE_ERROR_TOO_BIG_DATA,
brpc::policy::ParseCouchbaseMessage(
- &couchbase_buf, socket.get(), false, NULL).error());
+ &couchbase_buf, socket.get(), false, nullptr).error());
}
diff --git a/test/brpc_esp_protocol_unittest.cpp b/test/brpc_esp_protocol_unittest.cpp
index d4cab7c4..1832608b 100644
--- a/test/brpc_esp_protocol_unittest.cpp
+++ b/test/brpc_esp_protocol_unittest.cpp
@@ -78,7 +78,7 @@ protected:
brpc::policy::SerializeEspRequest(&req_buf, &cntl, &req);
butil::IOBuf packet_buf;
- brpc::policy::PackEspRequest(&packet_buf, NULL, cntl.call_id().value, NULL, &cntl, req_buf, NULL);
+ brpc::policy::PackEspRequest(&packet_buf, nullptr, cntl.call_id().value, nullptr, &cntl, req_buf, nullptr);
packet_buf.cut_into_file_descriptor(_pipe_fds[1], packet_buf.size());
}
@@ -107,7 +107,7 @@ TEST_F(EspTest, complete_flow) {
const brpc::Authenticator* auth = brpc::policy::global_esp_authenticator();
butil::IOBuf packet_buf;
- brpc::policy::PackEspRequest(&packet_buf, NULL, cntl.call_id().value, NULL, &cntl, req_buf, auth);
+ brpc::policy::PackEspRequest(&packet_buf, nullptr, cntl.call_id().value, nullptr, &cntl, req_buf, auth);
std::string auth_str;
auth->GenerateCredential(&auth_str);
@@ -121,7 +121,7 @@ TEST_F(EspTest, complete_flow) {
response_buf.append_from_file_descriptor(_pipe_fds[0], 1024);
brpc::ParseResult res_pr =
- brpc::policy::ParseEspMessage(&response_buf, NULL, false, NULL);
+ brpc::policy::ParseEspMessage(&response_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, res_pr.error());
brpc::InputMessageBase* res_msg = res_pr.message();
@@ -145,7 +145,7 @@ TEST_F(EspTest, wrong_response_head) {
response_buf.append_from_file_descriptor(_pipe_fds[0], 1024);
brpc::ParseResult res_pr =
- brpc::policy::ParseEspMessage(&response_buf, NULL, false, NULL);
+ brpc::policy::ParseEspMessage(&response_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, res_pr.error());
brpc::InputMessageBase* res_msg = res_pr.message();
diff --git a/test/brpc_event_dispatcher_unittest.cpp b/test/brpc_event_dispatcher_unittest.cpp
index dcca305f..bf3f1875 100644
--- a/test/brpc_event_dispatcher_unittest.cpp
+++ b/test/brpc_event_dispatcher_unittest.cpp
@@ -55,7 +55,7 @@ TEST_F(EventDispatcherTest, versioned_ref) {
struct UserData;
-UserData* g_user_data = NULL;
+UserData* g_user_data = nullptr;
struct UserData : public brpc::VersionedRefWithId<UserData> {
explicit UserData(Forbidden f)
@@ -72,7 +72,7 @@ struct UserData : public brpc::VersionedRefWithId<UserData> {
void BeforeRecycled() {
count.store(0, butil::memory_order_relaxed);
- g_user_data = NULL;
+ g_user_data = nullptr;
}
void BeforeAdditionalRefReleased() {
@@ -117,7 +117,7 @@ void* VRefThread(void* arg) {
while (!vref_thread_stop) {
TestVRef(id);
}
- return NULL;
+ return nullptr;
}
TEST_F(EventDispatcherTest, versioned_ref_with_id) {
@@ -140,14 +140,14 @@ TEST_F(EventDispatcherTest, versioned_ref_with_id) {
const size_t thread_num = 8;
pthread_t tid[thread_num];
for (auto& i : tid) {
- ASSERT_EQ(0, pthread_create(&i, NULL, VRefThread, (void*)id));
+ ASSERT_EQ(0, pthread_create(&i, nullptr, VRefThread, (void*)id));
}
sleep(2);
vref_thread_stop = true;
for (const auto i : tid) {
- pthread_join(i, NULL);
+ pthread_join(i, nullptr);
}
ASSERT_EQ(2, ptr->nref());
@@ -299,7 +299,7 @@ void* client_thread(void* arg) {
}
free(buf);
EXPECT_EQ(0, close(m->fd));
- return NULL;
+ return nullptr;
}
inline uint32_t fmix32 ( uint32_t h ) {
@@ -345,7 +345,7 @@ TEST_F(EventDispatcherTest, dispatch_tasks) {
cm[i]->fd = fds[i * 2 + 1];
cm[i]->times = 0;
cm[i]->bytes = 0;
- ASSERT_EQ(0, pthread_create(&cth[i], NULL, client_thread, cm[i]));
+ ASSERT_EQ(0, pthread_create(&cth[i], nullptr, client_thread, cm[i]));
}
LOG(INFO) << "Begin to profile... (5 seconds)";
@@ -369,7 +369,7 @@ TEST_F(EventDispatcherTest, dispatch_tasks) {
client_stop = true;
for (size_t i = 0; i < NCLIENT; ++i) {
- pthread_join(cth[i], NULL);
+ pthread_join(cth[i], nullptr);
}
sleep(1);
diff --git a/test/brpc_extension_unittest.cpp b/test/brpc_extension_unittest.cpp
index eea238ee..367f80aa 100644
--- a/test/brpc_extension_unittest.cpp
+++ b/test/brpc_extension_unittest.cpp
@@ -51,7 +51,7 @@ const int g_foo = 10;
const int g_bar = 20;
TEST_F(ExtensionTest, basic) {
- ConstIntExtension()->Register("foo", NULL);
+ ConstIntExtension()->Register("foo", nullptr);
ConstIntExtension()->Register("foo", &g_foo);
ConstIntExtension()->Register("bar", &g_bar);
diff --git a/test/brpc_grpc_protocol_unittest.cpp b/test/brpc_grpc_protocol_unittest.cpp
index 5a9752ea..5a1bc8df 100644
--- a/test/brpc_grpc_protocol_unittest.cpp
+++ b/test/brpc_grpc_protocol_unittest.cpp
@@ -103,7 +103,7 @@ class GrpcTest : public ::testing::Test {
protected:
GrpcTest() {
EXPECT_EQ(0, _server.AddService(&_svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- EXPECT_EQ(0, _server.Start(g_server_addr.c_str(), NULL));
+ EXPECT_EQ(0, _server.Start(g_server_addr.c_str(), nullptr));
brpc::ChannelOptions options;
options.protocol = g_protocol;
options.timeout_ms = g_timeout_ms;
@@ -126,7 +126,7 @@ protected:
req.set_return_error(false);
test::GrpcService_Stub stub(&_channel);
- stub.Method(&cntl, &req, &res, NULL);
+ stub.Method(&cntl, &req, &res, nullptr);
EXPECT_FALSE(cntl.Failed()) << cntl.ErrorCode() << ": " << cntl.ErrorText();
EXPECT_EQ(res.message(), g_prefix + g_req);
}
@@ -180,7 +180,7 @@ TEST_F(GrpcTest, return_error) {
req.set_gzip(false);
req.set_return_error(true);
test::GrpcService_Stub stub(&_channel);
- stub.Method(&cntl, &req, &res, NULL);
+ stub.Method(&cntl, &req, &res, nullptr);
EXPECT_TRUE(cntl.Failed());
EXPECT_EQ(cntl.ErrorCode(), brpc::EINTERNAL);
EXPECT_TRUE(butil::StringPiece(cntl.ErrorText()).ends_with(butil::string_printf("%s", g_prefix.c_str())));
@@ -200,7 +200,7 @@ TEST_F(GrpcTest, RpcTimedOut) {
req.set_gzip(false);
req.set_return_error(false);
test::GrpcService_Stub stub(&_channel);
- stub.MethodTimeOut(&cntl, &req, &res, NULL);
+ stub.MethodTimeOut(&cntl, &req, &res, nullptr);
EXPECT_TRUE(cntl.Failed());
EXPECT_EQ(cntl.ErrorCode(), brpc::ERPCTIMEDOUT);
}
@@ -213,7 +213,7 @@ TEST_F(GrpcTest, MethodNotExist) {
req.set_gzip(false);
req.set_return_error(false);
test::GrpcService_Stub stub(&_channel);
- stub.MethodNotExist(&cntl, &req, &res, NULL);
+ stub.MethodNotExist(&cntl, &req, &res, nullptr);
EXPECT_TRUE(cntl.Failed());
EXPECT_EQ(cntl.ErrorCode(), brpc::EINTERNAL);
ASSERT_TRUE(butil::StringPiece(cntl.ErrorText()).ends_with("Method MethodNotExist() not implemented."));
@@ -245,11 +245,11 @@ TEST_F(GrpcTest, GrpcTimeOut) {
req.set_message(g_req);
req.set_gzip(false);
req.set_return_error(false);
- req.set_timeout_us((int64_t)(strtol(timeouts[i+1], NULL, 10)));
+ req.set_timeout_us((int64_t)(strtol(timeouts[i+1], nullptr, 10)));
cntl.set_timeout_ms(-1);
cntl.http_request().SetHeader("grpc-timeout", timeouts[i]);
test::GrpcService_Stub stub(&_channel);
- stub.Method(&cntl, &req, &res, NULL);
+ stub.Method(&cntl, &req, &res, nullptr);
EXPECT_FALSE(cntl.Failed());
}
@@ -264,7 +264,7 @@ TEST_F(GrpcTest, GrpcTimeOut) {
req.set_timeout_us(9876000);
cntl.set_timeout_ms(9876);
test::GrpcService_Stub stub(&_channel);
- stub.Method(&cntl, &req, &res, NULL);
+ stub.Method(&cntl, &req, &res, nullptr);
EXPECT_FALSE(cntl.Failed());
}
@@ -278,7 +278,7 @@ TEST_F(GrpcTest, GrpcTimeOut) {
req.set_return_error(false);
req.set_timeout_us(g_timeout_ms * 1000);
test::GrpcService_Stub stub(&_channel);
- stub.Method(&cntl, &req, &res, NULL);
+ stub.Method(&cntl, &req, &res, nullptr);
EXPECT_FALSE(cntl.Failed());
}
}
diff --git a/test/brpc_h2_unsent_message_unittest.cpp b/test/brpc_h2_unsent_message_unittest.cpp
index 1c7b985a..a8cd8da2 100644
--- a/test/brpc_h2_unsent_message_unittest.cpp
+++ b/test/brpc_h2_unsent_message_unittest.cpp
@@ -248,7 +248,7 @@ TEST(H2UnsentMessage, request_throughput) {
brpc::Controller cntl;
butil::IOBuf request_buf;
cntl.http_request().uri() = "0.0.0.0:8010/HttpService/Echo";
- brpc::policy::SerializeHttpRequest(&request_buf, &cntl, NULL);
+ brpc::policy::SerializeHttpRequest(&request_buf, &cntl, nullptr);
brpc::SocketId id;
brpc::SocketUniquePtr h2_client_sock;
@@ -258,7 +258,7 @@ TEST(H2UnsentMessage, request_throughput) {
EXPECT_EQ(0, brpc::Socket::Address(id, &h2_client_sock));
brpc::policy::H2Context* ctx =
- new brpc::policy::H2Context(h2_client_sock.get(), NULL);
+ new brpc::policy::H2Context(h2_client_sock.get(), nullptr);
CHECK_EQ(ctx->Init(), 0);
h2_client_sock->initialize_parsing_context(&ctx);
ctx->_last_sent_stream_id = 0;
diff --git a/test/brpc_hpack_unittest.cpp b/test/brpc_hpack_unittest.cpp
index 48d3ae52..98d86648 100644
--- a/test/brpc_hpack_unittest.cpp
+++ b/test/brpc_hpack_unittest.cpp
@@ -49,8 +49,8 @@ TEST_F(HPackTest, many_dynamic_table_size_updates) {
const pid_t pid = fork();
ASSERT_GE(pid, 0);
if (pid == 0) {
- if (freopen("/dev/null", "w", stdout) == NULL ||
- freopen("/dev/null", "w", stderr) == NULL) {
+ if (freopen("/dev/null", "w", stdout) == nullptr ||
+ freopen("/dev/null", "w", stderr) == nullptr) {
exit(1);
}
@@ -62,15 +62,15 @@ TEST_F(HPackTest, many_dynamic_table_size_updates) {
exit(3);
}
pthread_t tid;
- if (pthread_create(&tid, &attr, DecodeManyDynamicTableSizeUpdates, NULL) != 0) {
+ if (pthread_create(&tid, &attr, DecodeManyDynamicTableSizeUpdates, nullptr) != 0) {
exit(4);
}
pthread_attr_destroy(&attr);
- void* ret = NULL;
+ void* ret = nullptr;
if (pthread_join(tid, &ret) != 0) {
exit(5);
}
- exit(ret == NULL ? 0 : 6);
+ exit(ret == nullptr ? 0 : 6);
}
int status = 0;
ASSERT_EQ(pid, waitpid(pid, &status, 0));
diff --git a/test/brpc_http_message_unittest.cpp b/test/brpc_http_message_unittest.cpp
index 9933a8d1..bd2ac5ed 100644
--- a/test/brpc_http_message_unittest.cpp
+++ b/test/brpc_http_message_unittest.cpp
@@ -151,7 +151,7 @@ TEST(HttpMessageTest, request_sanity) {
ASSERT_TRUE(header.GetHeader("log-id"));
ASSERT_EQ("456", *header.GetHeader("log-id"));
- ASSERT_TRUE(NULL != header.GetHeader("Authorization"));
+ ASSERT_TRUE(nullptr != header.GetHeader("Authorization"));
ASSERT_EQ("test", *header.GetHeader("Authorization"));
}
@@ -429,19 +429,19 @@ TEST(HttpMessageTest, find_method_property_by_uri) {
brpc::Server server;
ASSERT_EQ(0, server.AddService(new test::EchoService(),
brpc::SERVER_OWNS_SERVICE));
- ASSERT_EQ(0, server.Start(9237, NULL));
+ ASSERT_EQ(0, server.Start(9237, nullptr));
std::string unknown_method;
- brpc::Server::MethodProperty* mp = NULL;
+ brpc::Server::MethodProperty* mp = nullptr;
- mp = FindMethodPropertyByURI("", &server, NULL);
+ mp = FindMethodPropertyByURI("", &server, nullptr);
ASSERT_TRUE(mp);
ASSERT_EQ("index", mp->method->service()->name());
- mp = FindMethodPropertyByURI("/", &server, NULL);
+ mp = FindMethodPropertyByURI("/", &server, nullptr);
ASSERT_TRUE(mp);
ASSERT_EQ("index", mp->method->service()->name());
- mp = FindMethodPropertyByURI("//", &server, NULL);
+ mp = FindMethodPropertyByURI("//", &server, nullptr);
ASSERT_TRUE(mp);
ASSERT_EQ("index", mp->method->service()->name());
@@ -649,14 +649,14 @@ TEST(HttpMessageTest, serialize_http_response) {
// Content is cleared.
CHECK(content.empty());
- // NULL content
+ // nullptr content
header.SetHeader("Content-Length", "100");
- MakeRawHttpResponse(&response, &header, NULL);
+ MakeRawHttpResponse(&response, &header, nullptr);
ASSERT_EQ("HTTP/1.1 200 OK\r\nFoo: Bar\r\nContent-Length: 100\r\n\r\n", response)
<< butil::ToPrintable(response);
header.SetHeader("Transfer-Encoding", "chunked");
- MakeRawHttpResponse(&response, &header, NULL);
+ MakeRawHttpResponse(&response, &header, nullptr);
ASSERT_EQ("HTTP/1.1 200 OK\r\nFoo: Bar\r\nTransfer-Encoding: chunked\r\n\r\n", response)
<< butil::ToPrintable(response);
header.RemoveHeader("Transfer-Encoding");
@@ -669,7 +669,7 @@ TEST(HttpMessageTest, serialize_http_response) {
header.SetHeader("Content-Length", "100");
header.SetHeader("Transfer-Encoding", "chunked");
- MakeRawHttpResponse(&response, &header, NULL);
+ MakeRawHttpResponse(&response, &header, nullptr);
ASSERT_EQ("HTTP/1.1 200 OK\r\nFoo: Bar\r\nTransfer-Encoding: chunked\r\n\r\n", response)
<< butil::ToPrintable(response);
header.RemoveHeader("Transfer-Encoding");
@@ -731,7 +731,7 @@ TEST(HttpMessageTest, http_1_1_request_without_host) {
brpc::HttpMessage http_message;
ASSERT_GE(http_message.ParseFromIOBuf(request), 0);
- ASSERT_GE(http_message.ParseFromArray(NULL, 0), 0);
+ ASSERT_GE(http_message.ParseFromArray(nullptr, 0), 0);
ASSERT_TRUE(http_message.Completed());
ASSERT_EQ("text/plain", http_message.header().content_type());
}
diff --git a/test/brpc_http_rpc_protocol_unittest.cpp b/test/brpc_http_rpc_protocol_unittest.cpp
index 97de6995..df5c838f 100644
--- a/test/brpc_http_rpc_protocol_unittest.cpp
+++ b/test/brpc_http_rpc_protocol_unittest.cpp
@@ -118,7 +118,7 @@ public:
const std::string* sleep_ms_str =
cntl->http_request().uri().GetQuery("sleep_ms");
if (sleep_ms_str) {
- bthread_usleep(strtol(sleep_ms_str->data(), NULL, 10) * 1000);
+ bthread_usleep(strtol(sleep_ms_str->data(), nullptr, 10) * 1000);
}
res->set_message(EXP_RESPONSE);
}
@@ -157,7 +157,7 @@ protected:
virtual void TearDown() {};
void VerifyMessage(brpc::InputMessageBase* msg, bool expect) {
- if (msg->_socket == NULL) {
+ if (msg->_socket == nullptr) {
_socket->ReAddress(&msg->_socket);
}
msg->_arg = &_server;
@@ -183,7 +183,7 @@ protected:
void ProcessMessage(void (*process)(brpc::InputMessageBase*),
brpc::InputMessageBase* msg, bool set_eof) {
- if (msg->_socket == NULL) {
+ if (msg->_socket == nullptr) {
_socket->ReAddress(&msg->_socket);
}
msg->_arg = &_server;
@@ -203,7 +203,7 @@ protected:
test::EchoRequest req;
req.set_message(EXP_REQUEST);
butil::IOBufAsZeroCopyOutputStream req_stream(&msg->body());
- EXPECT_TRUE(json2pb::ProtoMessageToJson(req, &req_stream, NULL));
+ EXPECT_TRUE(json2pb::ProtoMessageToJson(req, &req_stream, nullptr));
return msg;
}
@@ -257,7 +257,7 @@ protected:
void CallVersion(brpc::Channel* channel, brpc::Controller* cntl) {
cntl->http_request().uri() = "/status";
cntl->http_request().set_method(brpc::HTTP_METHOD_GET);
- channel->CallMethod(NULL, cntl, NULL, NULL, NULL);
+ channel->CallMethod(nullptr, cntl, nullptr, nullptr, nullptr);
}
void CallHttpEcho(brpc::Channel* channel, brpc::Controller* cntl) {
@@ -267,7 +267,7 @@ protected:
cntl->http_request().uri() = "/EchoService/Echo";
cntl->http_request().set_method(brpc::HTTP_METHOD_POST);
cntl->http_request().set_content_type("application/json");
- channel->CallMethod(NULL, cntl, &req, &res, NULL);
+ channel->CallMethod(nullptr, cntl, &req, &res, nullptr);
}
@@ -279,7 +279,7 @@ protected:
test::EchoResponse res;
res.set_message(EXP_RESPONSE);
butil::IOBufAsZeroCopyOutputStream res_stream(&msg->body());
- EXPECT_TRUE(json2pb::ProtoMessageToJson(res, &res_stream, NULL));
+ EXPECT_TRUE(json2pb::ProtoMessageToJson(res, &res_stream, nullptr));
return msg;
}
@@ -296,7 +296,7 @@ protected:
EXPECT_EQ((ssize_t)bytes_in_pipe,
buf.append_from_file_descriptor(_pipe_fds[0], 1024));
brpc::ParseResult pr =
- brpc::policy::ParseHttpMessage(&buf, _socket.get(), false, NULL);
+ brpc::policy::ParseHttpMessage(&buf, _socket.get(), false, nullptr);
EXPECT_EQ(brpc::PARSE_OK, pr.error());
brpc::policy::HttpContext* msg =
static_cast<brpc::policy::HttpContext*>(pr.message());
@@ -314,9 +314,9 @@ protected:
ASSERT_FALSE(cntl->Failed());
brpc::policy::H2UnsentRequest* h2_req = brpc::policy::H2UnsentRequest::New(cntl);
cntl->_current_call.stream_user_data = h2_req;
- brpc::SocketMessage* socket_message = NULL;
- brpc::policy::PackH2Request(NULL, &socket_message, cntl->call_id().value,
- NULL, cntl, request_buf, NULL);
+ brpc::SocketMessage* socket_message = nullptr;
+ brpc::policy::PackH2Request(nullptr, &socket_message, cntl->call_id().value,
+ nullptr, cntl, request_buf, nullptr);
butil::Status st = socket_message->AppendAndDestroySelf(out, _h2_client_sock.get());
ASSERT_TRUE(st.ok());
*h2_stream_id = h2_req->_stream_id;
@@ -352,7 +352,7 @@ TEST_F(HttpTest, reject_oversized_http_body) {
buf.append("POST / HTTP/1.1\r\nContent-Length: 5\r\n\r\nhello");
brpc::ParseResult result =
- brpc::policy::ParseHttpMessage(&buf, _socket.get(), false, NULL);
+ brpc::policy::ParseHttpMessage(&buf, _socket.get(), false, nullptr);
EXPECT_EQ(brpc::PARSE_ERROR_NOT_ENOUGH_DATA, result.error());
int bytes_in_pipe = 0;
ASSERT_EQ(0, ioctl(_pipe_fds[0], FIONREAD, &bytes_in_pipe));
@@ -371,7 +371,7 @@ TEST_F(HttpTest, reject_oversized_chunked_http_body) {
"3\r\nabc\r\n2\r\nde\r\n0\r\n\r\n");
brpc::ParseResult result =
- brpc::policy::ParseHttpMessage(&buf, _socket.get(), false, NULL);
+ brpc::policy::ParseHttpMessage(&buf, _socket.get(), false, nullptr);
EXPECT_EQ(brpc::PARSE_ERROR_NOT_ENOUGH_DATA, result.error());
int bytes_in_pipe = 0;
ASSERT_EQ(0, ioctl(_pipe_fds[0], FIONREAD, &bytes_in_pipe));
@@ -517,7 +517,7 @@ TEST_F(HttpTest, builtin_auth_policy_on_public_and_internal_port) {
brpc::Controller cntl;
cntl.http_request().uri() = "/status";
cntl.http_request().set_method(brpc::HTTP_METHOD_GET);
- chan.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ chan.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_EQ(brpc::EHTTP, cntl.ErrorCode()) << cntl.ErrorText();
ASSERT_EQ(brpc::HTTP_STATUS_FORBIDDEN, cntl.http_response().status_code());
@@ -533,7 +533,7 @@ TEST_F(HttpTest, builtin_auth_policy_on_public_and_internal_port) {
brpc::Controller cntl;
cntl.http_request().uri() = "/status";
cntl.http_request().set_method(brpc::HTTP_METHOD_GET);
- chan.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ chan.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(brpc::HTTP_STATUS_OK, cntl.http_response().status_code());
}
@@ -670,13 +670,13 @@ TEST_F(HttpTest, complete_flow) {
brpc::policy::SerializeHttpRequest(&request_buf, &cntl, &req);
ASSERT_FALSE(cntl.Failed());
brpc::policy::PackHttpRequest(
- &total_buf, NULL, cntl.call_id().value,
+ &total_buf, nullptr, cntl.call_id().value,
cntl._method, &cntl, request_buf, &_auth);
ASSERT_FALSE(cntl.Failed());
// Verify and handle request
brpc::ParseResult req_pr =
- brpc::policy::ParseHttpMessage(&total_buf, _socket.get(), false, NULL);
+ brpc::policy::ParseHttpMessage(&total_buf, _socket.get(), false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, req_pr.error());
brpc::InputMessageBase* req_msg = req_pr.message();
VerifyMessage(req_msg, true);
@@ -686,7 +686,7 @@ TEST_F(HttpTest, complete_flow) {
butil::IOPortal response_buf;
response_buf.append_from_file_descriptor(_pipe_fds[0], 1024);
brpc::ParseResult res_pr =
- brpc::policy::ParseHttpMessage(&response_buf, _socket.get(), false, NULL);
+ brpc::policy::ParseHttpMessage(&response_buf, _socket.get(), false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, res_pr.error());
brpc::InputMessageBase* res_msg = res_pr.message();
ProcessMessage(brpc::policy::ProcessHttpResponse, res_msg, false);
@@ -699,7 +699,7 @@ TEST_F(HttpTest, chunked_uploading) {
const int port = 8923;
brpc::Server server;
EXPECT_EQ(0, server.AddService(&_svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
// Send request via curl using chunked encoding
const std::string req = "{\"message\":\"hello\"}";
@@ -755,12 +755,12 @@ public:
? brpc::FORCE_STOP : brpc::WAIT_FOR_STOP);
butil::intrusive_ptr<brpc::ProgressiveAttachment> pa
= cntl->CreateProgressiveAttachment(stop_style);
- if (pa == NULL) {
+ if (pa == nullptr) {
cntl->SetFailed("The socket was just failed");
return;
}
if (_done_place == DONE_BEFORE_CREATE_PA) {
- done_guard.reset(NULL);
+ done_guard.reset(nullptr);
}
ASSERT_GT(PA_DATA_LEN, 8u); // long enough to hold a 64-bit decimal.
char buf[PA_DATA_LEN];
@@ -782,12 +782,12 @@ public:
++c;
}
if (_done_place == DONE_AFTER_CREATE_PA_BEFORE_DESTROY_PA) {
- done_guard.reset(NULL);
+ done_guard.reset(nullptr);
}
LOG(INFO) << "Destroy pa=" << pa.get();
- pa.reset(NULL);
+ pa.reset(nullptr);
if (_done_place == DONE_AFTER_DESTROY_PA) {
- done_guard.reset(NULL);
+ done_guard.reset(nullptr);
}
}
@@ -803,7 +803,7 @@ public:
? brpc::FORCE_STOP : brpc::WAIT_FOR_STOP);
butil::intrusive_ptr<brpc::ProgressiveAttachment> pa
= cntl->CreateProgressiveAttachment(stop_style);
- if (pa == NULL) {
+ if (pa == nullptr) {
cntl->SetFailed("The socket was just failed");
return;
}
@@ -824,7 +824,7 @@ public:
// The remote client will not receive the data written to the
// progressive attachment when the controller failed.
cntl->SetFailed("Intentionally set controller failed");
- done_guard.reset(NULL);
+ done_guard.reset(nullptr);
// Return value of Write after controller has failed should
// be less than zero.
@@ -850,7 +850,7 @@ TEST_F(HttpTest, read_chunked_response_normally) {
brpc::Server server;
DownloadServiceImpl svc;
EXPECT_EQ(0, server.AddService(&svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
for (int i = 0; i < 3; ++i) {
svc.set_done_place((DonePlace)i);
@@ -860,7 +860,7 @@ TEST_F(HttpTest, read_chunked_response_normally) {
ASSERT_EQ(0, channel.Init(butil::EndPoint(butil::my_ip(), port), &options));
brpc::Controller cntl;
cntl.http_request().uri() = "/DownloadService/Download";
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
std::string expected(PA_DATA_LEN, 0);
@@ -874,7 +874,7 @@ TEST_F(HttpTest, read_failed_chunked_response) {
brpc::Server server;
DownloadServiceImpl svc;
EXPECT_EQ(0, server.AddService(&svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
brpc::Channel channel;
brpc::ChannelOptions options;
@@ -884,7 +884,7 @@ TEST_F(HttpTest, read_failed_chunked_response) {
brpc::Controller cntl;
cntl.http_request().uri() = "/DownloadService/DownloadFailed";
cntl.response_will_be_read_progressively();
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
EXPECT_TRUE(cntl.response_attachment().empty());
ASSERT_TRUE(cntl.Failed());
ASSERT_NE(cntl.ErrorText().find("HTTP/1.1 500 Internal Server Error"),
@@ -955,7 +955,7 @@ TEST_F(HttpTest, read_long_body_progressively) {
const int port = 8923;
brpc::Server server;
EXPECT_EQ(0, server.AddService(&svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
{
brpc::Channel channel;
brpc::ChannelOptions options;
@@ -965,7 +965,7 @@ TEST_F(HttpTest, read_long_body_progressively) {
brpc::Controller cntl;
cntl.response_will_be_read_progressively();
cntl.http_request().uri() = "/DownloadService/Download";
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_TRUE(cntl.response_attachment().empty());
reader.reset(new ReadBody);
@@ -1003,7 +1003,7 @@ TEST_F(HttpTest, read_short_body_progressively) {
const int NREP = 10000;
DownloadServiceImpl svc(DONE_BEFORE_CREATE_PA, NREP);
EXPECT_EQ(0, server.AddService(&svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
{
brpc::Channel channel;
brpc::ChannelOptions options;
@@ -1013,7 +1013,7 @@ TEST_F(HttpTest, read_short_body_progressively) {
brpc::Controller cntl;
cntl.response_will_be_read_progressively();
cntl.http_request().uri() = "/DownloadService/Download";
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_TRUE(cntl.response_attachment().empty());
reader.reset(new ReadBody);
@@ -1042,7 +1042,7 @@ TEST_F(HttpTest, read_progressively_after_cntl_destroys) {
const int port = 8923;
brpc::Server server;
EXPECT_EQ(0, server.AddService(&svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
{
brpc::Channel channel;
brpc::ChannelOptions options;
@@ -1052,7 +1052,7 @@ TEST_F(HttpTest, read_progressively_after_cntl_destroys) {
brpc::Controller cntl;
cntl.response_will_be_read_progressively();
cntl.http_request().uri() = "/DownloadService/Download";
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_TRUE(cntl.response_attachment().empty());
reader.reset(new ReadBody);
@@ -1088,7 +1088,7 @@ TEST_F(HttpTest, read_progressively_after_long_delay) {
const int port = 8923;
brpc::Server server;
EXPECT_EQ(0, server.AddService(&svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
{
brpc::Channel channel;
brpc::ChannelOptions options;
@@ -1098,7 +1098,7 @@ TEST_F(HttpTest, read_progressively_after_long_delay) {
brpc::Controller cntl;
cntl.response_will_be_read_progressively();
cntl.http_request().uri() = "/DownloadService/Download";
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_TRUE(cntl.response_attachment().empty());
LOG(INFO) << "Sleep 3 seconds to make PA at server-side full";
@@ -1136,7 +1136,7 @@ TEST_F(HttpTest, skip_progressive_reading) {
const int port = 8923;
brpc::Server server;
EXPECT_EQ(0, server.AddService(&svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
brpc::Channel channel;
brpc::ChannelOptions options;
options.protocol = brpc::PROTOCOL_HTTP;
@@ -1145,7 +1145,7 @@ TEST_F(HttpTest, skip_progressive_reading) {
brpc::Controller cntl;
cntl.response_will_be_read_progressively();
cntl.http_request().uri() = "/DownloadService/Download";
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_TRUE(cntl.response_attachment().empty());
}
@@ -1177,7 +1177,7 @@ TEST_F(HttpTest, failed_on_read_one_part) {
DownloadServiceImpl svc(DONE_BEFORE_CREATE_PA,
std::numeric_limits<size_t>::max());
EXPECT_EQ(0, server.AddService(&svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
brpc::Channel channel;
brpc::ChannelOptions options;
options.protocol = brpc::PROTOCOL_HTTP;
@@ -1186,7 +1186,7 @@ TEST_F(HttpTest, failed_on_read_one_part) {
brpc::Controller cntl;
cntl.response_will_be_read_progressively();
cntl.http_request().uri() = "/DownloadService/Download";
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_TRUE(cntl.response_attachment().empty());
cntl.ReadProgressiveAttachmentBy(new AlwaysFailRead);
@@ -1203,7 +1203,7 @@ TEST_F(HttpTest, broken_socket_stops_progressive_reading) {
DownloadServiceImpl svc(DONE_BEFORE_CREATE_PA,
std::numeric_limits<size_t>::max());
EXPECT_EQ(0, server.AddService(&svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
brpc::Channel channel;
brpc::ChannelOptions options;
@@ -1213,7 +1213,7 @@ TEST_F(HttpTest, broken_socket_stops_progressive_reading) {
brpc::Controller cntl;
cntl.response_will_be_read_progressively();
cntl.http_request().uri() = "/DownloadService/Download";
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_TRUE(cntl.response_attachment().empty());
reader.reset(new ReadBody);
@@ -1315,7 +1315,7 @@ public:
private:
void check_header(brpc::Controller* cntl) {
const std::string* test_header = cntl->http_request().GetHeader(TEST_PROGRESSIVE_HEADER);
- CHECK(test_header != NULL);
+ CHECK(test_header != nullptr);
CHECK_EQ(*test_header, TEST_PROGRESSIVE_HEADER_VAL);
}
};
@@ -1328,7 +1328,7 @@ TEST_F(HttpTest, server_end_read_short_body_progressively) {
UploadServiceImpl upsvc;
brpc::Server server;
EXPECT_EQ(0, server.AddService(&upsvc, opt));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
brpc::Channel channel;
brpc::ChannelOptions options;
@@ -1353,7 +1353,7 @@ TEST_F(HttpTest, server_end_read_short_body_progressively) {
}
++c;
}
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed());
}
@@ -1367,7 +1367,7 @@ TEST_F(HttpTest, server_end_read_failed) {
UploadServiceImpl upsvc;
brpc::Server server;
EXPECT_EQ(0, server.AddService(&upsvc, opt));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
brpc::Channel channel;
brpc::ChannelOptions options;
@@ -1392,7 +1392,7 @@ TEST_F(HttpTest, server_end_read_failed) {
}
++c;
}
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl.Failed());
}
#endif // BUTIL_USE_ASAN
@@ -1401,7 +1401,7 @@ TEST_F(HttpTest, http2_sanity) {
const int port = 8923;
brpc::Server server;
EXPECT_EQ(0, server.AddService(&_svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
brpc::Channel channel;
brpc::ChannelOptions options;
@@ -1417,7 +1417,7 @@ TEST_F(HttpTest, http2_sanity) {
big_req.set_message(message);
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.http_request().uri() = "/EchoService/Echo";
- channel.CallMethod(NULL, &cntl, &big_req, &res, NULL);
+ channel.CallMethod(nullptr, &cntl, &big_req, &res, nullptr);
ASSERT_FALSE(cntl.Failed());
ASSERT_EQ(EXP_RESPONSE, res.message());
@@ -1431,7 +1431,7 @@ TEST_F(HttpTest, http2_sanity) {
cntl.http_request().set_content_type("application/json");
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.http_request().uri() = "/EchoService/Echo";
- channel.CallMethod(NULL, &cntl, &req, &res, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &res, nullptr);
ASSERT_FALSE(cntl.Failed());
ASSERT_EQ(EXP_RESPONSE, res.message());
}
@@ -1440,7 +1440,7 @@ TEST_F(HttpTest, http2_sanity) {
brpc::SocketUniquePtr main_ptr;
brpc::SocketUniquePtr agent_ptr;
EXPECT_EQ(brpc::Socket::Address(channel._server_id, &main_ptr), 0);
- EXPECT_EQ(main_ptr->GetAgentSocket(&agent_ptr, NULL), 0);
+ EXPECT_EQ(main_ptr->GetAgentSocket(&agent_ptr, nullptr), 0);
brpc::policy::H2Context* ctx = static_cast<brpc::policy::H2Context*>(agent_ptr->parsing_context());
ASSERT_GT(ctx->_remote_window_left.load(butil::memory_order_relaxed),
brpc::H2Settings::DEFAULT_INITIAL_WINDOW_SIZE / 2);
@@ -1465,7 +1465,7 @@ TEST_F(HttpTest, http2_ping) {
res_out.append(pingbuf, sizeof(pingbuf));
// parse response
brpc::ParseResult res_pr =
- brpc::policy::ParseH2Message(&res_out, _h2_client_sock.get(), false, NULL);
+ brpc::policy::ParseH2Message(&res_out, _h2_client_sock.get(), false, nullptr);
ASSERT_TRUE(res_pr.is_ok());
// process response
ProcessMessage(brpc::policy::ProcessHttpResponse, res_pr.message(), false);
@@ -1495,7 +1495,7 @@ TEST_F(HttpTest, http2_rst_before_header) {
MakeH2EchoResponseBuf(&res_out, h2_stream_id);
// parse response
brpc::ParseResult res_pr =
- brpc::policy::ParseH2Message(&res_out, _h2_client_sock.get(), false, NULL);
+ brpc::policy::ParseH2Message(&res_out, _h2_client_sock.get(), false, nullptr);
ASSERT_TRUE(res_pr.is_ok());
// process response
ProcessMessage(brpc::policy::ProcessHttpResponse, res_pr.message(), false);
@@ -1519,7 +1519,7 @@ TEST_F(HttpTest, http2_rst_after_header_and_data) {
res_out.append(rstbuf, sizeof(rstbuf));
// parse response
brpc::ParseResult res_pr =
- brpc::policy::ParseH2Message(&res_out, _h2_client_sock.get(), false, NULL);
+ brpc::policy::ParseH2Message(&res_out, _h2_client_sock.get(), false, nullptr);
ASSERT_TRUE(res_pr.is_ok());
// process response
ProcessMessage(brpc::policy::ProcessHttpResponse, res_pr.message(), false);
@@ -1543,7 +1543,7 @@ TEST_F(HttpTest, http2_window_used_up_buffers_request) {
brpc::policy::SerializeFrameHead(settingsbuf, nb, brpc::policy::H2_FRAME_SETTINGS, 0, 0);
butil::IOBuf buf;
buf.append(settingsbuf, brpc::policy::FRAME_HEAD_SIZE + nb);
- brpc::policy::ParseH2Message(&buf, _h2_client_sock.get(), false, NULL);
+ brpc::policy::ParseH2Message(&buf, _h2_client_sock.get(), false, nullptr);
brpc::policy::H2Context* ctx = static_cast<brpc::policy::H2Context*>(
_h2_client_sock->parsing_context());
@@ -1551,9 +1551,9 @@ TEST_F(HttpTest, http2_window_used_up_buffers_request) {
for (int i = 0; i <= nsuc; i++) {
brpc::policy::H2UnsentRequest* h2_req = brpc::policy::H2UnsentRequest::New(&cntl);
cntl._current_call.stream_user_data = h2_req;
- brpc::SocketMessage* socket_message = NULL;
- brpc::policy::PackH2Request(NULL, &socket_message, cntl.call_id().value,
- NULL, &cntl, request_buf, NULL);
+ brpc::SocketMessage* socket_message = nullptr;
+ brpc::policy::PackH2Request(nullptr, &socket_message, cntl.call_id().value,
+ nullptr, &cntl, request_buf, nullptr);
butil::IOBuf dummy;
butil::Status st = socket_message->AppendAndDestroySelf(&dummy, _h2_client_sock.get());
ASSERT_TRUE(st.ok());
@@ -1579,12 +1579,12 @@ TEST_F(HttpTest, http2_settings) {
butil::IOBuf buf;
buf.append(settingsbuf, brpc::policy::FRAME_HEAD_SIZE + nb);
- brpc::policy::H2Context* ctx = new brpc::policy::H2Context(_socket.get(), NULL);
+ brpc::policy::H2Context* ctx = new brpc::policy::H2Context(_socket.get(), nullptr);
CHECK_EQ(ctx->Init(), 0);
_socket->initialize_parsing_context(&ctx);
ctx->_conn_state = brpc::policy::H2_CONNECTION_READY;
// parse settings
- brpc::policy::ParseH2Message(&buf, _socket.get(), false, NULL);
+ brpc::policy::ParseH2Message(&buf, _socket.get(), false, nullptr);
butil::IOPortal response_buf;
CHECK_EQ(response_buf.append_from_file_descriptor(_pipe_fds[0], 1024),
@@ -1619,11 +1619,11 @@ TEST_F(HttpTest, http2_goaway_with_debug_data) {
buf.append(goawaybuf, brpc::policy::FRAME_HEAD_SIZE + payload_size);
brpc::policy::H2Context* ctx =
- new brpc::policy::H2Context(_h2_client_sock.get(), NULL);
+ new brpc::policy::H2Context(_h2_client_sock.get(), nullptr);
CHECK_EQ(ctx->Init(), 0);
_h2_client_sock->initialize_parsing_context(&ctx);
ctx->_conn_state = brpc::policy::H2_CONNECTION_READY;
- brpc::policy::ParseH2Message(&buf, _h2_client_sock.get(), false, NULL);
+ brpc::policy::ParseH2Message(&buf, _h2_client_sock.get(), false, nullptr);
// Reading the debug data instead would leave -1 here, which disables the
// `_goaway_stream_id >= 0' check in TryToInsertStream.
@@ -1657,7 +1657,7 @@ TEST_F(HttpTest, http2_not_closing_socket_when_rpc_timeout) {
const int port = 8923;
brpc::Server server;
EXPECT_EQ(0, server.AddService(&_svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
brpc::Channel channel;
brpc::ChannelOptions options;
options.protocol = "h2";
@@ -1671,7 +1671,7 @@ TEST_F(HttpTest, http2_not_closing_socket_when_rpc_timeout) {
brpc::Controller cntl;
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.http_request().uri() = "/EchoService/Echo";
- channel.CallMethod(NULL, &cntl, &req, &res, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &res, nullptr);
ASSERT_FALSE(cntl.Failed());
ASSERT_EQ(EXP_RESPONSE, res.message());
}
@@ -1685,7 +1685,7 @@ TEST_F(HttpTest, http2_not_closing_socket_when_rpc_timeout) {
cntl.set_timeout_ms(50);
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.http_request().uri() = "/EchoService/Echo?sleep_ms=300";
- channel.CallMethod(NULL, &cntl, &req, &res, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &res, nullptr);
ASSERT_TRUE(cntl.Failed());
brpc::SocketUniquePtr ptr;
@@ -1698,7 +1698,7 @@ TEST_F(HttpTest, http2_not_closing_socket_when_rpc_timeout) {
brpc::Controller cntl;
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.http_request().uri() = "/EchoService/Echo";
- channel.CallMethod(NULL, &cntl, &req, &res, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &res, nullptr);
ASSERT_FALSE(cntl.Failed());
ASSERT_EQ(EXP_RESPONSE, res.message());
brpc::SocketUniquePtr ptr;
@@ -1790,7 +1790,7 @@ TEST_F(HttpTest, http2_header_after_data) {
}
// parse response
brpc::ParseResult res_pr =
- brpc::policy::ParseH2Message(&res_out, _h2_client_sock.get(), false, NULL);
+ brpc::policy::ParseH2Message(&res_out, _h2_client_sock.get(), false, nullptr);
ASSERT_TRUE(res_pr.is_ok());
// process response
ProcessMessage(brpc::policy::ProcessHttpResponse, res_pr.message(), false);
@@ -1822,22 +1822,22 @@ TEST_F(HttpTest, http2_goaway_sanity) {
res_out.append(goawaybuf, sizeof(goawaybuf));
// parse response
brpc::ParseResult res_pr =
- brpc::policy::ParseH2Message(&res_out, _h2_client_sock.get(), false, NULL);
+ brpc::policy::ParseH2Message(&res_out, _h2_client_sock.get(), false, nullptr);
ASSERT_TRUE(res_pr.is_ok());
// process response
ProcessMessage(brpc::policy::ProcessHttpResponse, res_pr.message(), false);
ASSERT_TRUE(!cntl.Failed());
// parse GOAWAY
- res_pr = brpc::policy::ParseH2Message(&res_out, _h2_client_sock.get(), false, NULL);
+ res_pr = brpc::policy::ParseH2Message(&res_out, _h2_client_sock.get(), false, nullptr);
ASSERT_EQ(res_pr.error(), brpc::PARSE_ERROR_NOT_ENOUGH_DATA);
// Since GOAWAY has been received, the next request should fail
brpc::policy::H2UnsentRequest* h2_req = brpc::policy::H2UnsentRequest::New(&cntl);
cntl._current_call.stream_user_data = h2_req;
- brpc::SocketMessage* socket_message = NULL;
- brpc::policy::PackH2Request(NULL, &socket_message, cntl.call_id().value,
- NULL, &cntl, butil::IOBuf(), NULL);
+ brpc::SocketMessage* socket_message = nullptr;
+ brpc::policy::PackH2Request(nullptr, &socket_message, cntl.call_id().value,
+ nullptr, &cntl, butil::IOBuf(), nullptr);
butil::IOBuf dummy;
butil::Status st = socket_message->AppendAndDestroySelf(&dummy, _h2_client_sock.get());
ASSERT_EQ(st.error_code(), brpc::ELOGOFF);
@@ -1874,10 +1874,10 @@ TEST_F(HttpTest, http2_handle_goaway_streams) {
ids.push_back(cntl.call_id());
cntl.set_timeout_ms(-1);
cntl.http_request().uri() = "/it-doesnt-matter";
- channel.CallMethod(NULL, &cntl, NULL, NULL, done);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, done);
}
- int servfd = accept(listenfd, NULL, NULL);
+ int servfd = accept(listenfd, nullptr, nullptr);
ASSERT_GT(servfd, 0);
// Sleep for a while to make sure that server has received all data.
bthread_usleep(2000);
@@ -2044,7 +2044,7 @@ TEST_F(HttpTest, proto_text_content_type) {
cntl.Reset();
cntl.http_request().set_content_type("application/proto-text");
res.Clear();
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
ASSERT_FALSE(cntl.Failed());
ASSERT_EQ(EXP_RESPONSE, res.message());
ASSERT_EQ("application/proto-text", cntl.http_response().content_type());
@@ -2120,7 +2120,7 @@ class HttpServiceImpl : public ::test::HttpService {
brpc::ClosureGuard done_guard(done);
brpc::Controller* cntl = static_cast<brpc::Controller*>(cntl_base);
const std::string* expect = cntl->http_request().GetHeader("Expect");
- ASSERT_TRUE(expect != NULL);
+ ASSERT_TRUE(expect != nullptr);
ASSERT_EQ("100-continue", *expect);
ASSERT_EQ(cntl->http_request().method(), brpc::HTTP_METHOD_POST);
cntl->response_attachment().append("world");
@@ -2132,7 +2132,7 @@ TEST_F(HttpTest, http_head) {
brpc::Server server;
HttpServiceImpl svc;
EXPECT_EQ(0, server.AddService(&svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
brpc::Channel channel;
brpc::ChannelOptions options;
@@ -2143,7 +2143,7 @@ TEST_F(HttpTest, http_head) {
cntl.http_request().set_method(brpc::HTTP_METHOD_HEAD);
cntl.http_request().uri().set_path("/HttpService/Head");
cntl.http_request().SetHeader("x-db-index", butil::IntToString(i));
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
if (i % 2 == 0) {
@@ -2180,7 +2180,7 @@ void MakeHttpRequestHeaders(butil::IOBuf* out,
//the request-target consists of only the host name and port number of
//the tunnel destination, seperated by a colon. For example,
//Host: server.example.com:80
- if (h->GetHeader("host") == NULL) {
+ if (h->GetHeader("host") == nullptr) {
os << "Host: ";
if (!uri.host().empty()) {
os << uri.host();
@@ -2200,15 +2200,15 @@ void MakeHttpRequestHeaders(butil::IOBuf* out,
it != h->HeaderEnd(); ++it) {
os << it->first << ": " << it->second << BRPC_CRLF;
}
- if (h->GetHeader("Accept") == NULL) {
+ if (h->GetHeader("Accept") == nullptr) {
os << "Accept: */*" BRPC_CRLF;
}
// The fake "curl" user-agent may let servers return plain-text results.
- if (h->GetHeader("User-Agent") == NULL) {
+ if (h->GetHeader("User-Agent") == nullptr) {
os << "User-Agent: brpc/1.0 curl/7.0" BRPC_CRLF;
}
const std::string& user_info = h->uri().user_info();
- if (!user_info.empty() && h->GetHeader("Authorization") == NULL) {
+ if (!user_info.empty() && h->GetHeader("Authorization") == nullptr) {
// NOTE: just assume user_info is well formatted, namely
// "<user_name>:<password>". Users are very unlikely to add extra
// characters in this part and even if users did, most of them are
@@ -2243,7 +2243,7 @@ void ReadOneResponse(brpc::SocketUniquePtr& sock,
bthread_usleep(1000);
continue;
}
- brpc::ParseResult pr = brpc::policy::ParseHttpMessage(&read_buf, sock.get(), false, NULL);
+ brpc::ParseResult pr = brpc::policy::ParseHttpMessage(&read_buf, sock.get(), false, nullptr);
ASSERT_TRUE(pr.error() == brpc::PARSE_ERROR_NOT_ENOUGH_DATA || pr.is_ok());
if (pr.is_ok()) {
imsg_guard.reset(static_cast<brpc::policy::HttpContext*>(pr.message()));
@@ -2258,7 +2258,7 @@ TEST_F(HttpTest, http_expect) {
brpc::Server server;
HttpServiceImpl svc;
EXPECT_EQ(0, server.AddService(&svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- EXPECT_EQ(0, server.Start(port, NULL));
+ EXPECT_EQ(0, server.Start(port, nullptr));
butil::EndPoint ep;
ASSERT_EQ(0, butil::str2endpoint("127.0.0.1:8923", &ep));
@@ -2339,7 +2339,7 @@ TEST_F(HttpTest, grpc_auth_failed_response) {
h2_msg->Init(h2_ctx, 1); // stream_id = 1
// Set socket and arg using existing test pattern
- if (h2_msg->_socket == NULL) {
+ if (h2_msg->_socket == nullptr) {
_socket->ReAddress(&h2_msg->_socket);
}
h2_msg->_arg = &_server;
@@ -2419,7 +2419,7 @@ TEST_F(HttpTest, http10_auth_failed_response) {
EXPECT_EQ((ssize_t)bytes_in_pipe, buf.append_from_file_descriptor(_pipe_fds[0], 1024));
// Parse HTTP/1.0 response and verify format
- brpc::ParseResult pr = brpc::policy::ParseHttpMessage(&buf, _socket.get(), false, NULL);
+ brpc::ParseResult pr = brpc::policy::ParseHttpMessage(&buf, _socket.get(), false, nullptr);
EXPECT_EQ(brpc::PARSE_OK, pr.error());
brpc::policy::HttpContext* response_msg = static_cast<brpc::policy::HttpContext*>(pr.message());
@@ -2435,12 +2435,12 @@ TEST_F(HttpTest, http10_auth_failed_response) {
// Verify HTTP headers for HTTP/1.0
const std::string* content_length = response_msg->header().GetHeader("Content-Length");
- EXPECT_TRUE(content_length != NULL);
+ EXPECT_TRUE(content_length != nullptr);
EXPECT_GT(std::stoi(*content_length), 0);
// Content-Type may not always be set for error responses, check if present
const std::string* content_type = response_msg->header().GetHeader("Content-Type");
- if (content_type != NULL) {
+ if (content_type != nullptr) {
// If present, should contain text
EXPECT_TRUE(content_type->find("text") != std::string::npos);
}
diff --git a/test/brpc_hulu_pbrpc_protocol_unittest.cpp b/test/brpc_hulu_pbrpc_protocol_unittest.cpp
index d00b9d45..e33d860e 100644
--- a/test/brpc_hulu_pbrpc_protocol_unittest.cpp
+++ b/test/brpc_hulu_pbrpc_protocol_unittest.cpp
@@ -116,7 +116,7 @@ protected:
virtual void TearDown() {};
void VerifyMessage(brpc::InputMessageBase* msg) {
- if (msg->_socket == NULL) {
+ if (msg->_socket == nullptr) {
_socket->ReAddress(&msg->_socket);
}
msg->_arg = &_server;
@@ -125,7 +125,7 @@ protected:
void ProcessMessage(void (*process)(brpc::InputMessageBase*),
brpc::InputMessageBase* msg, bool set_eof) {
- if (msg->_socket == NULL) {
+ if (msg->_socket == nullptr) {
_socket.get()->ReAddress(&msg->_socket);
}
msg->_arg = &_server;
@@ -176,7 +176,7 @@ protected:
butil::IOPortal buf;
EXPECT_EQ((ssize_t)bytes_in_pipe,
buf.append_from_file_descriptor(_pipe_fds[0], 1024));
- brpc::ParseResult pr = brpc::policy::ParseHuluMessage(&buf, NULL, false, NULL);
+ brpc::ParseResult pr = brpc::policy::ParseHuluMessage(&buf, nullptr, false, nullptr);
EXPECT_EQ(brpc::PARSE_OK, pr.error());
brpc::policy::MostCommonMessage* msg =
static_cast<brpc::policy::MostCommonMessage*>(pr.message());
@@ -200,13 +200,13 @@ protected:
brpc::SerializeRequestDefault(&request_buf, &cntl, &req);
ASSERT_FALSE(cntl.Failed());
brpc::policy::PackHuluRequest(
- &total_buf, NULL, cntl.call_id().value,
+ &total_buf, nullptr, cntl.call_id().value,
test::EchoService::descriptor()->method(0),
&cntl, request_buf, &_auth);
ASSERT_FALSE(cntl.Failed());
brpc::ParseResult req_pr =
- brpc::policy::ParseHuluMessage(&total_buf, NULL, false, NULL);
+ brpc::policy::ParseHuluMessage(&total_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, req_pr.error());
brpc::InputMessageBase* req_msg = req_pr.message();
ProcessMessage(brpc::policy::ProcessHuluRequest, req_msg, false);
@@ -290,13 +290,13 @@ TEST_F(HuluTest, complete_flow) {
ASSERT_FALSE(cntl.Failed());
cntl.request_attachment().append(EXP_REQUEST);
brpc::policy::PackHuluRequest(
- &total_buf, NULL, cntl.call_id().value,
+ &total_buf, nullptr, cntl.call_id().value,
test::EchoService::descriptor()->method(0), &cntl, request_buf, &_auth);
ASSERT_FALSE(cntl.Failed());
// Verify and handle request
brpc::ParseResult req_pr =
- brpc::policy::ParseHuluMessage(&total_buf, NULL, false, NULL);
+ brpc::policy::ParseHuluMessage(&total_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, req_pr.error());
brpc::InputMessageBase* req_msg = req_pr.message();
VerifyMessage(req_msg);
@@ -306,7 +306,7 @@ TEST_F(HuluTest, complete_flow) {
butil::IOPortal response_buf;
response_buf.append_from_file_descriptor(_pipe_fds[0], 1024);
brpc::ParseResult res_pr =
- brpc::policy::ParseHuluMessage(&response_buf, NULL, false, NULL);
+ brpc::policy::ParseHuluMessage(&response_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, res_pr.error());
brpc::InputMessageBase* res_msg = res_pr.message();
ProcessMessage(brpc::policy::ProcessHuluResponse, res_msg, false);
@@ -327,13 +327,13 @@ TEST_F(HuluTest, close_in_callback) {
brpc::SerializeRequestDefault(&request_buf, &cntl, &req);
ASSERT_FALSE(cntl.Failed());
brpc::policy::PackHuluRequest(
- &total_buf, NULL, cntl.call_id().value,
+ &total_buf, nullptr, cntl.call_id().value,
test::EchoService::descriptor()->method(0), &cntl, request_buf, &_auth);
ASSERT_FALSE(cntl.Failed());
// Handle request
brpc::ParseResult req_pr =
- brpc::policy::ParseHuluMessage(&total_buf, NULL, false, NULL);
+ brpc::policy::ParseHuluMessage(&total_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, req_pr.error());
brpc::InputMessageBase* req_msg = req_pr.message();
ProcessMessage(brpc::policy::ProcessHuluRequest, req_msg, false);
diff --git a/test/brpc_input_messenger_unittest.cpp b/test/brpc_input_messenger_unittest.cpp
index ae4afb6f..fcf233b1 100644
--- a/test/brpc_input_messenger_unittest.cpp
+++ b/test/brpc_input_messenger_unittest.cpp
@@ -43,7 +43,7 @@ int main(int argc, char* argv[]) {
brpc::SerializeRequestDefault,
brpc::policy::PackHuluRequest,
EmptyProcessHuluRequest, EmptyProcessHuluRequest,
- NULL, NULL, NULL,
+ nullptr, nullptr, nullptr,
brpc::CONNECTION_TYPE_ALL, "dummy_hulu" };
EXPECT_EQ(0, RegisterProtocol((brpc::ProtocolType)30, dummy_protocol));
return RUN_ALL_TESTS();
@@ -106,14 +106,14 @@ void* client_thread(void* arg) {
butil::fd_guard fd(butil::unix_socket_connect(socket_name));
if (fd < 0) {
PLOG(FATAL) << "Fail to connect to " << socket_name;
- return NULL;
+ return nullptr;
}
#else
butil::EndPoint point(butil::IP_ANY, 7878);
- butil::fd_guard fd(butil::tcp_connect(point, NULL));
+ butil::fd_guard fd(butil::tcp_connect(point, nullptr));
if (fd < 0) {
PLOG(FATAL) << "Fail to connect to " << point;
- return NULL;
+ return nullptr;
}
#endif
@@ -132,7 +132,7 @@ void* client_thread(void* arg) {
if (n < 0) {
if (errno != EINTR) {
PLOG(FATAL) << "Fail to write fd=" << fd;
- return NULL;
+ return nullptr;
}
} else {
++m->times;
@@ -144,7 +144,7 @@ void* client_thread(void* arg) {
}
}
free(buf);
- return NULL;
+ return nullptr;
}
TEST_F(MessengerTest, dispatch_tasks) {
@@ -156,7 +156,7 @@ TEST_F(MessengerTest, dispatch_tasks) {
const brpc::InputMessageHandler pairs[] = {
{ brpc::policy::ParseHuluMessage,
- EmptyProcessHuluRequest, NULL, NULL, "dummy_hulu" }
+ EmptyProcessHuluRequest, nullptr, nullptr, "dummy_hulu" }
};
for (size_t i = 0; i < NEPOLL; ++i) {
@@ -170,14 +170,14 @@ TEST_F(MessengerTest, dispatch_tasks) {
ASSERT_TRUE(listening_fd > 0);
butil::make_non_blocking(listening_fd);
ASSERT_EQ(0, messenger[i].AddHandler(pairs[0]));
- ASSERT_EQ(0, messenger[i].StartAccept(listening_fd, -1, NULL, false));
+ ASSERT_EQ(0, messenger[i].StartAccept(listening_fd, -1, nullptr, false));
}
for (size_t i = 0; i < NCLIENT; ++i) {
cm[i] = new ClientMeta;
cm[i]->times = 0;
cm[i]->bytes = 0;
- ASSERT_EQ(0, pthread_create(&cth[i], NULL, client_thread, cm[i]));
+ ASSERT_EQ(0, pthread_create(&cth[i], nullptr, client_thread, cm[i]));
}
sleep(1);
@@ -211,7 +211,7 @@ TEST_F(MessengerTest, dispatch_tasks) {
<< "/s";
for (size_t i = 0; i < NCLIENT; ++i) {
- pthread_join(cth[i], NULL);
+ pthread_join(cth[i], nullptr);
printf("joined client %lu\n", i);
}
for (size_t i = 0; i < NEPOLL; ++i) {
diff --git a/test/brpc_interceptor_unittest.cpp b/test/brpc_interceptor_unittest.cpp
index 6238c3fe..ca9ab40f 100644
--- a/test/brpc_interceptor_unittest.cpp
+++ b/test/brpc_interceptor_unittest.cpp
@@ -118,7 +118,7 @@ public:
::test::EchoResponse& res) {
for (g_index = 0; g_index < 1000; ++g_index) {
brpc::Controller cntl;
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
if (g_index % 2 == 0) {
ASSERT_TRUE(cntl.Failed());
ASSERT_EQ(EREJECT, cntl.ErrorCode());
@@ -190,7 +190,7 @@ TEST_F(InterceptorTest, sanity) {
for (g_index = 0; g_index < 1000; ++g_index) {
brpc::Controller cntl;
brpc::NsheadMessage response;
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
if (g_index % 2 == 0) {
ASSERT_EQ(NSHEAD_EXP_RESPONSE, response.body.to_string());
} else {
diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp
index 1b326a8f..8748625c 100644
--- a/test/brpc_load_balancer_unittest.cpp
+++ b/test/brpc_load_balancer_unittest.cpp
@@ -155,7 +155,7 @@ void* DBDBthread(void* arg) {
bthread_usleep(100 * 1000);
}
- return NULL;
+ return nullptr;
}
template <typename DBD>
@@ -170,7 +170,7 @@ void DBDMultiBthread() {
bthread_t tids[10000];
for (size_t i = 0; i < ARRAY_SIZE(tids); ++i) {
- ASSERT_EQ(0, bthread_start_urgent(&tids[i], NULL, DBDBthread<DBD>, &d));
+ ASSERT_EQ(0, bthread_start_urgent(&tids[i], nullptr, DBDBthread<DBD>, &d));
}
// Modify during reading.
@@ -183,7 +183,7 @@ void DBDMultiBthread() {
}
exitFlag = true;
for (size_t i = 0; i < ARRAY_SIZE(tids); ++i) {
- ASSERT_EQ(0, bthread_join(tids[i], NULL));
+ ASSERT_EQ(0, bthread_join(tids[i], nullptr));
}
}
@@ -216,7 +216,7 @@ struct BAIDU_CACHELINE_ALIGNMENT PerfArgs {
int64_t elapse_ns;
bool ready;
- PerfArgs() : dbd(NULL), counter(0), elapse_ns(0), ready(false) {}
+ PerfArgs() : dbd(nullptr), counter(0), elapse_ns(0), ready(false) {}
};
template<typename DBD>
@@ -241,7 +241,7 @@ void* read_dbd(void* void_arg) {
}
t.stop();
args->elapse_ns = t.n_elapsed();
- return NULL;
+ return nullptr;
}
template<typename DBD>
@@ -256,7 +256,7 @@ void PerfTest(int thread_num, bool modify_during_reading) {
std::vector<PerfArgs<DBD>> args(thread_num);
for (int i = 0; i < thread_num; ++i) {
args[i].dbd = &dbd;
- ASSERT_EQ(0, pthread_create(&threads[i], NULL, read_dbd<DBD>, &args[i]));
+ ASSERT_EQ(0, pthread_create(&threads[i], nullptr, read_dbd<DBD>, &args[i]));
}
while (true) {
bool all_ready = true;
@@ -291,7 +291,7 @@ void PerfTest(int thread_num, bool modify_during_reading) {
int64_t wait_time = 0;
int64_t count = 0;
for (int i = 0; i < thread_num; ++i) {
- pthread_join(threads[i], NULL);
+ pthread_join(threads[i], nullptr);
wait_time += args[i].elapse_ns;
count += args[i].counter;
}
@@ -372,7 +372,7 @@ static void ValidateLALB(LALB& lalb, size_t N) {
for (size_t R = 0; R < 2; ++R) {
ASSERT_EQ((int64_t*)d[R].weight_tree[i].left, &lalb._left_weights[i]);
size_t* pindex = d[R].server_map.seek(d[R].weight_tree[i].server_id);
- ASSERT_TRUE(pindex != NULL && *pindex == i);
+ ASSERT_TRUE(pindex != nullptr && *pindex == i);
}
total += d[0].weight_tree[i].weight->volatile_value();
}
@@ -435,7 +435,7 @@ void* select_server(void* arg) {
brpc::LoadBalancer* c = sa->lb;
brpc::SocketUniquePtr ptr;
CountMap *selected_count = new CountMap;
- brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL };
+ brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, nullptr };
brpc::LoadBalancer::SelectOut out(&ptr);
uint32_t rand_seed = rand();
if (sa->hash) {
@@ -468,8 +468,8 @@ class SaveRecycle : public brpc::SocketUser {
TEST_F(LoadBalancerTest, update_while_selection) {
for (size_t round = 0; round < 5; ++round) {
- brpc::LoadBalancer* lb = NULL;
- SelectArg sa = { NULL, NULL};
+ brpc::LoadBalancer* lb = nullptr;
+ SelectArg sa = { nullptr, nullptr};
bool is_lalb = false;
if (round == 0) {
lb = new brpc::policy::RoundRobinLoadBalancer;
@@ -488,7 +488,7 @@ TEST_F(LoadBalancerTest, update_while_selection) {
// Accessing empty lb should result in error.
brpc::SocketUniquePtr ptr;
- brpc::LoadBalancer::SelectIn in = { 0, false, true, 0, NULL };
+ brpc::LoadBalancer::SelectIn in = { 0, false, true, 0, nullptr };
brpc::LoadBalancer::SelectOut out(&ptr);
ASSERT_EQ(ENODATA, lb->SelectServer(in, &out));
@@ -528,7 +528,7 @@ TEST_F(LoadBalancerTest, update_while_selection) {
butil::Timer tm;
tm.start();
for (size_t i = 0; i < ARRAY_SIZE(th); ++i) {
- ASSERT_EQ(0, pthread_create(&th[i], NULL, select_server, &sa));
+ ASSERT_EQ(0, pthread_create(&th[i], nullptr, select_server, &sa));
}
std::vector<brpc::ServerId> removed;
const size_t REP = 200;
@@ -610,8 +610,8 @@ TEST_F(LoadBalancerTest, update_while_selection) {
TEST_F(LoadBalancerTest, fairness) {
for (size_t round = 0; round < 6; ++round) {
- brpc::LoadBalancer* lb = NULL;
- SelectArg sa = { NULL, NULL};
+ brpc::LoadBalancer* lb = nullptr;
+ SelectArg sa = { nullptr, nullptr};
if (round == 0) {
lb = new brpc::policy::RoundRobinLoadBalancer;
} else if (round == 1) {
@@ -661,7 +661,7 @@ TEST_F(LoadBalancerTest, fairness) {
}
for (size_t i = 0; i < ARRAY_SIZE(th); ++i) {
- ASSERT_EQ(0, pthread_create(&th[i], NULL, select_server, &sa));
+ ASSERT_EQ(0, pthread_create(&th[i], nullptr, select_server, &sa));
}
bthread_usleep(10000);
ProfilerStart((lb_name + ".prof").c_str());
@@ -794,7 +794,7 @@ TEST_F(LoadBalancerTest, consistent_hashing) {
const size_t SELECT_TIMES = 1000000;
std::map<butil::EndPoint, size_t> times;
brpc::SocketUniquePtr ptr;
- brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL };
+ brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, nullptr };
::brpc::LoadBalancer::SelectOut out(&ptr);
for (size_t i = 0; i < SELECT_TIMES; ++i) {
in.has_request_code = true;
@@ -871,7 +871,7 @@ TEST_F(LoadBalancerTest, weighted_round_robin) {
// consistent with weight configured.
std::map<butil::EndPoint, size_t> select_result;
brpc::SocketUniquePtr ptr;
- brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL };
+ brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, nullptr };
brpc::LoadBalancer::SelectOut out(&ptr);
int total_weight = 12;
std::vector<butil::EndPoint> select_servers;
@@ -983,7 +983,7 @@ TEST_F(LoadBalancerTest, weighted_randomized) {
// weight randomized with weight configured.
std::map<butil::EndPoint, size_t> select_result;
brpc::SocketUniquePtr ptr;
- brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL };
+ brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, nullptr };
brpc::LoadBalancer::SelectOut out(&ptr);
int run_times = configed_weight_sum * 100;
std::vector<butil::EndPoint> select_servers;
@@ -1051,7 +1051,7 @@ TEST_F(LoadBalancerTest, weighted_randomized_equal_weight) {
std::map<butil::EndPoint, size_t> select_result;
brpc::SocketUniquePtr ptr;
- brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL };
+ brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, nullptr };
brpc::LoadBalancer::SelectOut out(&ptr);
const int run_times = 40000;
for (int i = 0; i < run_times; ++i) {
@@ -1104,7 +1104,7 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) {
// Without setting anything, the lb should work fine
for (int i = 0; i < 4; ++i) {
brpc::SocketUniquePtr ptr;
- brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL };
+ brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, nullptr };
brpc::LoadBalancer::SelectOut out(&ptr);
ASSERT_EQ(0, lb->SelectServer(in, &out));
}
@@ -1114,7 +1114,7 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) {
ptr->_ninflight_app_health_check.store(1, butil::memory_order_relaxed);
for (int i = 0; i < 4; ++i) {
brpc::SocketUniquePtr ptr;
- brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL };
+ brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, nullptr };
brpc::LoadBalancer::SelectOut out(&ptr);
ASSERT_EQ(0, lb->SelectServer(in, &out));
// After putting server[0] into health check state, the only choice is servers[1]
@@ -1125,7 +1125,7 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) {
ptr->_ninflight_app_health_check.store(1, butil::memory_order_relaxed);
for (int i = 0; i < 4; ++i) {
brpc::SocketUniquePtr ptr;
- brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL };
+ brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, nullptr };
brpc::LoadBalancer::SelectOut out(&ptr);
// There is no server available
ASSERT_EQ(EHOSTDOWN, lb->SelectServer(in, &out));
@@ -1140,7 +1140,7 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) {
bool get_server2 = false;
for (int i = 0; i < 20; ++i) {
brpc::SocketUniquePtr ptr;
- brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL };
+ brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, nullptr };
brpc::LoadBalancer::SelectOut out(&ptr);
ASSERT_EQ(0, lb->SelectServer(in, &out));
if (ptr->remote_side().port == 8832) {
@@ -1181,7 +1181,7 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) {
lb->AddServer(id);
}
brpc::SocketUniquePtr sptr;
- brpc::LoadBalancer::SelectIn in = { 0, false, true, 0u, NULL };
+ brpc::LoadBalancer::SelectIn in = { 0, false, true, 0u, nullptr };
brpc::LoadBalancer::SelectOut out(&sptr);
ASSERT_EQ(0, lb->SelectServer(in, &out));
@@ -1312,7 +1312,7 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) {
{
// trigger one server to health check
brpc::Controller cntl;
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
}
// This sleep make one server revived 700ms earlier than the other server, which
// can make the server down again if no request limit policy are applied here.
@@ -1320,20 +1320,20 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) {
{
// trigger the other server to health check
brpc::Controller cntl;
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
}
butil::EndPoint point(butil::IP_ANY, 7777);
EchoServiceImpl service;
brpc::Server server;
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(point, NULL));
+ ASSERT_EQ(0, server.Start(point, nullptr));
butil::EndPoint point2(butil::IP_ANY, 7778);
EchoServiceImpl service2;
brpc::Server server2;
ASSERT_EQ(0, server2.AddService(&service2, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server2.Start(point2, NULL));
+ ASSERT_EQ(0, server2.Start(point2, nullptr));
int64_t start_ms = butil::cpuwide_time_ms();
while ((butil::cpuwide_time_ms() - start_ms) < 3500) {
@@ -1413,7 +1413,7 @@ TEST_F(LoadBalancerTest, la_records_latency_with_consistent_time_source) {
const std::string s = os.str();
const size_t p = s.find("avg_latency=");
if (p == std::string::npos) return -1;
- return strtoll(s.c_str() + p + strlen("avg_latency="), NULL, 10);
+ return strtoll(s.c_str() + p + strlen("avg_latency="), nullptr, 10);
};
// Drive a few "RPCs": pick a server, sleep ~2ms, feed back. begin_time_us
@@ -1422,11 +1422,11 @@ TEST_F(LoadBalancerTest, la_records_latency_with_consistent_time_source) {
for (int i = 0; i < 8; ++i) {
const int64_t begin_us = butil::gettimeofday_us();
brpc::SocketUniquePtr ptr;
- brpc::LoadBalancer::SelectIn in = { begin_us, true, false, 0u, NULL };
+ brpc::LoadBalancer::SelectIn in = { begin_us, true, false, 0u, nullptr };
brpc::LoadBalancer::SelectOut out(&ptr);
ASSERT_EQ(0, lalb.SelectServer(in, &out));
bthread_usleep(2000);
- brpc::LoadBalancer::CallInfo ci = { begin_us, id.id, 0, NULL };
+ brpc::LoadBalancer::CallInfo ci = { begin_us, id.id, 0, nullptr };
lalb.Feedback(ci);
}
diff --git a/test/brpc_mcpack2pb_unittest.cpp b/test/brpc_mcpack2pb_unittest.cpp
index 6718cae9..c0261540 100644
--- a/test/brpc_mcpack2pb_unittest.cpp
+++ b/test/brpc_mcpack2pb_unittest.cpp
@@ -47,7 +47,7 @@ TEST(Mcpack2pbParserTest, StringFieldWithZeroValueSize) {
mcpack2pb::ObjectIterator it1(&stream, body.size() - stream.popped_bytes());
bool found_content = false;
- for (; it1 != NULL; ++it1) {
+ for (; it1 != nullptr; ++it1) {
if (it1->name == "content") {
found_content = true;
break;
@@ -57,9 +57,9 @@ TEST(Mcpack2pbParserTest, StringFieldWithZeroValueSize) {
ASSERT_EQ(mcpack2pb::FIELD_ARRAY, it1->value.type());
mcpack2pb::ArrayIterator it2(it1->value);
- ASSERT_TRUE(it2 != NULL);
+ ASSERT_TRUE(it2 != nullptr);
bool found_service_name = false;
- for (mcpack2pb::ObjectIterator it3(*it2); it3 != NULL; ++it3) {
+ for (mcpack2pb::ObjectIterator it3(*it2); it3 != nullptr; ++it3) {
if (it3->name == "service_name") {
found_service_name = true;
ASSERT_EQ(mcpack2pb::FIELD_STRING, it3->value.type());
@@ -94,7 +94,7 @@ TEST(Mcpack2pbParserTest, ParseStringField) {
ASSERT_NE(0u, mcpack2pb::unbox(&stream));
mcpack2pb::ObjectIterator it(&stream, body.size() - stream.popped_bytes());
- ASSERT_TRUE(it != NULL);
+ ASSERT_TRUE(it != nullptr);
EXPECT_EQ("msg", it->name.as_string());
ASSERT_EQ(mcpack2pb::FIELD_STRING, it->value.type());
std::string value;
diff --git a/test/brpc_memcache_unittest.cpp b/test/brpc_memcache_unittest.cpp
index 3b7e676b..76c4ca4b 100644
--- a/test/brpc_memcache_unittest.cpp
+++ b/test/brpc_memcache_unittest.cpp
@@ -58,7 +58,7 @@ TEST(MemcacheParserTest, RejectOversizedResponseBeforeBufferingBody) {
buf.append(&header, sizeof(header));
EXPECT_EQ(brpc::PARSE_ERROR_TOO_BIG_DATA,
brpc::policy::ParseMemcacheMessage(
- &buf, socket.get(), false, NULL).error());
+ &buf, socket.get(), false, nullptr).error());
}
@@ -137,7 +137,7 @@ static void RunMemcached() {
puts("[Starting memcached]");
char* const argv[] = { (char*)MEMCACHED_BIN,
(char*)"-p", (char*)MEMCACHED_PORT,
- NULL };
+ nullptr };
if (execvp(MEMCACHED_BIN, argv) < 0) {
puts("Fail to run " MEMCACHED_BIN);
exit(1);
@@ -173,14 +173,14 @@ TEST_F(MemcacheTest, sanity) {
// Clear all contents in MC which is still holding older data after
// restarting in Ubuntu 18.04 (mc=1.5.6)
request.Flush(0);
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_TRUE(response.PopFlush());
cntl.Reset();
request.Clear();
request.Get("hello");
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
std::string value;
uint32_t flags = 0;
@@ -191,7 +191,7 @@ TEST_F(MemcacheTest, sanity) {
cntl.Reset();
request.Clear();
request.Set("hello", "world", 0xdeadbeef, 10, 0);
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_TRUE(response.PopSet(&cas_value)) << response.LastError();
ASSERT_EQ("", response.LastError());
@@ -199,7 +199,7 @@ TEST_F(MemcacheTest, sanity) {
cntl.Reset();
request.Clear();
request.Get("hello");
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed());
ASSERT_TRUE(response.PopGet(&value, &flags, &cas_value));
ASSERT_EQ("", response.LastError());
@@ -211,7 +211,7 @@ TEST_F(MemcacheTest, sanity) {
request.Clear();
request.Set("hello", "world2", 0xdeadbeef, 10,
cas_value/*intended match*/);
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
uint64_t cas_value2 = 0;
ASSERT_TRUE(response.PopSet(&cas_value2)) << response.LastError();
@@ -220,7 +220,7 @@ TEST_F(MemcacheTest, sanity) {
request.Clear();
request.Set("hello", "world3", 0xdeadbeef, 10,
cas_value2 + 1/*intended unmatch*/);
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
uint64_t cas_value3 = ~0;
ASSERT_FALSE(response.PopSet(&cas_value3));
@@ -243,7 +243,7 @@ TEST_F(MemcacheTest, incr_and_decr) {
request.Increment("counter1", 2, 10, 10);
request.Decrement("counter1", 1, 10, 10);
request.Increment("counter1", 3, 10, 10);
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
uint64_t new_value1 = 0;
uint64_t cas_value1 = 0;
@@ -276,7 +276,7 @@ TEST_F(MemcacheTest, version) {
brpc::MemcacheResponse response;
brpc::Controller cntl;
request.Version();
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
std::string version;
ASSERT_TRUE(response.PopVersion(&version)) << response.LastError();
diff --git a/test/brpc_mongo_protocol_unittest.cpp b/test/brpc_mongo_protocol_unittest.cpp
index 64e3bf39..68e4acdc 100644
--- a/test/brpc_mongo_protocol_unittest.cpp
+++ b/test/brpc_mongo_protocol_unittest.cpp
@@ -115,7 +115,7 @@ protected:
void ProcessMessage(void (*process)(brpc::InputMessageBase*),
brpc::InputMessageBase* msg, bool set_eof) {
- if (msg->_socket == NULL) {
+ if (msg->_socket == nullptr) {
_socket->ReAddress(&msg->_socket);
}
msg->_arg = &_server;
diff --git a/test/brpc_mysql_auth_handshake_unittest.cpp b/test/brpc_mysql_auth_handshake_unittest.cpp
index 98450834..7c8cd7c5 100644
--- a/test/brpc_mysql_auth_handshake_unittest.cpp
+++ b/test/brpc_mysql_auth_handshake_unittest.cpp
@@ -507,7 +507,7 @@ static const char* const kSpawnPwPassword = "brpc_test_password";
static bool IsSpawnedServer() { return g_mysqld_pid > 0; }
// Returns the first non-empty-password credential matching |use_ssl|, or
-// NULL when the active server exposes none (so the caller can skip).
+// nullptr when the active server exposes none (so the caller can skip).
static const AuthCase* FindNonEmptyCase(bool use_ssl) {
for (size_t i = 0; i < g_auth_cases.size(); ++i) {
if (!g_auth_cases[i].password.empty() &&
@@ -515,7 +515,7 @@ static const AuthCase* FindNonEmptyCase(bool use_ssl) {
return &g_auth_cases[i];
}
}
- return NULL;
+ return nullptr;
}
// Absolute path to the throwaway data directory. mysqld resolves a
@@ -523,7 +523,7 @@ static const AuthCase* FindNonEmptyCase(bool use_ssl) {
// directory), so the path handed to mysqld must be absolute.
static std::string TestDataDir() {
char cwd[1024];
- if (getcwd(cwd, sizeof(cwd)) == NULL) {
+ if (getcwd(cwd, sizeof(cwd)) == nullptr) {
return std::string("/tmp/mysql_data_for_test");
}
return std::string(cwd) + "/mysql_data_for_test";
@@ -642,7 +642,7 @@ static void RunMysqlServer() {
(char*)logerr_arg.c_str(),
(char*)"--mysqlx=OFF",
(char*)"--bind-address=127.0.0.1",
- NULL };
+ nullptr };
if (execvp(MYSQLD_BIN, argv) < 0) {
puts("Fail to run " MYSQLD_BIN);
exit(1);
@@ -696,7 +696,7 @@ static void RunMysqlServer() {
// Reads exactly |n| bytes into |buf|. When |ssl| is non-null the bytes
// come from the SSL session; otherwise from the raw fd. Returns true on
// success.
-static bool ReadFull(int fd, char* buf, size_t n, SSL* ssl = NULL) {
+static bool ReadFull(int fd, char* buf, size_t n, SSL* ssl = nullptr) {
size_t off = 0;
while (off < n) {
ssize_t r = ssl ? SSL_read(ssl, buf + off, static_cast<int>(n - off))
@@ -714,7 +714,7 @@ static bool ReadFull(int fd, char* buf, size_t n, SSL* ssl = NULL) {
// Writes all of |data| (over SSL when |ssl| is non-null). Returns true
// on success.
-static bool WriteFull(int fd, const std::string& data, SSL* ssl = NULL) {
+static bool WriteFull(int fd, const std::string& data, SSL* ssl = nullptr) {
size_t off = 0;
while (off < data.size()) {
ssize_t w = ssl ? SSL_write(ssl, data.data() + off,
@@ -734,7 +734,7 @@ static bool WriteFull(int fd, const std::string& data, SSL* ssl = NULL) {
// Reads one MySQL packet (4-byte header + payload). On success stores
// the payload in *payload, the sequence id in *seq, and returns true.
static bool ReadPacket(int fd, std::string* payload, uint8_t* seq,
- SSL* ssl = NULL) {
+ SSL* ssl = nullptr) {
char hdr[kPacketHeaderLen];
if (!ReadFull(fd, hdr, sizeof(hdr), ssl)) {
return false;
@@ -754,7 +754,7 @@ static bool ReadPacket(int fd, std::string* payload, uint8_t* seq,
// Frames |payload| with a packet header carrying |seq| and writes it.
static bool WritePacket(int fd, const std::string& payload, uint8_t seq,
- SSL* ssl = NULL) {
+ SSL* ssl = nullptr) {
std::string out;
PacketHeader header;
header.payload_len = static_cast<uint32_t>(payload.size());
@@ -771,7 +771,7 @@ static const uint32_t kClientSSL = 0x00000800;
// Sends the MySQL SSLRequest packet (the 32-byte HandshakeResponse41
// fixed prefix with CLIENT_SSL set, no username) at sequence |seq|, then
// performs a SSL client handshake on |fd|. Returns the SSL* on success
-// (caller owns it) or NULL on failure.
+// (caller owns it) or nullptr on failure.
static SSL* UpgradeToSSL(int fd, uint32_t capability_flags, uint8_t seq) {
// SSLRequest payload: 4B caps + 4B max_packet_size + 1B charset + 23B
// reserved = 32 bytes, with CLIENT_SSL set.
@@ -785,26 +785,26 @@ static SSL* UpgradeToSSL(int fd, uint32_t capability_flags, uint8_t seq) {
payload.push_back(static_cast<char>(0x21)); // charset utf8_general_ci
payload.append(23, '\0');
if (!WritePacket(fd, payload, seq)) {
- return NULL;
+ return nullptr;
}
// One client SSL_CTX for the whole process; certificate not verified
// (mysqld's auto-generated cert is self-signed).
- static SSL_CTX* ctx = NULL;
- if (ctx == NULL) {
+ static SSL_CTX* ctx = nullptr;
+ if (ctx == nullptr) {
ctx = SSL_CTX_new(TLS_client_method());
- if (ctx == NULL) {
- return NULL;
+ if (ctx == nullptr) {
+ return nullptr;
}
- SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
+ SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, nullptr);
}
SSL* ssl = SSL_new(ctx);
- if (ssl == NULL) {
- return NULL;
+ if (ssl == nullptr) {
+ return nullptr;
}
SSL_set_fd(ssl, fd);
if (SSL_connect(ssl) != 1) {
SSL_free(ssl);
- return NULL;
+ return nullptr;
}
return ssl;
}
@@ -863,7 +863,7 @@ static LoginTrace PerformSha2Login(int fd, const std::string& user,
const std::string& initial_plugin =
std::string()) {
LoginTrace t;
- SSL* ssl = NULL;
+ SSL* ssl = nullptr;
std::string payload;
uint8_t seq = 0;
if (!ReadPacket(fd, &payload, &seq)) { // greeting is always plaintext
@@ -899,7 +899,7 @@ static LoginTrace PerformSha2Login(int fd, const std::string& user,
uint8_t next_seq = static_cast<uint8_t>(seq + 1);
if (use_ssl) {
ssl = UpgradeToSSL(fd, resp.capability_flags, next_seq);
- if (ssl == NULL) {
+ if (ssl == nullptr) {
t.err = "SSL upgrade (SSLRequest + SSL_connect) failed";
goto done;
}
@@ -1038,7 +1038,7 @@ static LoginTrace PerformSha2Login(int fd, const std::string& user,
goto done;
}
done:
- if (ssl != NULL) {
+ if (ssl != nullptr) {
SSL_shutdown(ssl);
SSL_free(ssl);
}
@@ -1129,14 +1129,14 @@ TEST_F(MysqlHandshakeServerTest, AuthenticatesEmptyPasswordFastPath) {
puts("Skipped due to absence of mysqld");
return;
}
- const AuthCase* empty = NULL;
+ const AuthCase* empty = nullptr;
for (size_t i = 0; i < g_auth_cases.size(); ++i) {
if (g_auth_cases[i].password.empty() && !g_auth_cases[i].use_ssl) {
empty = &g_auth_cases[i];
break;
}
}
- if (empty == NULL) {
+ if (empty == nullptr) {
puts("Skipped: no empty-password credential on this server");
return;
}
@@ -1159,7 +1159,7 @@ TEST_F(MysqlHandshakeServerTest, FullAuthenticationNotSSL) {
return;
}
const AuthCase* c = FindNonEmptyCase(/*use_ssl=*/false);
- if (c == NULL) {
+ if (c == nullptr) {
puts("Skipped: no non-empty-password credential for plaintext "
"full-auth (need a running server with -mysql_password, or the "
"mysql client for the spawned account)");
@@ -1194,7 +1194,7 @@ TEST_F(MysqlHandshakeServerTest, FullAuthenticationSSL) {
return;
}
const AuthCase* c = FindNonEmptyCase(/*use_ssl=*/true);
- if (c == NULL) {
+ if (c == nullptr) {
puts("Skipped: no non-empty-password credential for SSL full-auth");
return;
}
diff --git a/test/brpc_mysql_auth_packet_unittest.cpp b/test/brpc_mysql_auth_packet_unittest.cpp
index aefe2c1e..0fd9ed1a 100644
--- a/test/brpc_mysql_auth_packet_unittest.cpp
+++ b/test/brpc_mysql_auth_packet_unittest.cpp
@@ -217,7 +217,7 @@ TEST(LenencStringTest, NonNull_SetsIsNullFalse) {
}
TEST(LenencStringTest, EmptyIsNotNull) {
- // Empty string (lenenc 0x00) must NOT be reported as NULL.
+ // Empty string (lenenc 0x00) must NOT be reported as nullptr.
std::string buf;
EncodeLengthEncodedString(butil::StringPiece(""), &buf);
std::string out = "stale";
diff --git a/test/brpc_mysql_connection_type_unittest.cpp b/test/brpc_mysql_connection_type_unittest.cpp
index cc068ae6..4aa89ea5 100644
--- a/test/brpc_mysql_connection_type_unittest.cpp
+++ b/test/brpc_mysql_connection_type_unittest.cpp
@@ -109,7 +109,7 @@ static std::string g_password;
static std::string TestDataDir() {
char cwd[1024];
- if (getcwd(cwd, sizeof(cwd)) == NULL) {
+ if (getcwd(cwd, sizeof(cwd)) == nullptr) {
return std::string("/tmp/mysql_conn_type_data_for_test");
}
return std::string(cwd) + "/mysql_conn_type_data_for_test";
@@ -213,7 +213,7 @@ static void StartServerOnce() {
(char*)logerr_arg.c_str(),
(char*)"--mysqlx=OFF",
(char*)"--bind-address=127.0.0.1",
- NULL};
+ nullptr};
if (execvp(MYSQLD_BIN, argv) < 0) {
puts("Fail to run " MYSQLD_BIN);
exit(1);
@@ -262,7 +262,7 @@ protected:
"integration test (set -mysql_use_running_server "
"or install mysqld)";
}
- brpc::policy::MysqlAuthenticator* auth = NULL;
+ brpc::policy::MysqlAuthenticator* auth = nullptr;
ASSERT_EQ(0, InitShortChannel(&_channel, &auth));
_auth.reset(auth);
}
@@ -288,7 +288,7 @@ TEST_F(MysqlConnectionTypeTest, PreparedStatementUnderShortRePreparesAndSucceeds
for (int iter = 0; iter < 5; ++iter) {
brpc::MysqlStatementUniquePtr stmt =
brpc::NewMysqlStatement(_channel, "SELECT ? AS v");
- ASSERT_TRUE(stmt != NULL) << "iter " << iter;
+ ASSERT_TRUE(stmt != nullptr) << "iter " << iter;
ASSERT_EQ(1u, stmt->param_count()) << "iter " << iter;
const int32_t bound = (int32_t)(40 + iter);
@@ -297,7 +297,7 @@ TEST_F(MysqlConnectionTypeTest, PreparedStatementUnderShortRePreparesAndSucceeds
brpc::MysqlResponse resp;
brpc::Controller cntl;
- _channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ _channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << "iter " << iter << ": " << cntl.ErrorText();
ASSERT_GE(resp.reply_size(), 1) << "iter " << iter;
@@ -330,7 +330,7 @@ TEST_F(MysqlConnectionTypeTest, PlainQueryUnderShortMustSucceed) {
brpc::MysqlResponse resp;
brpc::Controller cntl;
- _channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ _channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_GE(resp.reply_size(), 1);
diff --git a/test/brpc_mysql_pool_concurrency_unittest.cpp b/test/brpc_mysql_pool_concurrency_unittest.cpp
index a942a028..4534710e 100644
--- a/test/brpc_mysql_pool_concurrency_unittest.cpp
+++ b/test/brpc_mysql_pool_concurrency_unittest.cpp
@@ -134,7 +134,7 @@ static std::string g_schema;
static std::string TestDataDir() {
char cwd[1024];
- if (getcwd(cwd, sizeof(cwd)) == NULL) {
+ if (getcwd(cwd, sizeof(cwd)) == nullptr) {
return std::string("/tmp/mysql_pool_conc_data_for_test");
}
return std::string(cwd) + "/mysql_pool_conc_data_for_test";
@@ -240,7 +240,7 @@ static void StartServerOnce() {
(char*)logerr_arg.c_str(),
(char*)"--mysqlx=OFF",
(char*)"--bind-address=127.0.0.1",
- NULL};
+ nullptr};
if (execvp(MYSQLD_BIN, argv) < 0) {
puts("Fail to run " MYSQLD_BIN);
exit(1);
@@ -269,7 +269,7 @@ static bool RunPlain(brpc::Channel& channel, const std::string& sql,
return false;
}
brpc::Controller cntl;
- channel.CallMethod(NULL, &cntl, &req, resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, resp, nullptr);
if (cntl.Failed()) {
if (err) *err = "rpc failed: " + cntl.ErrorText();
return false;
@@ -300,7 +300,7 @@ static bool RunInTx(brpc::Channel& channel, const brpc::MysqlTransaction* tx,
return false;
}
brpc::Controller cntl;
- channel.CallMethod(NULL, &cntl, &req, resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, resp, nullptr);
if (cntl.Failed()) {
if (err) *err = "rpc failed: " + cntl.ErrorText();
return false;
@@ -375,7 +375,7 @@ protected:
<< "failed to set gflag max_connection_pool_size";
// Create the schema over a schema-less channel, then bind to it.
- brpc::policy::MysqlAuthenticator* setup_auth = NULL;
+ brpc::policy::MysqlAuthenticator* setup_auth = nullptr;
ASSERT_EQ(0, InitPooledChannel(&_setup_channel, &setup_auth, ""));
_setup_auth.reset(setup_auth);
brpc::MysqlResponse resp;
@@ -384,7 +384,7 @@ protected:
"CREATE DATABASE IF NOT EXISTS " + g_schema,
&resp, &err)) << err;
- brpc::policy::MysqlAuthenticator* auth = NULL;
+ brpc::policy::MysqlAuthenticator* auth = nullptr;
ASSERT_EQ(0, InitPooledChannel(&_channel, &auth, g_schema));
_auth.reset(auth);
}
@@ -414,7 +414,7 @@ static bool WU_TxnCommitVisible(brpc::Channel& ch, const std::string& table,
brpc::MysqlResponse resp;
brpc::MysqlTransactionUniquePtr tx =
brpc::NewMysqlTransaction(ch, brpc::MysqlTransactionOptions());
- if (tx == NULL) { *err = "WU1: NewMysqlTransaction NULL"; return false; }
+ if (tx == nullptr) { *err = "WU1: NewMysqlTransaction NULL"; return false; }
if (!RunInTx(ch, tx.get(),
butil::string_printf("INSERT INTO %s VALUES (%d, '%s')",
table.c_str(), id, name),
@@ -453,7 +453,7 @@ static bool WU_TxnRollbackDiscards(brpc::Channel& ch, const std::string& table,
brpc::MysqlResponse resp;
brpc::MysqlTransactionUniquePtr tx =
brpc::NewMysqlTransaction(ch, brpc::MysqlTransactionOptions());
- if (tx == NULL) { *err = "WU2: NewMysqlTransaction NULL"; return false; }
+ if (tx == nullptr) { *err = "WU2: NewMysqlTransaction NULL"; return false; }
if (!RunInTx(ch, tx.get(),
butil::string_printf("INSERT INTO %s VALUES (%d, 'cory')",
table.c_str(), id),
@@ -486,7 +486,7 @@ static bool WU_TxnReadsOwnWrite(brpc::Channel& ch, const std::string& table,
brpc::MysqlResponse resp;
brpc::MysqlTransactionUniquePtr tx =
brpc::NewMysqlTransaction(ch, brpc::MysqlTransactionOptions());
- if (tx == NULL) { *err = "WU3: NewMysqlTransaction NULL"; return false; }
+ if (tx == nullptr) { *err = "WU3: NewMysqlTransaction NULL"; return false; }
if (!RunInTx(ch, tx.get(),
butil::string_printf("INSERT INTO %s VALUES (%d, '%s')",
table.c_str(), id, name),
@@ -524,13 +524,13 @@ static bool WU_PreparedBindInt(brpc::Channel& ch, const std::string& table,
brpc::MysqlStatementUniquePtr stmt = brpc::NewMysqlStatement(
ch, butil::string_printf("SELECT name FROM %s WHERE id=?",
table.c_str()));
- if (stmt == NULL) { *err = "WU4: NewMysqlStatement NULL"; return false; }
+ if (stmt == nullptr) { *err = "WU4: NewMysqlStatement NULL"; return false; }
if (stmt->param_count() != 1u) { *err = "WU4: param_count != 1"; return false; }
brpc::MysqlRequest req(stmt.get());
if (!req.AddParam((int32_t)id)) { *err = "WU4: AddParam failed"; return false; }
brpc::Controller cntl;
- ch.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ ch.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
if (cntl.Failed()) { *err = "WU4 rpc: " + cntl.ErrorText(); return false; }
if (resp.reply_size() < 1 || !resp.reply(0).is_resultset()) {
*err = "WU4: not a resultset"; return false;
@@ -556,7 +556,7 @@ static bool WU_PreparedArithmetic(brpc::Channel& ch, int worker, int iter,
const long long expect = (long long)a + b;
brpc::MysqlStatementUniquePtr stmt =
brpc::NewMysqlStatement(ch, "SELECT CAST(? AS SIGNED) + CAST(? AS SIGNED)");
- if (stmt == NULL) { *err = "WU5: NewMysqlStatement NULL"; return false; }
+ if (stmt == nullptr) { *err = "WU5: NewMysqlStatement NULL"; return false; }
if (stmt->param_count() != 2u) { *err = "WU5: param_count != 2"; return false; }
brpc::MysqlRequest req(stmt.get());
@@ -565,7 +565,7 @@ static bool WU_PreparedArithmetic(brpc::Channel& ch, int worker, int iter,
}
brpc::MysqlResponse resp;
brpc::Controller cntl;
- ch.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ ch.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
if (cntl.Failed()) { *err = "WU5 rpc: " + cntl.ErrorText(); return false; }
if (resp.reply_size() < 1 || !resp.reply(0).is_resultset() ||
resp.reply(0).row_count() != 1u) {
@@ -609,11 +609,11 @@ void* MixWorker(void* p) {
if (!ok) {
a->error = butil::string_printf("worker %d iter %d pick %d: %s",
a->worker_id, iter, pick, err.c_str());
- return NULL;
+ return nullptr;
}
++a->completed;
}
- return NULL;
+ return nullptr;
}
// TEST 1: many bthreads, each looping ~50x over a mix of the reused work
@@ -640,11 +640,11 @@ TEST_F(MysqlPoolConcurrencyTest, ManyWorkersMixedScenarios) {
std::vector<bthread_t> threads(kWorkers);
for (int w = 0; w < kWorkers; ++w) {
- ASSERT_EQ(0, bthread_start_background(&threads[w], NULL, MixWorker,
+ ASSERT_EQ(0, bthread_start_background(&threads[w], nullptr, MixWorker,
&args[w]));
}
for (int w = 0; w < kWorkers; ++w) {
- bthread_join(threads[w], NULL);
+ bthread_join(threads[w], nullptr);
}
for (int w = 0; w < kWorkers; ++w) {
@@ -683,22 +683,22 @@ void* AffinityWorker(void* p) {
brpc::MysqlTransactionUniquePtr tx =
brpc::NewMysqlTransaction(*a->channel, brpc::MysqlTransactionOptions());
- if (tx == NULL) { a->error = "NewMysqlTransaction NULL"; return NULL; }
+ if (tx == nullptr) { a->error = "NewMysqlTransaction NULL"; return nullptr; }
a->socket_id = tx->GetSocketId();
brpc::MysqlResponse resp;
if (!RunInTx(*a->channel, tx.get(),
butil::string_printf("INSERT INTO %s VALUES (%d)",
a->table.c_str(), a->id),
- &resp, &a->error)) return NULL;
+ &resp, &a->error)) return nullptr;
if (resp.reply(0).is_error()) {
a->error = "INSERT err: " + resp.reply(0).error().msg().as_string();
- return NULL;
+ return nullptr;
}
// Read inside the txn: must see exactly our own row (per-worker table).
if (!RunInTx(*a->channel, tx.get(),
butil::string_printf("SELECT v FROM %s", a->table.c_str()),
- &resp, &a->error)) return NULL;
+ &resp, &a->error)) return nullptr;
a->row_count = ResultRowCount(resp);
if (a->row_count == 1) {
long long v = 0;
@@ -708,7 +708,7 @@ void* AffinityWorker(void* p) {
}
a->committed = tx->commit();
if (!a->committed) a->error = "commit failed";
- return NULL;
+ return nullptr;
}
// TEST 2 (focused check a): two transactions in parallel must hold DIFFERENT
@@ -733,10 +733,10 @@ TEST_F(MysqlPoolConcurrencyTest, TwoTransactionsHoldDifferentPinnedSockets) {
AffinityWorkerArgs a1{&_channel, t1, 30900 + iter, 0, -1, -1, false, ""};
bthread_t b0, b1;
- ASSERT_EQ(0, bthread_start_background(&b0, NULL, AffinityWorker, &a0));
- ASSERT_EQ(0, bthread_start_background(&b1, NULL, AffinityWorker, &a1));
- bthread_join(b0, NULL);
- bthread_join(b1, NULL);
+ ASSERT_EQ(0, bthread_start_background(&b0, nullptr, AffinityWorker, &a0));
+ ASSERT_EQ(0, bthread_start_background(&b1, nullptr, AffinityWorker, &a1));
+ bthread_join(b0, nullptr);
+ bthread_join(b1, nullptr);
ASSERT_TRUE(a0.error.empty()) << "iter " << iter << " txn0: " << a0.error;
ASSERT_TRUE(a1.error.empty()) << "iter " << iter << " txn1: " << a1.error;
@@ -781,10 +781,10 @@ void* PreparedWorker(void* p) {
if (!WU_PreparedArithmetic(*a->channel, a->base, k, &err)) {
a->ok = false;
a->error = err;
- return NULL;
+ return nullptr;
}
}
- return NULL;
+ return nullptr;
}
// TEST 3 (focused check b): one transaction + one prepared statement in
@@ -805,10 +805,10 @@ TEST_F(MysqlPoolConcurrencyTest, TransactionPlusPreparedInParallel) {
PreparedWorkerArgs pa{&_channel, 200 + iter, true, ""};
bthread_t bt, bp;
- ASSERT_EQ(0, bthread_start_background(&bt, NULL, AffinityWorker, &ta));
- ASSERT_EQ(0, bthread_start_background(&bp, NULL, PreparedWorker, &pa));
- bthread_join(bt, NULL);
- bthread_join(bp, NULL);
+ ASSERT_EQ(0, bthread_start_background(&bt, nullptr, AffinityWorker, &ta));
+ ASSERT_EQ(0, bthread_start_background(&bp, nullptr, PreparedWorker, &pa));
+ bthread_join(bt, nullptr);
+ bthread_join(bp, nullptr);
ASSERT_TRUE(ta.error.empty()) << "iter " << iter << " txn: " << ta.error;
ASSERT_TRUE(pa.ok) << "iter " << iter << " prepared: " << pa.error;
@@ -862,7 +862,7 @@ void* PinnedTxnWorker(void* p) {
brpc::MysqlTransactionUniquePtr tx =
brpc::NewMysqlTransaction(*a->channel, brpc::MysqlTransactionOptions());
- if (tx == NULL) { a->error = "NewMysqlTransaction NULL"; return NULL; }
+ if (tx == nullptr) { a->error = "NewMysqlTransaction NULL"; return nullptr; }
brpc::MysqlResponse resp;
@@ -871,10 +871,10 @@ void* PinnedTxnWorker(void* p) {
if (!RunInTx(*a->channel, tx.get(),
butil::string_printf("INSERT INTO %s VALUES (%d, 'nova')",
a->table.c_str(), a->id),
- &resp, &a->error)) return NULL;
+ &resp, &a->error)) return nullptr;
if (resp.reply(0).is_error()) {
a->error = "INSERT err: " + resp.reply(0).error().msg().as_string();
- return NULL;
+ return nullptr;
}
// Statement 2: SELECT our own (uncommitted) row back.
@@ -882,11 +882,11 @@ void* PinnedTxnWorker(void* p) {
if (!RunInTx(*a->channel, tx.get(),
butil::string_printf("SELECT name FROM %s WHERE id=%d",
a->table.c_str(), a->id),
- &resp, &a->error)) return NULL;
+ &resp, &a->error)) return nullptr;
if (ResultRowCount(resp) != 1 ||
resp.reply(0).next().field(0).string().as_string() != "nova") {
a->error = "SELECT-own-row did not read back its own write";
- return NULL;
+ return nullptr;
}
// Statement 3: UPDATE our own row.
@@ -894,10 +894,10 @@ void* PinnedTxnWorker(void* p) {
if (!RunInTx(*a->channel, tx.get(),
butil::string_printf("UPDATE %s SET name='zephyr' WHERE id=%d",
a->table.c_str(), a->id),
- &resp, &a->error)) return NULL;
+ &resp, &a->error)) return nullptr;
if (resp.reply(0).is_error()) {
a->error = "UPDATE err: " + resp.reply(0).error().msg().as_string();
- return NULL;
+ return nullptr;
}
// Statement 4: SELECT the updated value back.
@@ -905,16 +905,16 @@ void* PinnedTxnWorker(void* p) {
if (!RunInTx(*a->channel, tx.get(),
butil::string_printf("SELECT name FROM %s WHERE id=%d",
a->table.c_str(), a->id),
- &resp, &a->error)) return NULL;
+ &resp, &a->error)) return nullptr;
if (ResultRowCount(resp) != 1 ||
resp.reply(0).next().field(0).string().as_string() != "zephyr") {
a->error = "SELECT after UPDATE saw wrong value";
- return NULL;
+ return nullptr;
}
// Discard so the per-worker table is empty for the next outer-loop pass.
- if (!tx->rollback()) { a->error = "rollback failed"; return NULL; }
- return NULL;
+ if (!tx->rollback()) { a->error = "rollback failed"; return nullptr; }
+ return nullptr;
}
// TEST A: ConcurrentTxnsStayPinned (the most important check)
@@ -958,11 +958,11 @@ TEST_F(MysqlPoolConcurrencyTest, ConcurrentTxnsStayPinned) {
std::vector<bthread_t> threads(kTxns);
for (int w = 0; w < kTxns; ++w) {
- ASSERT_EQ(0, bthread_start_background(&threads[w], NULL,
+ ASSERT_EQ(0, bthread_start_background(&threads[w], nullptr,
PinnedTxnWorker, &args[w]));
}
for (int w = 0; w < kTxns; ++w) {
- bthread_join(threads[w], NULL);
+ bthread_join(threads[w], nullptr);
}
// No worker errored.
@@ -1018,23 +1018,23 @@ void* AbortWorker(void* p) {
{
brpc::MysqlTransactionUniquePtr tx = brpc::NewMysqlTransaction(
*a->channel, brpc::MysqlTransactionOptions());
- if (tx == NULL) { a->error = "NewMysqlTransaction NULL"; return NULL; }
+ if (tx == nullptr) { a->error = "NewMysqlTransaction NULL"; return nullptr; }
brpc::MysqlResponse resp;
if (!RunInTx(*a->channel, tx.get(),
butil::string_printf("INSERT INTO %s VALUES (%d, 'quill')",
a->table.c_str(), a->id),
- &resp, &a->error)) return NULL;
+ &resp, &a->error)) return nullptr;
if (resp.reply(0).is_error()) {
a->error = "INSERT err: " + resp.reply(0).error().msg().as_string();
- return NULL;
+ return nullptr;
}
if (a->mode == 0) {
- if (!tx->rollback()) { a->error = "explicit rollback failed"; return NULL; }
+ if (!tx->rollback()) { a->error = "explicit rollback failed"; return nullptr; }
}
// mode 1: fall off the end of this scope -> tx dtor auto-rollbacks.
}
- return NULL;
+ return nullptr;
}
// TEST B: ConcurrentTxnAbortAndAutoRollback
@@ -1071,11 +1071,11 @@ TEST_F(MysqlPoolConcurrencyTest, ConcurrentTxnAbortAndAutoRollback) {
std::vector<bthread_t> threads(kWorkersB);
for (int w = 0; w < kWorkersB; ++w) {
- ASSERT_EQ(0, bthread_start_background(&threads[w], NULL,
+ ASSERT_EQ(0, bthread_start_background(&threads[w], nullptr,
AbortWorker, &args[w]));
}
for (int w = 0; w < kWorkersB; ++w) {
- bthread_join(threads[w], NULL);
+ bthread_join(threads[w], nullptr);
}
for (int w = 0; w < kWorkersB; ++w) {
@@ -1122,12 +1122,12 @@ void* ReserveWorker(void* p) {
for (int k = 0; k < 8; ++k) {
brpc::MysqlTransactionUniquePtr tx = brpc::NewMysqlTransaction(
*a->channel, brpc::MysqlTransactionOptions());
- if (tx == NULL) { a->error = "reserve: NewMysqlTransaction NULL"; return NULL; }
+ if (tx == nullptr) { a->error = "reserve: NewMysqlTransaction NULL"; return nullptr; }
brpc::MysqlResponse resp;
- if (!RunInTx(*a->channel, tx.get(), "SELECT 1", &resp, &a->error)) return NULL;
- if (!tx->rollback()) { a->error = "reserve: rollback failed"; return NULL; }
+ if (!RunInTx(*a->channel, tx.get(), "SELECT 1", &resp, &a->error)) return nullptr;
+ if (!tx->rollback()) { a->error = "reserve: rollback failed"; return nullptr; }
}
- return NULL;
+ return nullptr;
}
// Execute a shared prepared statement S with a fresh INT param and verify the
@@ -1146,23 +1146,23 @@ void* StmtExecWorker(void* p) {
for (int k = 0; k < 12; ++k) {
const int32_t v = a->base + k;
brpc::MysqlRequest req(a->stmt);
- if (!req.AddParam(v)) { a->error = "AddParam failed"; return NULL; }
+ if (!req.AddParam(v)) { a->error = "AddParam failed"; return nullptr; }
brpc::MysqlResponse resp;
brpc::Controller cntl;
- a->channel->CallMethod(NULL, &cntl, &req, &resp, NULL);
- if (cntl.Failed()) { a->error = "rpc: " + cntl.ErrorText(); return NULL; }
+ a->channel->CallMethod(nullptr, &cntl, &req, &resp, nullptr);
+ if (cntl.Failed()) { a->error = "rpc: " + cntl.ErrorText(); return nullptr; }
if (resp.reply_size() < 1 || !resp.reply(0).is_resultset() ||
resp.reply(0).row_count() != 1u) {
- a->error = "bad resultset for S"; return NULL;
+ a->error = "bad resultset for S"; return nullptr;
}
long long got = 0;
if (!FieldToLongLong(resp.reply(0).next().field(0), &got) || got != v) {
a->error = butil::string_printf(
"S returned wrong value (got %lld want %d)", got, v);
- return NULL;
+ return nullptr;
}
}
- return NULL;
+ return nullptr;
}
// TEST C: PreparedRePreparesWhenConnectionStolen
@@ -1192,7 +1192,7 @@ TEST_F(MysqlPoolConcurrencyTest, PreparedRePreparesWhenConnectionStolen) {
brpc::MysqlStatementUniquePtr S =
brpc::NewMysqlStatement(_channel, "SELECT CAST(? AS SIGNED) AS v");
- ASSERT_TRUE(S != NULL);
+ ASSERT_TRUE(S != nullptr);
ASSERT_EQ(1u, S->param_count());
// Execute S once to cache its stmt_id on whatever connection it lands on.
@@ -1200,7 +1200,7 @@ TEST_F(MysqlPoolConcurrencyTest, PreparedRePreparesWhenConnectionStolen) {
brpc::MysqlRequest req(S.get());
ASSERT_TRUE(req.AddParam((int32_t)140000));
brpc::Controller cntl;
- _channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ _channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_TRUE(resp.reply_size() >= 1 && resp.reply(0).is_resultset());
long long got = 0;
@@ -1218,7 +1218,7 @@ TEST_F(MysqlPoolConcurrencyTest, PreparedRePreparesWhenConnectionStolen) {
for (int w = 0; w < kReservers; ++w) {
res_args[w].channel = &_channel;
- ASSERT_EQ(0, bthread_start_background(&res_threads[w], NULL,
+ ASSERT_EQ(0, bthread_start_background(&res_threads[w], nullptr,
ReserveWorker, &res_args[w]));
}
for (int w = 0; w < kExecutors; ++w) {
@@ -1226,14 +1226,14 @@ TEST_F(MysqlPoolConcurrencyTest, PreparedRePreparesWhenConnectionStolen) {
exec_args[w].stmt = S.get();
// Unique param ranges per worker+loop so a wrong value is unambiguous.
exec_args[w].base = 141000 + loop * 1000 + w * 100;
- ASSERT_EQ(0, bthread_start_background(&exec_threads[w], NULL,
+ ASSERT_EQ(0, bthread_start_background(&exec_threads[w], nullptr,
StmtExecWorker, &exec_args[w]));
}
for (int w = 0; w < kReservers; ++w) {
- bthread_join(res_threads[w], NULL);
+ bthread_join(res_threads[w], nullptr);
}
for (int w = 0; w < kExecutors; ++w) {
- bthread_join(exec_threads[w], NULL);
+ bthread_join(exec_threads[w], nullptr);
}
for (int w = 0; w < kReservers; ++w) {
diff --git a/test/brpc_mysql_prepared_integration_unittest.cpp b/test/brpc_mysql_prepared_integration_unittest.cpp
index e14aea00..a6f153aa 100644
--- a/test/brpc_mysql_prepared_integration_unittest.cpp
+++ b/test/brpc_mysql_prepared_integration_unittest.cpp
@@ -23,7 +23,7 @@
// raw socket; here we drive the actual client stack a user would use.
//
// Each fat test chains several prepared-statement behaviors (param counting,
-// binding, typed fetch, re-execution, NULL handling, error paths) so the
+// binding, typed fetch, re-execution, nullptr handling, error paths) so the
// test boundaries reflect our own grouping of the client surface.
//
// HARNESS: Reuses the self-spawned / already-running mysqld pattern
@@ -104,7 +104,7 @@ static bool g_schema_ready = false;
static std::string TestDataDir() {
char cwd[1024];
- if (getcwd(cwd, sizeof(cwd)) == NULL) {
+ if (getcwd(cwd, sizeof(cwd)) == nullptr) {
return std::string("/tmp/mysql_ps_data_for_test");
}
return std::string(cwd) + "/mysql_ps_data_for_test";
@@ -212,7 +212,7 @@ static void StartServerOnce() {
(char*)logerr_arg.c_str(),
(char*)"--mysqlx=OFF",
(char*)"--bind-address=127.0.0.1",
- NULL};
+ nullptr};
if (execvp(MYSQLD_BIN, argv) < 0) {
puts("Fail to run " MYSQLD_BIN);
exit(1);
@@ -265,7 +265,7 @@ static bool RunPlainQuery(brpc::Channel* channel, const std::string& sql) {
}
brpc::MysqlResponse response;
brpc::Controller cntl;
- channel->CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel->CallMethod(nullptr, &cntl, &request, &response, nullptr);
if (cntl.Failed()) {
return false;
}
@@ -361,7 +361,7 @@ TEST_F(MysqlPreparedTest, ParamCountsAndNoParamSelect) {
brpc::MysqlRequest request(s.get());
brpc::MysqlResponse response;
brpc::Controller cntl;
- channel_.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel_.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_GE(response.reply_size(), 1u);
const brpc::MysqlReply& r = response.reply(0);
@@ -384,7 +384,7 @@ TEST_F(MysqlPreparedTest, BindAndExecuteIntStringAndArithmetic) {
ASSERT_TRUE(request.AddParam((int32_t)417));
brpc::MysqlResponse response;
brpc::Controller cntl;
- channel_.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel_.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_GE(response.reply_size(), 1u);
const brpc::MysqlReply& r = response.reply(0);
@@ -403,7 +403,7 @@ TEST_F(MysqlPreparedTest, BindAndExecuteIntStringAndArithmetic) {
ASSERT_TRUE(request.AddParam(butil::StringPiece("cobalt")));
brpc::MysqlResponse response;
brpc::Controller cntl;
- channel_.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel_.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_GE(response.reply_size(), 1u);
const brpc::MysqlReply& r = response.reply(0);
@@ -429,7 +429,7 @@ TEST_F(MysqlPreparedTest, BindAndExecuteIntStringAndArithmetic) {
ASSERT_TRUE(request.AddParam((int32_t)28));
brpc::MysqlResponse response;
brpc::Controller cntl;
- channel_.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel_.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_GE(response.reply_size(), 1u);
const brpc::MysqlReply& r = response.reply(0);
@@ -465,7 +465,7 @@ TEST_F(MysqlPreparedTest, ReExecuteAndTypedColumnFetch) {
ASSERT_TRUE(request.AddParam(c.id));
brpc::MysqlResponse response;
brpc::Controller cntl;
- channel_.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel_.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_GE(response.reply_size(), 1u);
const brpc::MysqlReply& r = response.reply(0);
@@ -484,7 +484,7 @@ TEST_F(MysqlPreparedTest, ReExecuteAndTypedColumnFetch) {
ASSERT_TRUE(request.AddParam((int32_t)528));
brpc::MysqlResponse response;
brpc::Controller cntl;
- channel_.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel_.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_GE(response.reply_size(), 1u);
const brpc::MysqlReply& r = response.reply(0);
@@ -529,7 +529,7 @@ TEST_F(MysqlPreparedTest, NullColumnAndLiteralNullAreNil) {
ASSERT_TRUE(request.AddParam((int32_t)639));
brpc::MysqlResponse response;
brpc::Controller cntl;
- channel_.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel_.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_GE(response.reply_size(), 1u);
const brpc::MysqlReply& r = response.reply(0);
@@ -538,14 +538,14 @@ TEST_F(MysqlPreparedTest, NullColumnAndLiteralNullAreNil) {
EXPECT_TRUE(r.next().field(0).is_nil());
}
- // A literal NULL in the SELECT list also comes back nil.
+ // A literal nullptr in the SELECT list also comes back nil.
{
PREPARE_OR_FAIL(s, "SELECT NULL");
EXPECT_EQ(0u, s->param_count());
brpc::MysqlRequest request(s.get());
brpc::MysqlResponse response;
brpc::Controller cntl;
- channel_.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel_.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_GE(response.reply_size(), 1u);
const brpc::MysqlReply& r = response.reply(0);
@@ -573,7 +573,7 @@ TEST_F(MysqlPreparedTest, MalformedAndParamMismatchSurfaceErrors) {
brpc::MysqlRequest request(s.get());
brpc::MysqlResponse response;
brpc::Controller cntl;
- channel_.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel_.CallMethod(nullptr, &cntl, &request, &response, nullptr);
if (cntl.Failed()) {
SUCCEED() << "execute of malformed statement failed as expected: "
<< cntl.ErrorText();
@@ -592,7 +592,7 @@ TEST_F(MysqlPreparedTest, MalformedAndParamMismatchSurfaceErrors) {
brpc::MysqlRequest request(s.get());
brpc::MysqlResponse response;
brpc::Controller cntl;
- channel_.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel_.CallMethod(nullptr, &cntl, &request, &response, nullptr);
if (cntl.Failed()) {
SUCCEED() << "mismatched param count failed the RPC as expected: "
<< cntl.ErrorText();
@@ -618,7 +618,7 @@ TEST_F(MysqlPreparedTest, StatementReuseAndIndependentStatement) {
brpc::MysqlRequest request(s1.get());
brpc::MysqlResponse response;
brpc::Controller cntl;
- channel_.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel_.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_GE(response.reply_size(), 1u);
const brpc::MysqlReply& r = response.reply(0);
@@ -644,7 +644,7 @@ TEST_F(MysqlPreparedTest, StatementReuseAndIndependentStatement) {
ASSERT_TRUE(request.AddParam((int32_t)417));
brpc::MysqlResponse response;
brpc::Controller cntl;
- channel_.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel_.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_GE(response.reply_size(), 1u);
ASSERT_TRUE(response.reply(0).is_resultset());
@@ -704,7 +704,7 @@ TEST_F(MysqlPreparedTest, BinaryTimeAndDateTimeParsing) {
// DATE column: only the date part on the wire (len==4) -> "YYYY-MM-DD".
{"SELECT CAST('2021-03-04' AS DATE)", "2021-03-04"},
// TIME zero value: encoded with len==0 (no field bytes on the wire).
- // This must surface as the zero string "00:00:00", NOT as NULL.
+ // This must surface as the zero string "00:00:00", NOT as nullptr.
{"SELECT CAST('00:00:00' AS TIME)", "00:00:00"},
};
@@ -715,7 +715,7 @@ TEST_F(MysqlPreparedTest, BinaryTimeAndDateTimeParsing) {
brpc::MysqlRequest request(s.get());
brpc::MysqlResponse response;
brpc::Controller cntl;
- channel_.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel_.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_GE(response.reply_size(), 1u);
const brpc::MysqlReply& r = response.reply(0);
diff --git a/test/brpc_mysql_txn_integration_unittest.cpp b/test/brpc_mysql_txn_integration_unittest.cpp
index 3d2325ae..5d554299 100644
--- a/test/brpc_mysql_txn_integration_unittest.cpp
+++ b/test/brpc_mysql_txn_integration_unittest.cpp
@@ -95,7 +95,7 @@ static std::string s_password;
static std::string TestDataDir() {
char cwd[1024];
- if (getcwd(cwd, sizeof(cwd)) == NULL) {
+ if (getcwd(cwd, sizeof(cwd)) == nullptr) {
return std::string("/tmp/mysql_txn_data_for_test");
}
return std::string(cwd) + "/mysql_txn_data_for_test";
@@ -199,7 +199,7 @@ static void RunMysqlServer() {
(char*)logerr_arg.c_str(),
(char*)"--mysqlx=OFF",
(char*)"--bind-address=127.0.0.1",
- NULL};
+ nullptr};
if (execvp(MYSQLD_BIN, argv) < 0) {
puts("Fail to run " MYSQLD_BIN);
exit(1);
@@ -232,7 +232,7 @@ static bool RunPlain(brpc::Channel& channel, const std::string& sql,
return false;
}
brpc::Controller cntl;
- channel.CallMethod(NULL, &cntl, &req, resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, resp, nullptr);
return !cntl.Failed();
}
@@ -245,7 +245,7 @@ static bool RunInTx(brpc::Channel& channel, const brpc::MysqlTransaction* tx,
return false;
}
brpc::Controller cntl;
- channel.CallMethod(NULL, &cntl, &req, resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, resp, nullptr);
return !cntl.Failed();
}
@@ -353,7 +353,7 @@ TEST_F(MysqlTxnIntegrationTest, CommitPublishesRollbackRestores) {
{
brpc::MysqlTransactionUniquePtr tx =
brpc::NewMysqlTransaction(_channel, brpc::MysqlTransactionOptions());
- ASSERT_TRUE(tx != NULL) << "failed to start transaction";
+ ASSERT_TRUE(tx != nullptr) << "failed to start transaction";
ASSERT_TRUE(RunInTx(_channel, tx.get(),
"INSERT INTO " + Table() + " VALUES (3107, 'quill')",
&resp));
@@ -377,7 +377,7 @@ TEST_F(MysqlTxnIntegrationTest, CommitPublishesRollbackRestores) {
{
brpc::MysqlTransactionUniquePtr tx =
brpc::NewMysqlTransaction(_channel, brpc::MysqlTransactionOptions());
- ASSERT_TRUE(tx != NULL);
+ ASSERT_TRUE(tx != nullptr);
ASSERT_TRUE(RunInTx(_channel, tx.get(),
"INSERT INTO " + Table() + " VALUES (5288, 'brindle')",
&resp));
@@ -391,7 +391,7 @@ TEST_F(MysqlTxnIntegrationTest, CommitPublishesRollbackRestores) {
{
brpc::MysqlTransactionUniquePtr tx =
brpc::NewMysqlTransaction(_channel, brpc::MysqlTransactionOptions());
- ASSERT_TRUE(tx != NULL);
+ ASSERT_TRUE(tx != nullptr);
ASSERT_TRUE(RunInTx(_channel, tx.get(),
"DELETE FROM " + Table() + " WHERE id = 3107", &resp));
EXPECT_TRUE(ExpectOk(resp));
@@ -414,7 +414,7 @@ TEST_F(MysqlTxnIntegrationTest, CommitPublishesRollbackRestores) {
TEST_F(MysqlTxnIntegrationTest, OwnWriteVisibleOthersIsolated) {
brpc::MysqlTransactionUniquePtr tx =
brpc::NewMysqlTransaction(_channel, brpc::MysqlTransactionOptions());
- ASSERT_TRUE(tx != NULL);
+ ASSERT_TRUE(tx != nullptr);
brpc::MysqlResponse resp;
ASSERT_TRUE(RunInTx(_channel, tx.get(),
@@ -465,7 +465,7 @@ TEST_F(MysqlTxnIntegrationTest, AutocommitOnDurableOffRollbackable) {
{
brpc::MysqlTransactionUniquePtr tx =
brpc::NewMysqlTransaction(_channel, brpc::MysqlTransactionOptions());
- ASSERT_TRUE(tx != NULL);
+ ASSERT_TRUE(tx != nullptr);
ASSERT_TRUE(RunInTx(_channel, tx.get(), "SET autocommit = 0", &resp));
EXPECT_TRUE(ExpectOk(resp));
ASSERT_TRUE(RunInTx(_channel, tx.get(),
@@ -491,7 +491,7 @@ TEST_F(MysqlTxnIntegrationTest, GroupedInsertsThenSavepointPartialUndo) {
{
brpc::MysqlTransactionUniquePtr tx =
brpc::NewMysqlTransaction(_channel, brpc::MysqlTransactionOptions());
- ASSERT_TRUE(tx != NULL);
+ ASSERT_TRUE(tx != nullptr);
ASSERT_TRUE(RunInTx(_channel, tx.get(),
"INSERT INTO " + Table() + " VALUES (211, 'one')",
&resp));
@@ -518,7 +518,7 @@ TEST_F(MysqlTxnIntegrationTest, GroupedInsertsThenSavepointPartialUndo) {
{
brpc::MysqlTransactionUniquePtr tx =
brpc::NewMysqlTransaction(_channel, brpc::MysqlTransactionOptions());
- ASSERT_TRUE(tx != NULL);
+ ASSERT_TRUE(tx != nullptr);
ASSERT_TRUE(RunInTx(_channel, tx.get(),
"INSERT INTO " + Table() + " VALUES (901, 'kept')",
&resp));
@@ -565,7 +565,7 @@ TEST_F(MysqlTxnIntegrationTest, DuplicateKeyAndReadOnlyWriteReportErr) {
{
brpc::MysqlTransactionUniquePtr tx =
brpc::NewMysqlTransaction(_channel, brpc::MysqlTransactionOptions());
- ASSERT_TRUE(tx != NULL);
+ ASSERT_TRUE(tx != nullptr);
// Duplicate-key insert -> ERR packet (errno 1062, ER_DUP_ENTRY).
ASSERT_TRUE(RunInTx(_channel, tx.get(),
"INSERT INTO " + Table() + " VALUES (1505, 'clash')",
@@ -585,7 +585,7 @@ TEST_F(MysqlTxnIntegrationTest, DuplicateKeyAndReadOnlyWriteReportErr) {
opts.readonly = true;
brpc::MysqlTransactionUniquePtr tx =
brpc::NewMysqlTransaction(_channel, opts);
- ASSERT_TRUE(tx != NULL) << "failed to start read-only transaction";
+ ASSERT_TRUE(tx != nullptr) << "failed to start read-only transaction";
ASSERT_TRUE(RunInTx(_channel, tx.get(),
"INSERT INTO " + Table() + " VALUES (1777, 'nope')",
&resp));
diff --git a/test/brpc_naming_service_filter_unittest.cpp b/test/brpc_naming_service_filter_unittest.cpp
index 387aeb53..e036384e 100644
--- a/test/brpc_naming_service_filter_unittest.cpp
+++ b/test/brpc_naming_service_filter_unittest.cpp
@@ -66,7 +66,7 @@ TEST_F(NamingServiceFilterTest, sanity) {
ASSERT_EQ(0, butil::hostname2endpoint("10.128.0.1:1234", &ep));
for (int i = 0; i < 10; ++i) {
brpc::SocketUniquePtr tmp_sock;
- brpc::LoadBalancer::SelectIn sel_in = { 0, false, false, 0, NULL };
+ brpc::LoadBalancer::SelectIn sel_in = { 0, false, false, 0, nullptr };
brpc::LoadBalancer::SelectOut sel_out(&tmp_sock);
ASSERT_EQ(0, channel._lb->SelectServer(sel_in, &sel_out));
ASSERT_EQ(ep, tmp_sock->remote_side());
diff --git a/test/brpc_naming_service_unittest.cpp b/test/brpc_naming_service_unittest.cpp
index 0ba2be66..30c41923 100644
--- a/test/brpc_naming_service_unittest.cpp
+++ b/test/brpc_naming_service_unittest.cpp
@@ -237,11 +237,11 @@ TEST(NamingServiceTest, remotefile) {
brpc::Server server1;
UserNamingServiceImpl svc1;
ASSERT_EQ(0, server1.AddService(&svc1, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server1.Start("localhost:8635", NULL));
+ ASSERT_EQ(0, server1.Start("localhost:8635", nullptr));
brpc::Server server2;
UserNamingServiceImpl svc2;
ASSERT_EQ(0, server2.AddService(&svc2, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server2.Start("localhost:8636", NULL));
+ ASSERT_EQ(0, server2.Start("localhost:8636", nullptr));
butil::EndPoint n1;
ASSERT_EQ(0, butil::str2endpoint("0.0.0.0:8635", &n1));
@@ -449,7 +449,7 @@ TEST(NamingServiceTest, consul_with_backup_file) {
ASSERT_EQ(0, server.AddService(&svc,
brpc::SERVER_DOESNT_OWN_SERVICE,
restful_map.c_str()));
- ASSERT_EQ(0, server.Start("localhost:8500", NULL));
+ ASSERT_EQ(0, server.Start("localhost:8500", nullptr));
bthread_usleep(5000000);
@@ -664,7 +664,7 @@ TEST(NamingServiceTest, discovery_sanity) {
"/discovery/cancel => Cancel";
ASSERT_EQ(0, server.AddService(&svc, brpc::SERVER_DOESNT_OWN_SERVICE,
rest_mapping.c_str()));
- ASSERT_EQ(0, server.Start("localhost:8635", NULL));
+ ASSERT_EQ(0, server.Start("localhost:8635", nullptr));
brpc::policy::DiscoveryNamingService dcns;
std::vector<brpc::ServerNode> servers;
diff --git a/test/brpc_nova_pbrpc_protocol_unittest.cpp b/test/brpc_nova_pbrpc_protocol_unittest.cpp
index cfc41bd6..2d9da47a 100644
--- a/test/brpc_nova_pbrpc_protocol_unittest.cpp
+++ b/test/brpc_nova_pbrpc_protocol_unittest.cpp
@@ -104,7 +104,7 @@ protected:
virtual void TearDown() {};
void VerifyMessage(brpc::InputMessageBase* msg) {
- if (msg->_socket == NULL) {
+ if (msg->_socket == nullptr) {
_socket->ReAddress(&msg->_socket);
}
msg->_arg = &_server;
@@ -113,7 +113,7 @@ protected:
void ProcessMessage(void (*process)(brpc::InputMessageBase*),
brpc::InputMessageBase* msg, bool set_eof) {
- if (msg->_socket == NULL) {
+ if (msg->_socket == nullptr) {
_socket->ReAddress(&msg->_socket);
}
msg->_arg = &_server;
@@ -222,13 +222,13 @@ TEST_F(NovaTest, complete_flow) {
brpc::SerializeRequestDefault(&request_buf, &cntl, &req);
ASSERT_FALSE(cntl.Failed());
brpc::policy::PackNovaRequest(
- &total_buf, NULL, cntl.call_id().value,
+ &total_buf, nullptr, cntl.call_id().value,
test::EchoService::descriptor()->method(0), &cntl, request_buf, &_auth);
ASSERT_FALSE(cntl.Failed());
// Verify and handle request
brpc::ParseResult req_pr =
- brpc::policy::ParseNsheadMessage(&total_buf, NULL, false, NULL);
+ brpc::policy::ParseNsheadMessage(&total_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, req_pr.error());
brpc::InputMessageBase* req_msg = req_pr.message();
VerifyMessage(req_msg);
@@ -238,7 +238,7 @@ TEST_F(NovaTest, complete_flow) {
butil::IOPortal response_buf;
response_buf.append_from_file_descriptor(_pipe_fds[0], 1024);
brpc::ParseResult res_pr =
- brpc::policy::ParseNsheadMessage(&response_buf, NULL, false, NULL);
+ brpc::policy::ParseNsheadMessage(&response_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, res_pr.error());
brpc::InputMessageBase* res_msg = res_pr.message();
ProcessMessage(brpc::policy::ProcessNovaResponse, res_msg, false);
@@ -261,13 +261,13 @@ TEST_F(NovaTest, close_in_callback) {
brpc::SerializeRequestDefault(&request_buf, &cntl, &req);
ASSERT_FALSE(cntl.Failed());
brpc::policy::PackNovaRequest(
- &total_buf, NULL, cntl.call_id().value,
+ &total_buf, nullptr, cntl.call_id().value,
test::EchoService::descriptor()->method(0), &cntl, request_buf, &_auth);
ASSERT_FALSE(cntl.Failed());
// Handle request
brpc::ParseResult req_pr =
- brpc::policy::ParseNsheadMessage(&total_buf, NULL, false, NULL);
+ brpc::policy::ParseNsheadMessage(&total_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, req_pr.error());
brpc::InputMessageBase* req_msg = req_pr.message();
ProcessMessage(brpc::policy::ProcessNsheadRequest, req_msg, false);
diff --git a/test/brpc_p2c_ewma_load_balancer_unittest.cpp b/test/brpc_p2c_ewma_load_balancer_unittest.cpp
index 922bfc39..43532cac 100644
--- a/test/brpc_p2c_ewma_load_balancer_unittest.cpp
+++ b/test/brpc_p2c_ewma_load_balancer_unittest.cpp
@@ -61,7 +61,7 @@ brpc::ServerId CreateServer(const char* addr, const char* tag = "") {
// Report a call that took `latency_us' back to the load balancer.
void FeedbackLatency(brpc::LoadBalancer* lb, brpc::SocketId server_id,
int64_t latency_us, int error_code = 0,
- const brpc::Controller* cntl = NULL) {
+ const brpc::Controller* cntl = nullptr) {
brpc::LoadBalancer::CallInfo info;
info.begin_time_us = butil::gettimeofday_us() - latency_us;
info.server_id = server_id;
@@ -79,13 +79,13 @@ protected:
_lb->Destroy();
}
- int Select(brpc::SocketUniquePtr* ptr, bool* need_feedback = NULL,
- const brpc::ExcludedServers* excluded = NULL) {
+ int Select(brpc::SocketUniquePtr* ptr, bool* need_feedback = nullptr,
+ const brpc::ExcludedServers* excluded = nullptr) {
brpc::LoadBalancer::SelectIn in = {
butil::gettimeofday_us(), true, false, 0u, excluded };
brpc::LoadBalancer::SelectOut out(ptr);
const int rc = _lb->SelectServer(in, &out);
- if (need_feedback != NULL) {
+ if (need_feedback != nullptr) {
*need_feedback = out.need_feedback;
}
return rc;
@@ -207,7 +207,7 @@ TEST_F(P2CEwmaLoadBalancerTest, weighted_split_by_inflight) {
const brpc::ServerId w4 = CreateServer("127.0.0.1:7789", "4");
brpc::policy::P2CEwmaLoadBalancer* lb =
_lb->New(butil::StringPiece("choices=3"));
- ASSERT_TRUE(lb != NULL);
+ ASSERT_TRUE(lb != nullptr);
ASSERT_TRUE(lb->AddServer(w1));
ASSERT_TRUE(lb->AddServer(w2));
ASSERT_TRUE(lb->AddServer(w4));
@@ -217,7 +217,7 @@ TEST_F(P2CEwmaLoadBalancerTest, weighted_split_by_inflight) {
for (int i = 0; i < kRounds; ++i) {
brpc::SocketUniquePtr ptr;
brpc::LoadBalancer::SelectIn in = {
- butil::gettimeofday_us(), true, false, 0u, NULL };
+ butil::gettimeofday_us(), true, false, 0u, nullptr };
brpc::LoadBalancer::SelectOut out(&ptr);
ASSERT_EQ(0, lb->SelectServer(in, &out));
++counts[ptr->id()];
@@ -274,28 +274,28 @@ TEST_F(P2CEwmaLoadBalancerTest, excluded_servers) {
excluded->Add(a.id);
for (int i = 0; i < 20; ++i) {
brpc::SocketUniquePtr ptr;
- ASSERT_EQ(0, Select(&ptr, NULL, excluded));
+ ASSERT_EQ(0, Select(&ptr, nullptr, excluded));
ASSERT_EQ(b.id, ptr->id());
FeedbackLatency(_lb, b.id, 1000);
}
// All servers excluded: still take the last chance instead of failing.
excluded->Add(b.id);
brpc::SocketUniquePtr ptr;
- ASSERT_EQ(0, Select(&ptr, NULL, excluded));
+ ASSERT_EQ(0, Select(&ptr, nullptr, excluded));
brpc::ExcludedServers::Destroy(excluded);
}
TEST_F(P2CEwmaLoadBalancerTest, invalid_parameters) {
brpc::LoadBalancer* lb = _lb->New(butil::StringPiece(""));
- ASSERT_TRUE(lb != NULL);
+ ASSERT_TRUE(lb != nullptr);
lb->Destroy();
lb = _lb->New(butil::StringPiece("choices=4 tau_ms=5000"));
- ASSERT_TRUE(lb != NULL);
+ ASSERT_TRUE(lb != nullptr);
lb->Destroy();
- ASSERT_TRUE(_lb->New(butil::StringPiece("choices=1")) == NULL);
- ASSERT_TRUE(_lb->New(butil::StringPiece("choices=abc")) == NULL);
- ASSERT_TRUE(_lb->New(butil::StringPiece("tau_ms=0")) == NULL);
- ASSERT_TRUE(_lb->New(butil::StringPiece("unknown=1")) == NULL);
+ ASSERT_TRUE(_lb->New(butil::StringPiece("choices=1")) == nullptr);
+ ASSERT_TRUE(_lb->New(butil::StringPiece("choices=abc")) == nullptr);
+ ASSERT_TRUE(_lb->New(butil::StringPiece("tau_ms=0")) == nullptr);
+ ASSERT_TRUE(_lb->New(butil::StringPiece("unknown=1")) == nullptr);
}
struct ChurnArg {
@@ -309,7 +309,7 @@ void* SelectAndFeedback(void* void_arg) {
while (!arg->stop.load(butil::memory_order_relaxed)) {
brpc::SocketUniquePtr ptr;
brpc::LoadBalancer::SelectIn in = {
- butil::gettimeofday_us(), true, false, 0u, NULL };
+ butil::gettimeofday_us(), true, false, 0u, nullptr };
brpc::LoadBalancer::SelectOut out(&ptr);
if (arg->lb->SelectServer(in, &out) == 0) {
arg->nselected.fetch_add(1, butil::memory_order_relaxed);
@@ -318,7 +318,7 @@ void* SelectAndFeedback(void* void_arg) {
}
}
}
- return NULL;
+ return nullptr;
}
TEST_F(P2CEwmaLoadBalancerTest, concurrent_select_with_churn) {
@@ -337,7 +337,7 @@ TEST_F(P2CEwmaLoadBalancerTest, concurrent_select_with_churn) {
pthread_t threads[4];
for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
ASSERT_EQ(0, pthread_create(
- &threads[i], NULL, SelectAndFeedback, &arg));
+ &threads[i], nullptr, SelectAndFeedback, &arg));
}
// Churn membership while selections are running.
const int64_t stop_at_us = butil::gettimeofday_us() + 1000000L;
@@ -347,7 +347,7 @@ TEST_F(P2CEwmaLoadBalancerTest, concurrent_select_with_churn) {
}
arg.stop.store(true);
for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
- ASSERT_EQ(0, pthread_join(threads[i], NULL));
+ ASSERT_EQ(0, pthread_join(threads[i], nullptr));
}
LOG(INFO) << "selected " << arg.nselected.load() << " times";
ASSERT_GT(arg.nselected.load(), 0u);
@@ -372,7 +372,7 @@ TEST_F(P2CEwmaLoadBalancerTest, error_punish_is_capped) {
const std::string desc = os.str();
const size_t pos = desc.find("ewma_us=");
ASSERT_NE(std::string::npos, pos) << desc;
- const int64_t ewma_us = strtoll(desc.c_str() + pos + 8, NULL, 10);
+ const int64_t ewma_us = strtoll(desc.c_str() + pos + 8, nullptr, 10);
ASSERT_LE(ewma_us, brpc::policy::FLAGS_p2c_max_punish_ms * 1000L) << desc;
}
@@ -391,7 +391,7 @@ void* FeedbackHammer(void* void_arg) {
++n;
}
arg->nfeedback.fetch_add(n, butil::memory_order_relaxed);
- return NULL;
+ return nullptr;
}
TEST_F(P2CEwmaLoadBalancerTest, feedback_lock_overhead) {
@@ -409,12 +409,12 @@ TEST_F(P2CEwmaLoadBalancerTest, feedback_lock_overhead) {
const int64_t begin_us = butil::gettimeofday_us();
for (size_t i = 0; i < nthread; ++i) {
ASSERT_EQ(0, pthread_create(
- &threads[i], NULL, FeedbackHammer, &arg));
+ &threads[i], nullptr, FeedbackHammer, &arg));
}
usleep(500 * 1000);
arg.stop.store(true);
for (size_t i = 0; i < nthread; ++i) {
- ASSERT_EQ(0, pthread_join(threads[i], NULL));
+ ASSERT_EQ(0, pthread_join(threads[i], nullptr));
}
const int64_t elapsed_us = butil::gettimeofday_us() - begin_us;
const size_t n = arg.nfeedback.load();
diff --git a/test/brpc_prometheus_metrics_unittest.cpp b/test/brpc_prometheus_metrics_unittest.cpp
index 471fd40a..166d6f80 100644
--- a/test/brpc_prometheus_metrics_unittest.cpp
+++ b/test/brpc_prometheus_metrics_unittest.cpp
@@ -59,7 +59,7 @@ TEST(PrometheusMetrics, sanity) {
brpc::Server server;
DummyEchoServiceImpl echo_svc;
ASSERT_EQ(0, server.AddService(&echo_svc, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start("127.0.0.1:8614", NULL));
+ ASSERT_EQ(0, server.Start("127.0.0.1:8614", nullptr));
const std::list<std::string> labels = {"label1", "label2"};
bvar::MultiDimension<bvar::Adder<uint32_t> > my_madder("madder", labels);
@@ -84,7 +84,7 @@ TEST(PrometheusMetrics, sanity) {
ASSERT_EQ(0, channel.Init("127.0.0.1:8614", &channel_opts));
brpc::Controller cntl;
cntl.http_request().uri() = "/brpc_metrics";
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed());
std::string res = cntl.response_attachment().to_string();
LOG(INFO) << "output:\n" << res;
diff --git a/test/brpc_proto_unittest.cpp b/test/brpc_proto_unittest.cpp
index 88ed40da..d4e6aa82 100644
--- a/test/brpc_proto_unittest.cpp
+++ b/test/brpc_proto_unittest.cpp
@@ -36,11 +36,11 @@ void BuildDependency(const FileDescriptor *file_desc, DescriptorPool *pool) {
BuildDependency(fd, pool);
FileDescriptorProto proto;
fd->CopyTo(&proto);
- ASSERT_TRUE(pool->BuildFile(proto) != NULL);
+ ASSERT_TRUE(pool->BuildFile(proto) != nullptr);
}
FileDescriptorProto proto;
file_desc->CopyTo(&proto);
- ASSERT_TRUE(pool->BuildFile(proto) != NULL);
+ ASSERT_TRUE(pool->BuildFile(proto) != nullptr);
}
TEST(ProtoTest, proto) {
@@ -53,14 +53,14 @@ TEST(ProtoTest, proto) {
FileDescriptorProto file_desc_proto;
file_desc->CopyTo(&file_desc_proto);
const FileDescriptor *new_file_desc = pool.BuildFile(file_desc_proto);
- ASSERT_TRUE(new_file_desc != NULL);
+ ASSERT_TRUE(new_file_desc != nullptr);
const Descriptor *new_desc = new_file_desc->FindMessageTypeByName(desc->name());
- ASSERT_TRUE(new_desc != NULL);
+ ASSERT_TRUE(new_desc != nullptr);
meta.set_correlation_id(123);
std::string data;
ASSERT_TRUE(meta.SerializeToString(&data));
std::unique_ptr<Message> msg(factory.GetPrototype(new_desc)->New());
- ASSERT_TRUE(msg != NULL);
+ ASSERT_TRUE(msg != nullptr);
ASSERT_TRUE(msg->ParseFromString(data));
ASSERT_TRUE(msg->SerializeToString(&data));
policy::RpcMeta new_meta;
diff --git a/test/brpc_protobuf_json_unittest.cpp b/test/brpc_protobuf_json_unittest.cpp
index b5ad0bb2..eeadc4f7 100644
--- a/test/brpc_protobuf_json_unittest.cpp
+++ b/test/brpc_protobuf_json_unittest.cpp
@@ -52,7 +52,7 @@ protected:
inline int64_t gettimeofday_us() {
timeval now;
- gettimeofday(&now, NULL);
+ gettimeofday(&now, nullptr);
return now.tv_sec * 1000000L + now.tv_usec;
}
@@ -265,7 +265,7 @@ TEST_F(ProtobufJsonTest, json_to_pb_unicode_case) {
ASSERT_TRUE(!info1.compare(info2));
butil::IOBuf buf;
butil::IOBufAsZeroCopyOutputStream stream(&buf);
- bool res = json2pb::ProtoMessageToJson(address_book, &stream, NULL);
+ bool res = json2pb::ProtoMessageToJson(address_book, &stream, nullptr);
ASSERT_TRUE(res);
butil::IOBufAsZeroCopyInputStream stream2(buf);
AddressBook address_book_test3;
@@ -830,7 +830,7 @@ TEST_F(ProtobufJsonTest, pb_to_json_normal_case) {
printf("----------test pb to json------------\n\n");
json2pb::Pb2JsonOptions option;
option.bytes_to_base64 = true;
- bool ret = json2pb::ProtoMessageToJson(address_book, &info1, option, NULL);
+ bool ret = json2pb::ProtoMessageToJson(address_book, &info1, option, nullptr);
ASSERT_TRUE(ret);
#ifndef RAPIDJSON_VERSION_0_1
@@ -856,7 +856,7 @@ TEST_F(ProtobufJsonTest, pb_to_json_normal_case) {
{
json2pb::Pb2JsonOptions option;
option.bytes_to_base64 = true;
- ret = ProtoMessageToJson(address_book, &info1, option, NULL);
+ ret = ProtoMessageToJson(address_book, &info1, option, nullptr);
}
ASSERT_TRUE(ret);
@@ -884,7 +884,7 @@ TEST_F(ProtobufJsonTest, pb_to_json_normal_case) {
json2pb::Pb2JsonOptions option;
option.bytes_to_base64 = true;
option.enum_option = json2pb::OUTPUT_ENUM_BY_NUMBER;
- ret = ProtoMessageToJson(address_book, &info1, option, NULL);
+ ret = ProtoMessageToJson(address_book, &info1, option, nullptr);
}
ASSERT_TRUE(ret);
@@ -1021,7 +1021,7 @@ TEST_F(ProtobufJsonTest, pb_to_json_encode_decode) {
printf("----------test pb to json------------\n\n");
json2pb::Pb2JsonOptions option;
option.bytes_to_base64 = true;
- ASSERT_TRUE(ProtoMessageToJson(json_data, &info1, option, NULL));
+ ASSERT_TRUE(ProtoMessageToJson(json_data, &info1, option, nullptr));
#ifndef RAPIDJSON_VERSION_0_1
ASSERT_STREQ("{\"info\":[\"this is json data's info\",\"this is a test\"],\"type\":80000,"
"\"data:array\":[200,300],\"judge\":true,\"spur\":3.45,\"@Content_Test%@\":"
@@ -1041,8 +1041,8 @@ TEST_F(ProtobufJsonTest, pb_to_json_encode_decode) {
std::string info3;
JsonContextBodyEncDec data1;
- json2pb::JsonToProtoMessage(info1, &data1, NULL);
- json2pb::ProtoMessageToJson(data1, &info3, NULL);
+ json2pb::JsonToProtoMessage(info1, &data1, nullptr);
+ json2pb::ProtoMessageToJson(data1, &info3, nullptr);
ASSERT_STREQ(info1.data(), info3.data());
printf("----------test single repeated pb to json array------------\n\n");
@@ -1062,7 +1062,7 @@ TEST_F(ProtobufJsonTest, pb_to_json_encode_decode) {
std::string info4;
option.single_repeated_to_array = false;
- ASSERT_TRUE(ProtoMessageToJson(single_repeated_json_data, &info4, option, NULL));
+ ASSERT_TRUE(ProtoMessageToJson(single_repeated_json_data, &info4, option, nullptr));
#ifndef RAPIDJSON_VERSION_0_1
ASSERT_STREQ("{\"person\":["
"{\"name\":\"foo\",\"id\":1,\"json_body\":"
@@ -1085,7 +1085,7 @@ TEST_F(ProtobufJsonTest, pb_to_json_encode_decode) {
std::string info5;
option.single_repeated_to_array = true;
- ASSERT_TRUE(ProtoMessageToJson(single_repeated_json_data, &info5, option, NULL));
+ ASSERT_TRUE(ProtoMessageToJson(single_repeated_json_data, &info5, option, nullptr));
#ifndef RAPIDJSON_VERSION_0_1
ASSERT_STREQ("[{\"name\":\"foo\",\"id\":1,\"json_body\":"
"{\"info\":[\"this is json data's info\",\"this is a test\"],\"type\":80000,"
@@ -1109,8 +1109,8 @@ TEST_F(ProtobufJsonTest, pb_to_json_encode_decode) {
std::string info6;
AddressBookEncDec data2;
// object -> pb
- json2pb::JsonToProtoMessage(info4, &data2, NULL);
- json2pb::ProtoMessageToJson(data2, &info6, option, NULL);
+ json2pb::JsonToProtoMessage(info4, &data2, nullptr);
+ json2pb::ProtoMessageToJson(data2, &info6, option, nullptr);
ASSERT_STREQ(info6.data(), info5.data());
@@ -1119,13 +1119,13 @@ TEST_F(ProtobufJsonTest, pb_to_json_encode_decode) {
json2pb::Json2PbOptions option2;
option2.array_to_single_repeated = true;
// array -> pb
- json2pb::JsonToProtoMessage(info5, &data3, option2, NULL);
- json2pb::ProtoMessageToJson(data3, &info7, option, NULL);
+ json2pb::JsonToProtoMessage(info5, &data3, option2, nullptr);
+ json2pb::ProtoMessageToJson(data3, &info7, option, nullptr);
ASSERT_STREQ(info7.data(), info5.data());
std::string info8;
option.single_repeated_to_array = false;
- json2pb::ProtoMessageToJson(data3, &info8, option, NULL);
+ json2pb::ProtoMessageToJson(data3, &info8, option, nullptr);
ASSERT_STREQ(info8.data(), info4.data());
}
@@ -1183,7 +1183,7 @@ TEST_F(ProtobufJsonTest, pb_to_json_control_char_case) {
{
json2pb::Pb2JsonOptions option;
option.bytes_to_base64 = false;
- ret = ProtoMessageToJson(address_book, &info1, option, NULL);
+ ret = ProtoMessageToJson(address_book, &info1, option, nullptr);
ASSERT_TRUE(ret);
}
@@ -1212,7 +1212,7 @@ TEST_F(ProtobufJsonTest, pb_to_json_control_char_case) {
{
json2pb::Pb2JsonOptions option;
option.bytes_to_base64 = true;
- ret = ProtoMessageToJson(address_book, &info1, option, NULL);
+ ret = ProtoMessageToJson(address_book, &info1, option, nullptr);
ASSERT_TRUE(ret);
}
@@ -1242,7 +1242,7 @@ TEST_F(ProtobufJsonTest, pb_to_json_control_char_case) {
json2pb::Pb2JsonOptions option;
option.enum_option = json2pb::OUTPUT_ENUM_BY_NUMBER;
option.bytes_to_base64 = false;
- ret = ProtoMessageToJson(address_book, &info1, option, NULL);
+ ret = ProtoMessageToJson(address_book, &info1, option, nullptr);
ASSERT_TRUE(ret);
}
@@ -1313,7 +1313,7 @@ TEST_F(ProtobufJsonTest, pb_to_json_unicode_case) {
ASSERT_TRUE(ret);
butil::IOBuf buf;
butil::IOBufAsZeroCopyOutputStream stream(&buf);
- bool res = json2pb::ProtoMessageToJson(address_book, &stream, NULL);
+ bool res = json2pb::ProtoMessageToJson(address_book, &stream, nullptr);
ASSERT_TRUE(res);
ASSERT_TRUE(!info1.compare(buf.to_string()));
}
@@ -1451,18 +1451,18 @@ TEST_F(ProtobufJsonTest, pb_to_json_perf_case) {
float avg_time1 = 0;
float avg_time2 = 0;
const int times = 100000;
- ASSERT_TRUE(json2pb::ProtoMessageToJson(address_book, &info1, NULL));
+ ASSERT_TRUE(json2pb::ProtoMessageToJson(address_book, &info1, nullptr));
for (int i = 0; i < times; i++) {
std::string info3;
AddressBook data1;
timer.start();
- res = json2pb::JsonToProtoMessage(info1, &data1, NULL);
+ res = json2pb::JsonToProtoMessage(info1, &data1, nullptr);
timer.stop();
avg_time1 += timer.u_elapsed();
ASSERT_TRUE(res);
timer.start();
- res = json2pb::ProtoMessageToJson(data1, &info3, NULL);
+ res = json2pb::ProtoMessageToJson(data1, &info3, nullptr);
timer.stop();
avg_time2 += timer.u_elapsed();
ASSERT_TRUE(res);
@@ -1501,7 +1501,7 @@ TEST_F(ProtobufJsonTest, pb_to_json_encode_decode_perf_case) {
printf("text:%s\n", text.data());
- ASSERT_TRUE(json2pb::ProtoMessageToJson(json_data, &info1, NULL));
+ ASSERT_TRUE(json2pb::ProtoMessageToJson(json_data, &info1, nullptr));
printf("----------test pb to json encode decode performance------------\n\n");
ProfilerStart("pb_to_json_encode_decode_perf.prof");
@@ -1515,13 +1515,13 @@ TEST_F(ProtobufJsonTest, pb_to_json_encode_decode_perf_case) {
std::string info3;
JsonContextBody json_body;
timer.start();
- res = json2pb::JsonToProtoMessage(info1, &json_body, NULL);
+ res = json2pb::JsonToProtoMessage(info1, &json_body, nullptr);
timer.stop();
avg_time1 += timer.u_elapsed();
ASSERT_TRUE(res);
timer.start();
- res = json2pb::ProtoMessageToJson(json_body, &info3, NULL);
+ res = json2pb::ProtoMessageToJson(json_body, &info3, nullptr);
timer.stop();
avg_time2 += timer.u_elapsed();
ASSERT_TRUE(res);
diff --git a/test/brpc_public_pbrpc_protocol_unittest.cpp b/test/brpc_public_pbrpc_protocol_unittest.cpp
index e92f5ed9..f89ae4a6 100644
--- a/test/brpc_public_pbrpc_protocol_unittest.cpp
+++ b/test/brpc_public_pbrpc_protocol_unittest.cpp
@@ -111,7 +111,7 @@ protected:
virtual void TearDown() {};
void VerifyMessage(brpc::InputMessageBase* msg) {
- if (msg->_socket == NULL) {
+ if (msg->_socket == nullptr) {
_socket->ReAddress(&msg->_socket);
}
msg->_arg = &_server;
@@ -120,7 +120,7 @@ protected:
void ProcessMessage(void (*process)(brpc::InputMessageBase*),
brpc::InputMessageBase* msg, bool set_eof) {
- if (msg->_socket == NULL) {
+ if (msg->_socket == nullptr) {
_socket->ReAddress(&msg->_socket);
}
msg->_arg = &_server;
@@ -179,7 +179,7 @@ protected:
butil::IOPortal buf;
EXPECT_EQ((ssize_t)bytes_in_pipe,
buf.append_from_file_descriptor(_pipe_fds[0], 1024));
- brpc::ParseResult pr = brpc::policy::ParseNsheadMessage(&buf, NULL, false, NULL);
+ brpc::ParseResult pr = brpc::policy::ParseNsheadMessage(&buf, nullptr, false, nullptr);
EXPECT_EQ(brpc::PARSE_OK, pr.error());
brpc::policy::MostCommonMessage* msg =
static_cast<brpc::policy::MostCommonMessage*>(pr.message());
@@ -276,13 +276,13 @@ TEST_F(PublicPbrpcTest, complete_flow) {
brpc::policy::SerializePublicPbrpcRequest(&request_buf, &cntl, &req);
ASSERT_FALSE(cntl.Failed());
brpc::policy::PackPublicPbrpcRequest(
- &total_buf, NULL, cntl.call_id().value,
+ &total_buf, nullptr, cntl.call_id().value,
test::EchoService::descriptor()->method(0), &cntl, request_buf, &_auth);
ASSERT_FALSE(cntl.Failed());
// Verify and handle request
brpc::ParseResult req_pr =
- brpc::policy::ParseNsheadMessage(&total_buf, NULL, false, NULL);
+ brpc::policy::ParseNsheadMessage(&total_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, req_pr.error());
brpc::InputMessageBase* req_msg = req_pr.message();
VerifyMessage(req_msg);
@@ -292,7 +292,7 @@ TEST_F(PublicPbrpcTest, complete_flow) {
butil::IOPortal response_buf;
response_buf.append_from_file_descriptor(_pipe_fds[0], 1024);
brpc::ParseResult res_pr =
- brpc::policy::ParseNsheadMessage(&response_buf, NULL, false, NULL);
+ brpc::policy::ParseNsheadMessage(&response_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, res_pr.error());
brpc::InputMessageBase* res_msg = res_pr.message();
ProcessMessage(brpc::policy::ProcessPublicPbrpcResponse, res_msg, false);
@@ -313,13 +313,13 @@ TEST_F(PublicPbrpcTest, close_in_callback) {
brpc::policy::SerializePublicPbrpcRequest(&request_buf, &cntl, &req);
ASSERT_FALSE(cntl.Failed());
brpc::policy::PackPublicPbrpcRequest(
- &total_buf, NULL, cntl.call_id().value,
+ &total_buf, nullptr, cntl.call_id().value,
test::EchoService::descriptor()->method(0), &cntl, request_buf, &_auth);
ASSERT_FALSE(cntl.Failed());
// Handle request
brpc::ParseResult req_pr =
- brpc::policy::ParseNsheadMessage(&total_buf, NULL, false, NULL);
+ brpc::policy::ParseNsheadMessage(&total_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, req_pr.error());
brpc::InputMessageBase* req_msg = req_pr.message();
ProcessMessage(brpc::policy::ProcessNsheadRequest, req_msg, false);
diff --git a/test/brpc_rdma_unittest.cpp b/test/brpc_rdma_unittest.cpp
index 2ecd1f3c..9c52acb7 100644
--- a/test/brpc_rdma_unittest.cpp
+++ b/test/brpc_rdma_unittest.cpp
@@ -148,13 +148,13 @@ protected:
std::vector<SocketId> sids;
_server._am->ListConnections(&sids);
if (index >= sids.size()) {
- return NULL;
+ return nullptr;
}
SocketUniquePtr s;
if (Socket::Address(sids[index], &s) == 0) {
return s.get();
}
- return NULL;
+ return nullptr;
}
butil::TempFile _server_list;
@@ -203,7 +203,7 @@ TEST_F(RdmaTest, client_close_before_hello_send) {
ASSERT_EQ(rdma::RdmaEndpoint::UNINIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
close(sockfd);
usleep(100000); // wait for server to handle the msg
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
StopServer();
}
@@ -242,7 +242,7 @@ TEST_F(RdmaTest, client_close_during_hello_send) {
bzero((char*)&addr, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(PORT);
- Socket* s = NULL;
+ Socket* s = nullptr;
uint8_t data[8];
butil::fd_guard sockfd1(socket(AF_INET, SOCK_STREAM, 0));
@@ -260,7 +260,7 @@ TEST_F(RdmaTest, client_close_during_hello_send) {
ASSERT_EQ(rdma::RdmaEndpoint::UNINIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
close(sockfd1);
usleep(100000); // wait for server to handle the msg
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
butil::fd_guard sockfd2(socket(AF_INET, SOCK_STREAM, 0));
ASSERT_TRUE(sockfd2 >= 0);
@@ -274,7 +274,7 @@ TEST_F(RdmaTest, client_close_during_hello_send) {
ASSERT_EQ(rdma::RdmaEndpoint::S_HELLO_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
close(sockfd2);
usleep(100000); // wait for server to handle the msg
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
butil::fd_guard sockfd3(socket(AF_INET, SOCK_STREAM, 0));
ASSERT_TRUE(sockfd3 >= 0);
@@ -293,7 +293,7 @@ TEST_F(RdmaTest, client_close_during_hello_send) {
ASSERT_EQ(rdma::RdmaEndpoint::S_HELLO_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
close(sockfd3);
usleep(100000); // wait for server to handle the msg
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
StopServer();
}
@@ -305,7 +305,7 @@ TEST_F(RdmaTest, client_hello_msg_invalid_len) {
bzero((char*)&addr, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(PORT);
- Socket* s = NULL;
+ Socket* s = nullptr;
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
butil::fd_guard sockfd1(socket(AF_INET, SOCK_STREAM, 0));
@@ -321,7 +321,7 @@ TEST_F(RdmaTest, client_hello_msg_invalid_len) {
memset(data + 4, 0, 36);
ASSERT_EQ(36, write(sockfd1, data + 4, 36)); // Write invalid length.
usleep(100000); // wait for server to handle the msg
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
butil::fd_guard sockfd2(socket(AF_INET, SOCK_STREAM, 0));
ASSERT_TRUE(sockfd2 >= 0);
@@ -338,7 +338,7 @@ TEST_F(RdmaTest, client_hello_msg_invalid_len) {
memset(data + 6, 0, 34);
ASSERT_EQ(36, write(sockfd2, data + 4, 36)); // write invalid length
usleep(100000); // wait for server to handle the msg
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
StopServer();
}
@@ -350,7 +350,7 @@ TEST_F(RdmaTest, client_hello_msg_invalid_version) {
bzero((char*)&addr, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(PORT);
- Socket* s = NULL;
+ Socket* s = nullptr;
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
uint16_t len = butil::HostToNet16(rdma::HELLO_V2_MSG_LEN_MIN);
uint16_t ver = butil::HostToNet16(1);
@@ -385,7 +385,7 @@ TEST_F(RdmaTest, client_hello_msg_invalid_version) {
ASSERT_EQ(rdma::RdmaEndpoint::FALLBACK_TCP, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
sockfd1.reset(-1);
usleep(100000); // wait for server to handle the msg
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
butil::fd_guard sockfd2(socket(AF_INET, SOCK_STREAM, 0));
ASSERT_TRUE(sockfd2 >= 0);
@@ -411,7 +411,7 @@ TEST_F(RdmaTest, client_hello_msg_invalid_version) {
ASSERT_EQ(rdma::RdmaEndpoint::FALLBACK_TCP, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
sockfd2.reset(-1);
usleep(100000); // wait for server to handle the msg
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
StopServer();
}
@@ -423,7 +423,7 @@ TEST_F(RdmaTest, client_hello_msg_invalid_sq_rq_block_size) {
bzero((char*)&addr, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(PORT);
- Socket* s = NULL;
+ Socket* s = nullptr;
uint32_t flags = butil::HostToNet32(0);
rdma::v2_wire::HelloMessage msg{};
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
@@ -454,7 +454,7 @@ TEST_F(RdmaTest, client_hello_msg_invalid_sq_rq_block_size) {
ASSERT_EQ(rdma::RdmaEndpoint::FALLBACK_TCP, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
sockfd1.reset(-1);
usleep(100000); // wait for server to handle the msg
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
msg.sq_size = 16;
msg.rq_size = 10;
@@ -479,7 +479,7 @@ TEST_F(RdmaTest, client_hello_msg_invalid_sq_rq_block_size) {
ASSERT_EQ(rdma::RdmaEndpoint::FALLBACK_TCP, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
sockfd2.reset(-1);
usleep(100000); // wait for server to handle the msg
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
msg.sq_size = 16;
msg.rq_size = 16;
@@ -504,7 +504,7 @@ TEST_F(RdmaTest, client_hello_msg_invalid_sq_rq_block_size) {
ASSERT_EQ(rdma::RdmaEndpoint::FALLBACK_TCP, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
sockfd3.reset(-1);
usleep(100000); // wait for server to handle the msg
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
StopServer();
}
@@ -516,7 +516,7 @@ TEST_F(RdmaTest, client_close_after_qp_build) {
bzero((char*)&addr, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(PORT);
- Socket* s = NULL;
+ Socket* s = nullptr;
rdma::v2_wire::HelloMessage msg{};
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
msg.msg_len = rdma::HELLO_V2_MSG_LEN_MIN;
@@ -541,7 +541,7 @@ TEST_F(RdmaTest, client_close_after_qp_build) {
ASSERT_EQ(rdma::RdmaEndpoint::S_ACK_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
close(sockfd1);
usleep(100000); // wait for server to handle the msg
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
StopServer();
}
@@ -553,7 +553,7 @@ TEST_F(RdmaTest, client_close_during_ack_send) {
bzero((char*)&addr, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(PORT);
- Socket* s = NULL;
+ Socket* s = nullptr;
rdma::v2_wire::HelloMessage msg{};
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
msg.msg_len = rdma::HELLO_V2_MSG_LEN_MIN;
@@ -585,7 +585,7 @@ TEST_F(RdmaTest, client_close_during_ack_send) {
ASSERT_EQ(rdma::RdmaEndpoint::ESTABLISHED, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
close(sockfd1);
usleep(100000); // wait for server to handle the msg
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
StopServer();
}
@@ -597,7 +597,7 @@ TEST_F(RdmaTest, client_close_after_ack_send) {
bzero((char*)&addr, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(PORT);
- Socket* s = NULL;
+ Socket* s = nullptr;
rdma::v2_wire::HelloMessage msg{};
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
msg.msg_len = rdma::HELLO_V2_MSG_LEN_MIN;
@@ -630,7 +630,7 @@ TEST_F(RdmaTest, client_close_after_ack_send) {
ASSERT_EQ(RdmaTransport::RDMA_OFF, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_state);
close(sockfd1);
usleep(100000); // wait for server to handle the msg
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
butil::fd_guard sockfd2(socket(AF_INET, SOCK_STREAM, 0));
ASSERT_TRUE(sockfd2 >= 0);
@@ -650,7 +650,7 @@ TEST_F(RdmaTest, client_close_after_ack_send) {
ASSERT_EQ(rdma::RdmaEndpoint::ESTABLISHED, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
close(sockfd2);
usleep(100000); // wait for server to handle the msg
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
StopServer();
}
@@ -662,7 +662,7 @@ TEST_F(RdmaTest, client_send_data_on_tcp_after_ack_send) {
bzero((char*)&addr, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(PORT);
- Socket* s = NULL;
+ Socket* s = nullptr;
rdma::v2_wire::HelloMessage msg{};
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
msg.msg_len = rdma::HELLO_V2_MSG_LEN_MIN;
@@ -694,7 +694,7 @@ TEST_F(RdmaTest, client_send_data_on_tcp_after_ack_send) {
ASSERT_EQ(rdma::RdmaEndpoint::FALLBACK_TCP, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
ASSERT_EQ(sizeof(flags), write(sockfd1, &flags, sizeof(flags)));
usleep(100000);
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
butil::fd_guard sockfd2(socket(AF_INET, SOCK_STREAM, 0));
ASSERT_TRUE(sockfd2 >= 0);
@@ -714,7 +714,7 @@ TEST_F(RdmaTest, client_send_data_on_tcp_after_ack_send) {
ASSERT_EQ(rdma::RdmaEndpoint::ESTABLISHED, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
ASSERT_EQ(sizeof(flags), write(sockfd2, &flags, sizeof(flags)));
usleep(100000);
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
StopServer();
}
@@ -743,7 +743,7 @@ TEST_F(RdmaTest, server_miss_before_hello_send) {
ASSERT_EQ(0, Socket::Address(cntl._single_server_id, &s));
ASSERT_EQ(rdma::RdmaEndpoint::C_HELLO_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
- butil::fd_guard acc_fd(accept(sockfd, NULL, NULL));
+ butil::fd_guard acc_fd(accept(sockfd, nullptr, nullptr));
ASSERT_TRUE(acc_fd >= 0);
bthread_id_join(cntl.call_id());
@@ -774,7 +774,7 @@ TEST_F(RdmaTest, server_close_before_hello_send) {
ASSERT_EQ(0, Socket::Address(cntl._single_server_id, &s));
ASSERT_EQ(rdma::RdmaEndpoint::C_HELLO_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
- butil::fd_guard acc_fd(accept(sockfd, NULL, NULL));
+ butil::fd_guard acc_fd(accept(sockfd, nullptr, nullptr));
ASSERT_TRUE(acc_fd >= 0);
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
ASSERT_EQ(rdma::HELLO_V2_MSG_LEN_MIN, read(acc_fd, data, rdma::HELLO_V2_MSG_LEN_MIN));
@@ -810,7 +810,7 @@ TEST_F(RdmaTest, server_miss_during_magic_str) {
ASSERT_EQ(0, Socket::Address(cntl._single_server_id, &s));
ASSERT_EQ(rdma::RdmaEndpoint::C_HELLO_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
- butil::fd_guard acc_fd(accept(sockfd, NULL, NULL));
+ butil::fd_guard acc_fd(accept(sockfd, nullptr, nullptr));
ASSERT_TRUE(acc_fd >= 0);
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
ASSERT_EQ(rdma::HELLO_V2_MSG_LEN_MIN, read(acc_fd, data, rdma::HELLO_V2_MSG_LEN_MIN));
@@ -845,7 +845,7 @@ TEST_F(RdmaTest, server_close_during_magic_str) {
ASSERT_EQ(0, Socket::Address(cntl._single_server_id, &s));
ASSERT_EQ(rdma::RdmaEndpoint::C_HELLO_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
- butil::fd_guard acc_fd(accept(sockfd, NULL, NULL));
+ butil::fd_guard acc_fd(accept(sockfd, nullptr, nullptr));
ASSERT_TRUE(acc_fd >= 0);
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
ASSERT_EQ(rdma::HELLO_V2_MSG_LEN_MIN, read(acc_fd, data, rdma::HELLO_V2_MSG_LEN_MIN));
@@ -883,7 +883,7 @@ TEST_F(RdmaTest, server_hello_invalid_magic_str) {
ASSERT_EQ(0, Socket::Address(cntl._single_server_id, &s));
ASSERT_EQ(rdma::RdmaEndpoint::C_HELLO_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
- butil::fd_guard acc_fd(accept(sockfd, NULL, NULL));
+ butil::fd_guard acc_fd(accept(sockfd, nullptr, nullptr));
ASSERT_TRUE(acc_fd >= 0);
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
ASSERT_EQ(rdma::HELLO_V2_MSG_LEN_MIN, read(acc_fd, data, rdma::HELLO_V2_MSG_LEN_MIN));
@@ -919,7 +919,7 @@ TEST_F(RdmaTest, server_miss_during_hello_msg) {
ASSERT_EQ(0, Socket::Address(cntl._single_server_id, &s));
ASSERT_EQ(rdma::RdmaEndpoint::C_HELLO_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
- butil::fd_guard acc_fd(accept(sockfd, NULL, NULL));
+ butil::fd_guard acc_fd(accept(sockfd, nullptr, nullptr));
ASSERT_TRUE(acc_fd >= 0);
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
ASSERT_EQ(rdma::HELLO_V2_MSG_LEN_MIN, read(acc_fd, data, rdma::HELLO_V2_MSG_LEN_MIN));
@@ -954,7 +954,7 @@ TEST_F(RdmaTest, server_close_during_hello_msg) {
ASSERT_EQ(0, Socket::Address(cntl._single_server_id, &s));
ASSERT_EQ(rdma::RdmaEndpoint::C_HELLO_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
- butil::fd_guard acc_fd(accept(sockfd, NULL, NULL));
+ butil::fd_guard acc_fd(accept(sockfd, nullptr, nullptr));
ASSERT_TRUE(acc_fd >= 0);
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
ASSERT_EQ(rdma::HELLO_V2_MSG_LEN_MIN, read(acc_fd, data, rdma::HELLO_V2_MSG_LEN_MIN));
@@ -992,7 +992,7 @@ TEST_F(RdmaTest, server_hello_invalid_msg_len) {
ASSERT_EQ(0, Socket::Address(cntl._single_server_id, &s));
ASSERT_EQ(rdma::RdmaEndpoint::C_HELLO_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
- butil::fd_guard acc_fd(accept(sockfd, NULL, NULL));
+ butil::fd_guard acc_fd(accept(sockfd, nullptr, nullptr));
ASSERT_TRUE(acc_fd >= 0);
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
ASSERT_EQ(rdma::HELLO_V2_MSG_LEN_MIN, read(acc_fd, data, rdma::HELLO_V2_MSG_LEN_MIN));
@@ -1032,7 +1032,7 @@ TEST_F(RdmaTest, server_hello_invalid_version) {
ASSERT_EQ(0, Socket::Address(cntl._single_server_id, &s));
ASSERT_EQ(rdma::RdmaEndpoint::C_HELLO_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
- butil::fd_guard acc_fd(accept(sockfd, NULL, NULL));
+ butil::fd_guard acc_fd(accept(sockfd, nullptr, nullptr));
ASSERT_TRUE(acc_fd >= 0);
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
ASSERT_EQ(rdma::HELLO_V2_MSG_LEN_MIN, read(acc_fd, data, rdma::HELLO_V2_MSG_LEN_MIN));
@@ -1075,7 +1075,7 @@ TEST_F(RdmaTest, server_hello_invalid_sq_rq_size) {
ASSERT_EQ(0, Socket::Address(cntl._single_server_id, &s));
ASSERT_EQ(rdma::RdmaEndpoint::C_HELLO_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
- butil::fd_guard acc_fd(accept(sockfd, NULL, NULL));
+ butil::fd_guard acc_fd(accept(sockfd, nullptr, nullptr));
ASSERT_TRUE(acc_fd >= 0);
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
ASSERT_EQ(rdma::HELLO_V2_MSG_LEN_MIN, read(acc_fd, data, rdma::HELLO_V2_MSG_LEN_MIN));
@@ -1127,7 +1127,7 @@ TEST_F(RdmaTest, server_miss_after_ack) {
ASSERT_EQ(0, Socket::Address(cntl._single_server_id, &s));
ASSERT_EQ(rdma::RdmaEndpoint::C_HELLO_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
- butil::fd_guard acc_fd(accept(sockfd, NULL, NULL));
+ butil::fd_guard acc_fd(accept(sockfd, nullptr, nullptr));
ASSERT_TRUE(acc_fd >= 0);
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
ASSERT_EQ(rdma::HELLO_V2_MSG_LEN_MIN, read(acc_fd, data, rdma::HELLO_V2_MSG_LEN_MIN));
@@ -1179,7 +1179,7 @@ TEST_F(RdmaTest, server_close_after_ack) {
ASSERT_EQ(0, Socket::Address(cntl._single_server_id, &s));
ASSERT_EQ(rdma::RdmaEndpoint::C_HELLO_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
- butil::fd_guard acc_fd(accept(sockfd, NULL, NULL));
+ butil::fd_guard acc_fd(accept(sockfd, nullptr, nullptr));
ASSERT_TRUE(acc_fd >= 0);
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
ASSERT_EQ(rdma::HELLO_V2_MSG_LEN_MIN, read(acc_fd, data, rdma::HELLO_V2_MSG_LEN_MIN));
@@ -1232,7 +1232,7 @@ TEST_F(RdmaTest, server_send_data_on_tcp_after_ack) {
ASSERT_EQ(0, Socket::Address(cntl._single_server_id, &s));
ASSERT_EQ(rdma::RdmaEndpoint::C_HELLO_WAIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
- butil::fd_guard acc_fd(accept(sockfd, NULL, NULL));
+ butil::fd_guard acc_fd(accept(sockfd, nullptr, nullptr));
ASSERT_TRUE(acc_fd >= 0);
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
ASSERT_EQ(rdma::HELLO_V2_MSG_LEN_MIN, read(acc_fd, data, rdma::HELLO_V2_MSG_LEN_MIN));
@@ -1282,7 +1282,7 @@ TEST_F(RdmaTest, v2_client_hello_bytes_baseline) {
SocketUniquePtr s;
ASSERT_EQ(0, Socket::Address(cntl._single_server_id, &s));
- butil::fd_guard acc_fd(accept(sockfd, NULL, NULL));
+ butil::fd_guard acc_fd(accept(sockfd, nullptr, nullptr));
ASSERT_TRUE(acc_fd >= 0);
uint8_t data[rdma::HELLO_V2_MSG_LEN_MIN];
@@ -1369,7 +1369,7 @@ TEST_F(RdmaTest, v2_server_hello_bytes_baseline) {
sockfd.reset(-1);
usleep(100000);
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
StopServer();
}
@@ -1386,7 +1386,7 @@ TEST_F(RdmaTest, v2_server_drains_tail_then_reads_ack) {
ASSERT_EQ(0, connect(sockfd, (sockaddr*)&addr, sizeof(sockaddr)));
usleep(100000);
Socket* s = GetSocketFromServer(0);
- ASSERT_TRUE(s != NULL);
+ ASSERT_TRUE(s != nullptr);
ASSERT_EQ(rdma::RdmaEndpoint::UNINIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
// Build a v2 hello with msg_len = 48 (40 base + 8B zero tail).
@@ -1416,7 +1416,7 @@ TEST_F(RdmaTest, v2_server_drains_tail_then_reads_ack) {
sockfd.reset(-1);
usleep(100000);
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
StopServer();
}
@@ -1433,7 +1433,7 @@ TEST_F(RdmaTest, v2_server_rejects_oversized_msg_len) {
ASSERT_EQ(0, connect(sockfd, (sockaddr*)&addr, sizeof(sockaddr)));
usleep(100000);
Socket* s = GetSocketFromServer(0);
- ASSERT_TRUE(s != NULL);
+ ASSERT_TRUE(s != nullptr);
ASSERT_EQ(rdma::RdmaEndpoint::UNINIT, static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
// Build a v2 hello with msg_len = 4097 (HELLO_V2_MSG_LEN_MAX + 1).
@@ -1456,7 +1456,7 @@ TEST_F(RdmaTest, v2_server_rejects_oversized_msg_len) {
usleep(100000);
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
sockfd.reset(-1);
usleep(100000);
@@ -1535,7 +1535,7 @@ TEST_F(RdmaTest, v3_client_hello_bytes_baseline) {
google::protobuf::Closure* done = DoNothing();
::test::EchoService::Stub(&channel).Echo(&cntl, &req, &res, done);
- butil::fd_guard acc_fd(accept(sockfd, NULL, NULL));
+ butil::fd_guard acc_fd(accept(sockfd, nullptr, nullptr));
ASSERT_TRUE(acc_fd >= 0);
// [0..4) magic "RDM3"
@@ -1626,7 +1626,7 @@ TEST_F(RdmaTest, v3_server_hello_bytes_baseline) {
sockfd.reset(-1);
usleep(100000);
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
StopServer();
}
@@ -1643,14 +1643,14 @@ TEST_F(RdmaTest, v3_server_rejects_zero_pb_size) {
ASSERT_EQ(0, connect(sockfd, (sockaddr*)&addr, sizeof(sockaddr)));
usleep(100000);
Socket* s = GetSocketFromServer(0);
- ASSERT_TRUE(s != NULL);
+ ASSERT_TRUE(s != nullptr);
// "RDM3" + pb_size = 0 (4B big-endian zero).
uint8_t buf[8] = {'R', 'D', 'M', '3', 0, 0, 0, 0};
ASSERT_EQ(8, write(sockfd, buf, 8));
usleep(100000);
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
sockfd.reset(-1);
StopServer();
@@ -1668,7 +1668,7 @@ TEST_F(RdmaTest, v3_server_rejects_oversized_pb_size) {
ASSERT_EQ(0, connect(sockfd, (sockaddr*)&addr, sizeof(sockaddr)));
usleep(100000);
Socket* s = GetSocketFromServer(0);
- ASSERT_TRUE(s != NULL);
+ ASSERT_TRUE(s != nullptr);
uint8_t buf[8];
memcpy(buf, "RDM3", 4);
@@ -1679,7 +1679,7 @@ TEST_F(RdmaTest, v3_server_rejects_oversized_pb_size) {
ASSERT_EQ(8, write(sockfd, buf, 8));
usleep(100000);
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
sockfd.reset(-1);
StopServer();
@@ -1697,7 +1697,7 @@ TEST_F(RdmaTest, v3_server_rejects_invalid_pb_bytes) {
ASSERT_EQ(0, connect(sockfd, (sockaddr*)&addr, sizeof(sockaddr)));
usleep(100000);
Socket* s = GetSocketFromServer(0);
- ASSERT_TRUE(s != NULL);
+ ASSERT_TRUE(s != nullptr);
// "RDM3" + pb_size = 8 + 8 bytes of 0xff (invalid protobuf body).
uint8_t buf[16];
@@ -1708,7 +1708,7 @@ TEST_F(RdmaTest, v3_server_rejects_invalid_pb_bytes) {
ASSERT_EQ(16, write(sockfd, buf, 16));
usleep(100000);
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
sockfd.reset(-1);
StopServer();
@@ -1726,7 +1726,7 @@ TEST_F(RdmaTest, v3_server_invalid_sq_size_falls_back) {
ASSERT_EQ(0, connect(sockfd, (sockaddr*)&addr, sizeof(sockaddr)));
usleep(100000);
Socket* s = GetSocketFromServer(0);
- ASSERT_TRUE(s != NULL);
+ ASSERT_TRUE(s != nullptr);
rdma::RdmaHello msg = MakeValidV3Hello();
msg.set_sq_size(0); // invalid: < MIN_QP_SIZE (16)
@@ -1760,7 +1760,7 @@ TEST_F(RdmaTest, v3_server_invalid_sq_size_falls_back) {
sockfd.reset(-1);
usleep(100000);
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
StopServer();
}
@@ -1820,7 +1820,7 @@ TEST_F(RdmaTest, v3_server_accepts_client_hello_with_ece) {
ASSERT_EQ(0, connect(sockfd, (sockaddr*)&addr, sizeof(sockaddr)));
usleep(100000);
Socket* s = GetSocketFromServer(0);
- ASSERT_TRUE(s != NULL);
+ ASSERT_TRUE(s != nullptr);
rdma::RdmaHello msg = MakeValidV3HelloWithEce(0x02c9, 0x1, 0x0);
std::string packet = MakeV3Packet(msg);
@@ -1843,7 +1843,7 @@ TEST_F(RdmaTest, v3_server_accepts_client_hello_with_ece) {
sockfd.reset(-1);
usleep(100000);
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
StopServer();
}
@@ -1862,7 +1862,7 @@ TEST_F(RdmaTest, v3_server_reply_has_no_ece_when_disabled) {
ASSERT_EQ(0, connect(sockfd, (sockaddr*)&addr, sizeof(sockaddr)));
usleep(100000);
Socket* s = GetSocketFromServer(0);
- ASSERT_TRUE(s != NULL);
+ ASSERT_TRUE(s != nullptr);
rdma::RdmaHello msg = MakeValidV3HelloWithEce(0x02c9, 0x1, 0x0);
std::string packet = MakeV3Packet(msg);
@@ -1899,7 +1899,7 @@ TEST_F(RdmaTest, v3_server_reply_has_no_ece_without_hw_negotiation) {
ASSERT_EQ(0, connect(sockfd, (sockaddr*)&addr, sizeof(sockaddr)));
usleep(100000);
Socket* s = GetSocketFromServer(0);
- ASSERT_TRUE(s != NULL);
+ ASSERT_TRUE(s != nullptr);
rdma::RdmaHello msg = MakeValidV3HelloWithEce(0x02c9, 0x1, 0x0);
std::string packet = MakeV3Packet(msg);
@@ -1983,7 +1983,7 @@ TEST_F(RdmaTest, server_alloc_resource_fail_fallback_tcp) {
ASSERT_EQ(0, connect(sockfd, (sockaddr*)&addr, sizeof(sockaddr)));
usleep(100000); // wait for server to handle the msg
Socket* s = GetSocketFromServer(0);
- ASSERT_TRUE(s != NULL);
+ ASSERT_TRUE(s != nullptr);
ASSERT_EQ(rdma::RdmaEndpoint::UNINIT,
static_cast<RdmaTransport*>(s->_transport.get())->_rdma_ep->_state);
@@ -2021,7 +2021,7 @@ TEST_F(RdmaTest, server_alloc_resource_fail_fallback_tcp) {
sockfd.reset(-1);
usleep(100000);
- ASSERT_EQ(NULL, GetSocketFromServer(0));
+ ASSERT_EQ(nullptr, GetSocketFromServer(0));
StopServer();
}
@@ -2066,17 +2066,17 @@ TEST_F(RdmaTest, server_option_invalid) {
ASSERT_EQ(-1, server.Start(PORT, &options));
// nshead and rdma are incompatible
- options.rtmp_service = NULL;
+ options.rtmp_service = nullptr;
options.nshead_service = (NsheadService*)1;
ASSERT_EQ(-1, server.Start(PORT, &options));
// mongo and rdma are incompatible
- options.nshead_service = NULL;
+ options.nshead_service = nullptr;
options.mongo_service_adaptor = (MongoServiceAdaptor*)1;
ASSERT_EQ(-1, server.Start(PORT, &options));
// ssl and rdma are incompatible
- options.mongo_service_adaptor = NULL;
+ options.mongo_service_adaptor = nullptr;
options.mutable_ssl_options()->default_cert.certificate = "test";
ASSERT_EQ(-1, server.Start(PORT, &options));
}
@@ -2638,7 +2638,7 @@ TEST_P(RdmaRpcTest, verbs_error_handling) {
sge.lkey = 1; // incorrect lkey
wr.sg_list = &sge;
wr.num_sge = 1;
- ibv_send_wr* bad = NULL;
+ ibv_send_wr* bad = nullptr;
auto rdma_transport = static_cast<RdmaTransport*>(s->_transport.get());
ibv_post_send(rdma_transport->_rdma_ep->_resource->qp, &wr, &bad);
bthread_id_join(cntl.call_id());
@@ -2664,15 +2664,15 @@ TEST_P(RdmaRpcTest, rdma_use_parallel_channel) {
ASSERT_EQ(0, subchans[i].Init(_naming_url.c_str(), "rR", &opts));
ASSERT_EQ(0, channel.AddChannel(
&subchans[i], DOESNT_OWN_CHANNEL,
- NULL, NULL));
+ nullptr, nullptr));
}
- ASSERT_EQ(0, channel.Init(NULL));
+ ASSERT_EQ(0, channel.Init(nullptr));
Controller cntl;
test::EchoRequest req;
test::EchoResponse res;
req.set_message(__FUNCTION__);
- ::test::EchoService::Stub(&channel).Echo(&cntl, &req, &res, NULL);
+ ::test::EchoService::Stub(&channel).Echo(&cntl, &req, &res, nullptr);
ASSERT_EQ(0, cntl.ErrorCode());
ASSERT_EQ(NCHANS, (size_t)cntl.sub_count());
@@ -2695,14 +2695,14 @@ TEST_P(RdmaRpcTest, rdma_use_selective_channel) {
for (size_t i = 0; i < NCHANS; ++i) {
Channel* subchan = new Channel;
ASSERT_EQ(0, subchan->Init(_naming_url.c_str(), "rR", &opts));
- ASSERT_EQ(0, channel.AddChannel(subchan, NULL));
+ ASSERT_EQ(0, channel.AddChannel(subchan, nullptr));
}
Controller cntl;
test::EchoRequest req;
test::EchoResponse res;
req.set_message(__FUNCTION__);
- ::test::EchoService::Stub(&channel).Echo(&cntl, &req, &res, NULL);
+ ::test::EchoService::Stub(&channel).Echo(&cntl, &req, &res, nullptr);
ASSERT_EQ(0, cntl.ErrorCode()) << cntl.ErrorText();
ASSERT_EQ(1, cntl.sub_count());
@@ -2732,7 +2732,7 @@ TEST_P(RdmaRpcTest, send_rpcs_with_user_defined_iobuf) {
butil::IOBuf attach;
void* data = malloc(4096);;
- attach.append_user_data(data, 4096, NULL);
+ attach.append_user_data(data, 4096, nullptr);
req[0].set_message(__FUNCTION__);
cntl[0].request_attachment().append(attach);
google::protobuf::Closure* done = DoNothing();
diff --git a/test/brpc_redis_cluster_unittest.cpp b/test/brpc_redis_cluster_unittest.cpp
index 34a6d9ba..478bd92d 100644
--- a/test/brpc_redis_cluster_unittest.cpp
+++ b/test/brpc_redis_cluster_unittest.cpp
@@ -159,11 +159,11 @@ public:
};
static Session* GetOrCreateSession(brpc::RedisConnContext* ctx) {
- if (ctx == NULL) {
- return NULL;
+ if (ctx == nullptr) {
+ return nullptr;
}
Session* s = static_cast<Session*>(ctx->get_session());
- if (s == NULL) {
+ if (s == nullptr) {
s = new Session;
ctx->reset_session(s);
}
@@ -187,7 +187,7 @@ public:
brpc::RedisReply* output,
bool /*flush_batched*/) override {
Session* s = GetOrCreateSession(ctx);
- if (s != NULL) {
+ if (s != nullptr) {
s->asking = true;
}
output->SetStatus("OK");
@@ -366,7 +366,7 @@ public:
}
if (_data->node_id == _data->meta->ask_to) {
Session* s = GetOrCreateSession(ctx);
- if (s == NULL || !s->asking) {
+ if (s == nullptr || !s->asking) {
output->SetError("ERR ASKING required");
return brpc::REDIS_CMD_HANDLED;
}
@@ -552,7 +552,7 @@ TEST_F(RedisClusterChannelTest, basic_routing_and_multi_key_commands) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("mset %s v0 %s v1", key0.c_str(), key1.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
ASSERT_TRUE(resp.reply(0).is_string());
@@ -564,7 +564,7 @@ TEST_F(RedisClusterChannelTest, basic_routing_and_multi_key_commands) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("mget %s %s", key0.c_str(), key1.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
ASSERT_TRUE(resp.reply(0).is_array());
@@ -578,7 +578,7 @@ TEST_F(RedisClusterChannelTest, basic_routing_and_multi_key_commands) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("exists %s %s", key0.c_str(), key1.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(2, resp.reply(0).integer());
}
@@ -588,7 +588,7 @@ TEST_F(RedisClusterChannelTest, basic_routing_and_multi_key_commands) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("del %s %s", key0.c_str(), key1.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(2, resp.reply(0).integer());
}
@@ -609,7 +609,7 @@ TEST_F(RedisClusterChannelTest, moved_redirection) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("get %s", moved_key.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
ASSERT_TRUE(resp.reply(0).is_string());
@@ -633,7 +633,7 @@ TEST_F(RedisClusterChannelTest, ask_redirection) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("get %s", _meta->ask_key.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
ASSERT_TRUE(resp.reply(0).is_string());
@@ -658,7 +658,7 @@ TEST_F(RedisClusterChannelTest, ask_redirection_does_not_override_slot_cache) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("get %s", _meta->ask_key.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
ASSERT_TRUE(resp.reply(0).is_string());
@@ -676,7 +676,7 @@ TEST_F(RedisClusterChannelTest, cluster_nodes_fallback) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("set %s vv", key.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_TRUE(resp.reply(0).is_string());
ASSERT_EQ("OK", resp.reply(0).data());
@@ -697,7 +697,7 @@ TEST_F(RedisClusterChannelTest, eval_and_evalsha) {
"eval", "return 1", "2", key0, key1
};
ASSERT_TRUE(req.AddCommandByComponents(parts, sizeof(parts) / sizeof(parts[0])));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
ASSERT_TRUE(resp.reply(0).is_error());
@@ -710,7 +710,7 @@ TEST_F(RedisClusterChannelTest, eval_and_evalsha) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("evalsha abcdef 1 %s arg1", key0.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
ASSERT_TRUE(resp.reply(0).is_string());
@@ -727,7 +727,7 @@ TEST_F(RedisClusterChannelTest, redirect_retry_limit) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("get %s", _meta->redirect_loop_key.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_NE(std::string::npos, cntl.ErrorText().find("redirect"));
}
@@ -749,7 +749,7 @@ TEST_F(RedisClusterChannelTest, async_call) {
bthread::CountdownEvent event(1);
Done done(&event);
- channel.CallMethod(NULL, &cntl, &req, &resp, &done);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, &done);
event.wait();
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
@@ -775,7 +775,7 @@ TEST_F(RedisClusterChannelTest, pipeline_order_with_mixed_commands) {
ASSERT_TRUE(req.AddCommand("unlink %s %s", key0.c_str(), key1.c_str()));
ASSERT_TRUE(req.AddCommand("mget %s %s", key0.c_str(), key1.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(6, resp.reply_size());
ASSERT_EQ("OK", resp.reply(0).data());
@@ -806,7 +806,7 @@ TEST_F(RedisClusterChannelTest, transaction_commands_are_not_supported) {
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("multi"));
ASSERT_TRUE(req.AddCommand("exec"));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(2, resp.reply_size());
ASSERT_TRUE(resp.reply(0).is_error());
@@ -827,7 +827,7 @@ TEST_F(RedisClusterChannelTest, eval_argument_validation) {
"eval", "return 1", "abc", "k1"
};
ASSERT_TRUE(req.AddCommandByComponents(parts, sizeof(parts) / sizeof(parts[0])));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
ASSERT_TRUE(resp.reply(0).is_error());
@@ -843,7 +843,7 @@ TEST_F(RedisClusterChannelTest, eval_argument_validation) {
"eval", "return 1", "2", "k1"
};
ASSERT_TRUE(req.AddCommandByComponents(parts, sizeof(parts) / sizeof(parts[0])));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
ASSERT_TRUE(resp.reply(0).is_error());
@@ -864,7 +864,7 @@ TEST_F(RedisClusterChannelTest, async_failure_propagation) {
bthread::CountdownEvent event(1);
Done done(&event);
- channel.CallMethod(NULL, &cntl, &req, &resp, &done);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, &done);
event.wait();
ASSERT_TRUE(cntl.Failed());
@@ -886,7 +886,7 @@ TEST_F(RedisClusterChannelTest, max_redirect_zero_fails_on_single_redirect) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("get %s", key.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_NE(std::string::npos, cntl.ErrorText().find("redirect"));
@@ -912,7 +912,7 @@ TEST_F(RedisClusterChannelTest, redirect_with_refresh_failure_still_returns_repl
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("get %s", key.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_TRUE(resp.reply(0).is_string());
ASSERT_EQ("moved-value", resp.reply(0).data());
@@ -955,7 +955,7 @@ TEST_F(RedisClusterChannelTest, pipeline_with_ask_and_moved_keeps_order) {
ASSERT_TRUE(req.AddCommand("get %s", moved_key.c_str()));
ASSERT_TRUE(req.AddCommand("get %s", ask_key.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(3, resp.reply_size());
ASSERT_EQ("ask-value", resp.reply(0).data());
@@ -984,7 +984,7 @@ TEST_F(RedisClusterChannelTest, fallback_to_nodes_then_recover_to_slots) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("get %s", key.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ("recover-value", resp.reply(0).data());
ASSERT_GT(_meta->slots_calls.load(std::memory_order_relaxed), before_slots);
@@ -1000,7 +1000,7 @@ TEST_F(RedisClusterChannelTest, cluster_slots_empty_host_uses_seed_host) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("set %s host-fallback-value", key.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ("OK", resp.reply(0).data());
}
@@ -1036,7 +1036,7 @@ TEST_F(RedisClusterChannelTest, ping_without_key_uses_any_endpoint) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("ping"));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
ASSERT_TRUE(resp.reply(0).is_string());
@@ -1053,7 +1053,7 @@ TEST_F(RedisClusterChannelTest, wrong_argument_count_commands_return_error_reply
ASSERT_TRUE(req.AddCommand("mget"));
ASSERT_TRUE(req.AddCommand("mset only_key"));
ASSERT_TRUE(req.AddCommand("del"));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(3, resp.reply_size());
@@ -1073,7 +1073,7 @@ TEST_F(RedisClusterChannelTest, malformed_redirect_error_is_returned_directly) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("get %s", key.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
@@ -1101,7 +1101,7 @@ TEST_F(RedisClusterChannelTest, cluster_nodes_parser_ignores_migration_tokens) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("set %s from-nodes", key.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ("OK", resp.reply(0).data());
}
@@ -1117,7 +1117,7 @@ TEST_F(RedisClusterChannelTest, eval_numkeys_zero_routes_without_slot) {
"eval", "return 'ok'", "0", "arg1"
};
ASSERT_TRUE(req.AddCommandByComponents(parts, sizeof(parts) / sizeof(parts[0])));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
@@ -1146,7 +1146,7 @@ TEST_F(RedisClusterChannelTest, mset_stops_after_subcommand_error) {
key_ok.c_str(),
key_err.c_str(),
key_tail.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
@@ -1159,7 +1159,7 @@ TEST_F(RedisClusterChannelTest, mset_stops_after_subcommand_error) {
brpc::RedisResponse get_resp;
brpc::Controller get_cntl;
ASSERT_TRUE(get_req.AddCommand("get %s", key_ok.c_str()));
- channel.CallMethod(NULL, &get_cntl, &get_req, &get_resp, NULL);
+ channel.CallMethod(nullptr, &get_cntl, &get_req, &get_resp, nullptr);
ASSERT_FALSE(get_cntl.Failed()) << get_cntl.ErrorText();
ASSERT_TRUE(get_resp.reply(0).is_string());
ASSERT_EQ("v0", get_resp.reply(0).data());
@@ -1169,7 +1169,7 @@ TEST_F(RedisClusterChannelTest, mset_stops_after_subcommand_error) {
brpc::RedisResponse get_resp;
brpc::Controller get_cntl;
ASSERT_TRUE(get_req.AddCommand("get %s", key_tail.c_str()));
- channel.CallMethod(NULL, &get_cntl, &get_req, &get_resp, NULL);
+ channel.CallMethod(nullptr, &get_cntl, &get_req, &get_resp, nullptr);
ASSERT_FALSE(get_cntl.Failed()) << get_cntl.ErrorText();
ASSERT_TRUE(get_resp.reply(0).is_nil());
}
@@ -1201,7 +1201,7 @@ TEST_F(RedisClusterChannelTest, integer_aggregate_stops_after_subcommand_error)
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("unlink %s %s %s",
key0.c_str(), key_err.c_str(), key_tail.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
@@ -1213,7 +1213,7 @@ TEST_F(RedisClusterChannelTest, integer_aggregate_stops_after_subcommand_error)
brpc::RedisResponse get_resp;
brpc::Controller get_cntl;
ASSERT_TRUE(get_req.AddCommand("get %s", key_tail.c_str()));
- channel.CallMethod(NULL, &get_cntl, &get_req, &get_resp, NULL);
+ channel.CallMethod(nullptr, &get_cntl, &get_req, &get_resp, nullptr);
ASSERT_FALSE(get_cntl.Failed()) << get_cntl.ErrorText();
ASSERT_TRUE(get_resp.reply(0).is_string());
ASSERT_EQ("vtail", get_resp.reply(0).data());
@@ -1267,7 +1267,7 @@ TEST_F(RedisClusterChannelTest, async_concurrent_calls_with_mixed_redirections)
expected[i] = "normal-v";
}
ASSERT_TRUE(requests[i]->AddCommand("get %s", key.c_str()));
- channel.CallMethod(NULL,
+ channel.CallMethod(nullptr,
controllers[i].get(),
requests[i].get(),
responses[i].get(),
@@ -1299,7 +1299,7 @@ TEST_F(RedisClusterChannelTest, hashtag_keys_route_for_multi_key_commands) {
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("mset %s v0 %s v1", key0.c_str(), key1.c_str()));
ASSERT_TRUE(req.AddCommand("mget %s %s", key0.c_str(), key1.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(2, resp.reply_size());
@@ -1321,7 +1321,7 @@ TEST_F(RedisClusterChannelTest, missing_key_get_returns_nil_reply) {
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("get %s", key.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
@@ -1358,7 +1358,7 @@ TEST_F(RedisClusterChannelTest, pipeline_with_string_nil_error_and_string) {
ASSERT_TRUE(req.AddCommand("get %s", key_nil.c_str()));
ASSERT_TRUE(req.AddCommand("get %s", key_err.c_str()));
ASSERT_TRUE(req.AddCommand("get %s", key_ok.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(4, resp.reply_size());
@@ -1379,7 +1379,7 @@ TEST_F(RedisClusterChannelTest, empty_request_should_fail) {
brpc::RedisRequest req;
brpc::RedisResponse resp;
brpc::Controller cntl;
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_NE(std::string::npos, cntl.ErrorText().find("no redis command"));
}
@@ -1401,7 +1401,7 @@ TEST_F(RedisClusterChannelTest, pipeline_continues_after_command_error_reply) {
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("get %s", key_err.c_str()));
ASSERT_TRUE(req.AddCommand("get %s", key_ok.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(2, resp.reply_size());
@@ -1429,7 +1429,7 @@ TEST_F(RedisClusterChannelTest, redirect_updates_slot_cache_even_when_refresh_fa
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("get %s", key.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ("value-on-node1", resp.reply(0).data());
@@ -1437,7 +1437,7 @@ TEST_F(RedisClusterChannelTest, redirect_updates_slot_cache_even_when_refresh_fa
brpc::RedisResponse resp2;
brpc::Controller cntl2;
ASSERT_TRUE(req2.AddCommand("get %s", key.c_str()));
- channel.CallMethod(NULL, &cntl2, &req2, &resp2, NULL);
+ channel.CallMethod(nullptr, &cntl2, &req2, &resp2, nullptr);
ASSERT_FALSE(cntl2.Failed()) << cntl2.ErrorText();
ASSERT_EQ("value-on-node1", resp2.reply(0).data());
@@ -1491,7 +1491,7 @@ TEST_F(RedisClusterChannelTest, periodic_refresh_updates_slot_cache_on_topology_
brpc::RedisResponse resp;
brpc::Controller cntl;
ASSERT_TRUE(req.AddCommand("get %s", key.c_str()));
- channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, resp.reply_size());
ASSERT_TRUE(resp.reply(0).is_string());
@@ -1508,7 +1508,7 @@ TEST_F(RedisClusterChannelTest, periodic_refresh_updates_slot_cache_on_topology_
brpc::RedisResponse resp2;
brpc::Controller cntl2;
ASSERT_TRUE(req2.AddCommand("get %s", key.c_str()));
- channel.CallMethod(NULL, &cntl2, &req2, &resp2, NULL);
+ channel.CallMethod(nullptr, &cntl2, &req2, &resp2, nullptr);
ASSERT_FALSE(cntl2.Failed()) << cntl2.ErrorText();
ASSERT_EQ(1, resp2.reply_size());
ASSERT_TRUE(resp2.reply(0).is_string());
@@ -1540,7 +1540,7 @@ TEST_F(RedisClusterChannelTest, async_pipeline_mixed_commands) {
bthread::CountdownEvent event(1);
Done done(&event);
- channel.CallMethod(NULL, &cntl, &req, &resp, &done);
+ channel.CallMethod(nullptr, &cntl, &req, &resp, &done);
event.wait();
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
diff --git a/test/brpc_redis_unittest.cpp b/test/brpc_redis_unittest.cpp
index dc0f9d55..f4830d04 100644
--- a/test/brpc_redis_unittest.cpp
+++ b/test/brpc_redis_unittest.cpp
@@ -89,7 +89,7 @@ static void RunRedisServer() {
puts("[Starting redis-server]");
char* const argv[] = { (char*)REDIS_SERVER_BIN,
(char*)"--port", (char*)REDIS_SERVER_PORT,
- NULL };
+ nullptr };
unlink("dump.rdb");
if (execvp(REDIS_SERVER_BIN, argv) < 0) {
puts("Fail to run " REDIS_SERVER_BIN);
@@ -185,7 +185,7 @@ TEST_F(RedisTest, sanity) {
brpc::Controller cntl;
ASSERT_TRUE(request.AddCommand("get hello"));
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, response.reply_size());
ASSERT_EQ(brpc::REDIS_REPLY_NIL, response.reply(0).type())
@@ -195,7 +195,7 @@ TEST_F(RedisTest, sanity) {
request.Clear();
response.Clear();
request.AddCommand("set hello world");
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, response.reply_size());
ASSERT_EQ(brpc::REDIS_REPLY_STATUS, response.reply(0).type());
@@ -205,7 +205,7 @@ TEST_F(RedisTest, sanity) {
request.Clear();
response.Clear();
ASSERT_TRUE(request.AddCommand("get hello"));
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed());
ASSERT_EQ(1, response.reply_size());
ASSERT_EQ(brpc::REDIS_REPLY_STRING, response.reply(0).type());
@@ -215,7 +215,7 @@ TEST_F(RedisTest, sanity) {
request.Clear();
response.Clear();
request.AddCommand("set hello world2");
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, response.reply_size());
ASSERT_EQ(brpc::REDIS_REPLY_STATUS, response.reply(0).type());
@@ -225,7 +225,7 @@ TEST_F(RedisTest, sanity) {
request.Clear();
response.Clear();
ASSERT_TRUE(request.AddCommand("get hello"));
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed());
ASSERT_EQ(1, response.reply_size());
ASSERT_EQ(brpc::REDIS_REPLY_STRING, response.reply(0).type());
@@ -235,7 +235,7 @@ TEST_F(RedisTest, sanity) {
request.Clear();
response.Clear();
ASSERT_TRUE(request.AddCommand("del hello"));
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed());
ASSERT_EQ(brpc::REDIS_REPLY_INTEGER, response.reply(0).type());
ASSERT_EQ(1, response.reply(0).integer());
@@ -244,7 +244,7 @@ TEST_F(RedisTest, sanity) {
request.Clear();
response.Clear();
ASSERT_TRUE(request.AddCommand("get %s", "hello"));
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, response.reply_size());
ASSERT_EQ(brpc::REDIS_REPLY_NIL, response.reply(0).type());
@@ -274,7 +274,7 @@ TEST_F(RedisTest, keys_with_spaces) {
ASSERT_TRUE(request.AddCommand("get 'hello2 world2'"));
ASSERT_TRUE(request.AddCommand("get 'hello3 world3'"));
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(7, response.reply_size());
ASSERT_EQ(brpc::REDIS_REPLY_STATUS, response.reply(0).type());
@@ -315,7 +315,7 @@ TEST_F(RedisTest, incr_and_decr) {
request.AddCommand("decr counter1");
request.AddCommand("incrby counter1 %d", 10);
request.AddCommand("decrby counter1 %d", 20);
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(4, response.reply_size());
ASSERT_EQ(brpc::REDIS_REPLY_INTEGER, response.reply(0).type());
@@ -356,7 +356,7 @@ TEST_F(RedisTest, by_components) {
request.AddCommandByComponents(comp3, arraysize(comp3));
request.AddCommandByComponents(comp4, arraysize(comp4));
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(4, response.reply_size());
ASSERT_EQ(brpc::REDIS_REPLY_INTEGER, response.reply(0).type());
@@ -408,7 +408,7 @@ TEST_F(RedisTest, auth) {
request.AddCommand("auth %s", passwd1.c_str());
request.AddCommand("get mykey");
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(4, response.reply_size());
ASSERT_EQ(brpc::REDIS_REPLY_STATUS, response.reply(0).type());
@@ -432,7 +432,7 @@ TEST_F(RedisTest, auth) {
brpc::Controller cntl;
request.AddCommand("get mykey");
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, response.reply_size());
ASSERT_EQ(brpc::REDIS_REPLY_ERROR, response.reply(0).type());
@@ -455,7 +455,7 @@ TEST_F(RedisTest, auth) {
request.AddCommand("get mykey");
request.AddCommand("config set requirepass %s", passwd2.c_str());
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(2, response.reply_size());
ASSERT_EQ(brpc::REDIS_REPLY_STRING, response.reply(0).type());
@@ -478,7 +478,7 @@ TEST_F(RedisTest, auth) {
brpc::Controller cntl;
request.AddCommand("get mykey");
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, response.reply_size());
ASSERT_EQ(brpc::REDIS_REPLY_STRING, response.reply(0).type()) << response.reply(0);
@@ -1178,7 +1178,7 @@ TEST_F(RedisTest, server_sanity) {
ASSERT_TRUE(request.AddCommand("set key2 value2"));
ASSERT_TRUE(request.AddCommand("get key2"));
ASSERT_TRUE(request.AddCommand("xxxcommand key2"));
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(7, response.reply_size());
ASSERT_EQ(brpc::REDIS_REPLY_NIL, response.reply(0).type());
@@ -1208,7 +1208,7 @@ TEST_F(RedisTest, server_sanity) {
ASSERT_TRUE(request.AddCommand("set key4 \"\""));
ASSERT_TRUE(request.AddCommand("get key3"));
ASSERT_TRUE(request.AddCommand("get key4"));
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(4, response.reply_size());
ASSERT_EQ(brpc::REDIS_REPLY_STATUS, response.reply(0).type());
@@ -1230,12 +1230,12 @@ void* incr_thread(void* arg) {
brpc::RedisResponse response;
brpc::Controller cntl;
EXPECT_TRUE(request.AddCommand("incr count"));
- c->CallMethod(NULL, &cntl, &request, &response, NULL);
+ c->CallMethod(nullptr, &cntl, &request, &response, nullptr);
EXPECT_FALSE(cntl.Failed()) << cntl.ErrorText();
EXPECT_EQ(1, response.reply_size());
EXPECT_TRUE(response.reply(0).is_integer()) << response.reply(0);
}
- return NULL;
+ return nullptr;
}
TEST_F(RedisTest, server_concurrency) {
@@ -1264,12 +1264,12 @@ TEST_F(RedisTest, server_concurrency) {
channels.push_back(new brpc::Channel);
ASSERT_EQ(0, channels.back()->Init("127.0.0.1", server.listen_address().port, &options));
bthread_t bth;
- ASSERT_EQ(bthread_start_background(&bth, NULL, incr_thread, channels.back()), 0);
+ ASSERT_EQ(bthread_start_background(&bth, nullptr, incr_thread, channels.back()), 0);
bths.push_back(bth);
}
for (int i = 0; i < N; ++i) {
- bthread_join(bths[i], NULL);
+ bthread_join(bths[i], nullptr);
delete channels[i];
}
ASSERT_EQ(int_map["count"], 10 * 5000LL);
@@ -1359,7 +1359,7 @@ TEST_F(RedisTest, server_command_continue) {
brpc::Controller cntl;
ASSERT_TRUE(request.AddCommand("set hello world"));
ASSERT_TRUE(request.AddCommand("get hello"));
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(2, response.reply_size());
ASSERT_STREQ("world", response.reply(1).c_str());
@@ -1375,7 +1375,7 @@ TEST_F(RedisTest, server_command_continue) {
ASSERT_TRUE(request.AddCommand("incr hello 1"));
}
ASSERT_TRUE(request.AddCommand("exec"));
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_EQ(13, response.reply_size());
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(brpc::REDIS_REPLY_STATUS, response.reply(0).type());
@@ -1400,7 +1400,7 @@ TEST_F(RedisTest, server_command_continue) {
ASSERT_TRUE(request.AddCommand("get hello2"));
ASSERT_TRUE(request.AddCommand("set key1 value1"));
ASSERT_TRUE(request.AddCommand("get key1"));
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_STREQ("world", response.reply(0).c_str());
ASSERT_EQ(brpc::REDIS_REPLY_NIL, response.reply(1).type());
@@ -1447,7 +1447,7 @@ TEST_F(RedisTest, server_handle_pipeline) {
ASSERT_TRUE(request.AddCommand("set key1 world"));
ASSERT_TRUE(request.AddCommand("set key2 world"));
ASSERT_TRUE(request.AddCommand("get key2"));
- channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+ channel.CallMethod(nullptr, &cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(8, response.reply_size());
ASSERT_EQ(1, rsimpl->_batch_count);
diff --git a/test/brpc_rtmp_unittest.cpp b/test/brpc_rtmp_unittest.cpp
index 286f8a87..9fce3919 100644
--- a/test/brpc_rtmp_unittest.cpp
+++ b/test/brpc_rtmp_unittest.cpp
@@ -269,7 +269,7 @@ public:
<< " ms before responding play request";
bthread_usleep(_sleep_ms * 1000L);
}
- int rc = bthread_start_background(&_play_thread, NULL,
+ int rc = bthread_start_background(&_play_thread, nullptr,
RunSendData, this);
if (rc) {
status->set_error(rc, "Fail to create thread");
@@ -279,7 +279,7 @@ public:
if (!_state.compare_exchange_strong(expected, STATE_PLAYING)) {
if (expected == STATE_STOPPED) {
bthread_stop(_play_thread);
- bthread_join(_play_thread, NULL);
+ bthread_join(_play_thread, nullptr);
} else {
CHECK(false) << "Impossible";
}
@@ -290,7 +290,7 @@ public:
LOG(INFO) << "OnStop of PlayingDummyStream=" << this;
if (_state.exchange(STATE_STOPPED) == STATE_PLAYING) {
bthread_stop(_play_thread);
- bthread_join(_play_thread, NULL);
+ bthread_join(_play_thread, nullptr);
}
}
@@ -299,7 +299,7 @@ public:
private:
static void* RunSendData(void* arg) {
((PlayingDummyStream*)arg)->SendData();
- return NULL;
+ return nullptr;
}
butil::atomic<State> _state;
@@ -421,7 +421,7 @@ private:
class PublishService : public brpc::RtmpService {
public:
PublishService(int64_t sleep_ms = 0) : _sleep_ms(sleep_ms) {
- pthread_mutex_init(&_mutex, NULL);
+ pthread_mutex_init(&_mutex, nullptr);
}
~PublishService() {
pthread_mutex_destroy(&_mutex);
@@ -824,7 +824,7 @@ TEST(RtmpTest, abort_message_naming_own_chunk_stream) {
brpc::SocketUniquePtr sock;
ASSERT_EQ(0, brpc::Socket::Address(id, &sock));
- brpc::policy::RtmpContext ctx(NULL, NULL);
+ brpc::policy::RtmpContext ctx(nullptr, nullptr);
ctx.SetState(sock->remote_side(),
brpc::policy::RtmpContext::STATE_RECEIVED_C2);
diff --git a/test/brpc_server_unittest.cpp b/test/brpc_server_unittest.cpp
index 1012ce25..ed0268e8 100644
--- a/test/brpc_server_unittest.cpp
+++ b/test/brpc_server_unittest.cpp
@@ -75,13 +75,13 @@ extern bool SerializeRpcMessage(const google::protobuf::Message& serializer,
Controller& cntl, ContentType content_type,
CompressType compress_type,
ChecksumType checksum_type, butil::IOBuf* buf,
- const butil::IOBuf* checksum_attachment = NULL);
+ const butil::IOBuf* checksum_attachment = nullptr);
extern bool DeserializeRpcMessage(const butil::IOBuf& deserializer,
Controller& cntl, ContentType content_type,
CompressType compress_type,
ChecksumType checksum_type,
google::protobuf::Message* message,
- const butil::IOBuf* checksum_attachment = NULL);
+ const butil::IOBuf* checksum_attachment = nullptr);
}
}
@@ -90,7 +90,7 @@ namespace {
void* RunClosure(void* arg) {
google::protobuf::Closure* done = (google::protobuf::Closure*)arg;
done->Run();
- return NULL;
+ return nullptr;
}
bool g_verify_success = true;
@@ -145,7 +145,7 @@ public:
if (cntl->has_request_user_fields()) {
ASSERT_TRUE(!cntl->request_user_fields()->empty());
std::string* val = cntl->request_user_fields()->seek(EXP_USER_FIELD_KEY);
- ASSERT_TRUE(val != NULL);
+ ASSERT_TRUE(val != nullptr);
ASSERT_EQ(*val, EXP_USER_FIELD_VALUE);
cntl->response_user_fields()->insert(EXP_USER_FIELD_KEY, EXP_USER_FIELD_VALUE);
}
@@ -216,26 +216,26 @@ protected:
TEST_F(ServerTest, sanity) {
{
brpc::Server server;
- ASSERT_EQ(-1, server.Start("127.0.0.1:12345:asdf", NULL));
- ASSERT_EQ(-1, server.Start("127.0.0.1:99999", NULL));
- ASSERT_EQ(0, server.Start("127.0.0.1:8613", NULL));
+ ASSERT_EQ(-1, server.Start("127.0.0.1:12345:asdf", nullptr));
+ ASSERT_EQ(-1, server.Start("127.0.0.1:99999", nullptr));
+ ASSERT_EQ(0, server.Start("127.0.0.1:8613", nullptr));
}
{
brpc::Server server;
// accept hostname as well.
- ASSERT_EQ(0, server.Start("localhost:8613", NULL));
+ ASSERT_EQ(0, server.Start("localhost:8613", nullptr));
}
{
brpc::Server server;
- ASSERT_EQ(0, server.Start("localhost:0", NULL));
+ ASSERT_EQ(0, server.Start("localhost:0", nullptr));
// port should be replaced with the actually used one.
ASSERT_NE(0, server.listen_address().port);
}
{
brpc::Server server;
- ASSERT_EQ(-1, server.Start(99999, NULL));
- ASSERT_EQ(0, server.Start(8613, NULL));
+ ASSERT_EQ(-1, server.Start(99999, nullptr));
+ ASSERT_EQ(0, server.Start(8613, nullptr));
}
{
brpc::Server server;
@@ -244,7 +244,7 @@ TEST_F(ServerTest, sanity) {
ASSERT_EQ(-1, server.Start("127.0.0.1:8613", &options));
ASSERT_FALSE(server.IsRunning()); // Revert server's status
// And release the listen port
- ASSERT_EQ(0, server.Start("127.0.0.1:8613", NULL));
+ ASSERT_EQ(0, server.Start("127.0.0.1:8613", nullptr));
}
{
brpc::Server server;
@@ -252,7 +252,7 @@ TEST_F(ServerTest, sanity) {
ASSERT_EQ(0, server.Start(brpc::PortRange(8000, 9000), &options));
ASSERT_TRUE(server.IsRunning());
ASSERT_EQ(0ul, server.service_count());
- ASSERT_TRUE(NULL == server.first_service());
+ ASSERT_TRUE(nullptr == server.first_service());
ASSERT_EQ(0, server.Stop(0));
ASSERT_EQ(0, server.Join());
}
@@ -267,7 +267,7 @@ TEST_F(ServerTest, sanity) {
ASSERT_TRUE(server.IsRunning());
ASSERT_EQ(&auth, server.options().auth);
ASSERT_EQ(0ul, server.service_count());
- ASSERT_TRUE(NULL == server.first_service());
+ ASSERT_TRUE(nullptr == server.first_service());
std::vector<google::protobuf::Service*> services;
server.ListServices(&services);
@@ -402,7 +402,7 @@ TEST_F(ServerTest, empty_enabled_protocols) {
test::EchoResponse res;
req.set_message(EXP_REQUEST);
test::EchoService_Stub stub(&chan);
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(0, server.Stop(0));
@@ -428,7 +428,7 @@ TEST_F(ServerTest, only_allow_protocols_in_enabled_protocols) {
copt.protocol = "http";
ASSERT_EQ(0, http_channel.Init(ep, &copt));
cntl.Reset();
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << cntl.response_attachment();
// Unmatched protocols are not allowed.
@@ -440,7 +440,7 @@ TEST_F(ServerTest, only_allow_protocols_in_enabled_protocols) {
cntl.Reset();
req.set_message(EXP_REQUEST);
test::EchoService_Stub stub(&chan);
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_TRUE(cntl.ErrorText().find("Got EOF of ") != std::string::npos);
@@ -453,7 +453,7 @@ TEST_F(ServerTest, services_in_different_ns) {
brpc::Server server1;
EchoServiceV1 service_v1;
ASSERT_EQ(0, server1.AddService(&service_v1, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server1.Start(port, NULL));
+ ASSERT_EQ(0, server1.Start(port, nullptr));
brpc::Channel http_channel;
brpc::ChannelOptions chan_options;
chan_options.protocol = "http";
@@ -462,14 +462,14 @@ TEST_F(ServerTest, services_in_different_ns) {
cntl.http_request().uri() = "/EchoService/Echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"foo\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << cntl.response_attachment();
ASSERT_EQ(1, service_v1.ncalled.load());
cntl.Reset();
cntl.http_request().uri() = "/v1.EchoService/Echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"foo\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << cntl.response_attachment();
ASSERT_EQ(2, service_v1.ncalled.load());
//Stop the server to add another service.
@@ -483,20 +483,20 @@ TEST_F(ServerTest, services_in_different_ns) {
ASSERT_EQ(-1, server1.AddService(&service_v2, brpc::SERVER_DOESNT_OWN_SERVICE));
#else
ASSERT_EQ(0, server1.AddService(&service_v2, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server1.Start(port, NULL));
+ ASSERT_EQ(0, server1.Start(port, nullptr));
//sleep(3); // wait for HC
cntl.Reset();
cntl.http_request().uri() = "/v2.EchoService/Echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"value\":33}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << cntl.response_attachment();
ASSERT_EQ(1, service_v2.ncalled.load());
cntl.Reset();
cntl.http_request().uri() = "/EchoService/Echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"value\":33}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << cntl.response_attachment();
ASSERT_EQ(2, service_v2.ncalled.load());
server1.Stop(0);
@@ -509,7 +509,7 @@ TEST_F(ServerTest, various_forms_of_uri_paths) {
brpc::Server server1;
EchoServiceV1 service_v1;
ASSERT_EQ(0, server1.AddService(&service_v1, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server1.Start(port, NULL));
+ ASSERT_EQ(0, server1.Start(port, nullptr));
brpc::Channel http_channel;
brpc::ChannelOptions chan_options;
chan_options.protocol = "http";
@@ -518,7 +518,7 @@ TEST_F(ServerTest, various_forms_of_uri_paths) {
cntl.http_request().uri() = "/EchoService/Echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"foo\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << cntl.response_attachment();
ASSERT_EQ(1, service_v1.ncalled.load());
@@ -526,7 +526,7 @@ TEST_F(ServerTest, various_forms_of_uri_paths) {
cntl.http_request().uri() = "/EchoService///Echo//";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"foo\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << cntl.response_attachment();
ASSERT_EQ(2, service_v1.ncalled.load());
@@ -534,7 +534,7 @@ TEST_F(ServerTest, various_forms_of_uri_paths) {
cntl.http_request().uri() = "/EchoService /Echo/";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"foo\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_EQ(brpc::EREQUEST, cntl.ErrorCode());
LOG(INFO) << "Expected error: " << cntl.ErrorText();
@@ -545,7 +545,7 @@ TEST_F(ServerTest, various_forms_of_uri_paths) {
cntl.http_request().uri() = "/EchoService/Echo/Foo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"foo\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(3, service_v1.ncalled.load());
@@ -559,14 +559,14 @@ TEST_F(ServerTest, missing_required_fields) {
brpc::Server server1;
EchoServiceV1 service_v1;
ASSERT_EQ(0, server1.AddService(&service_v1, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server1.Start(port, NULL));
+ ASSERT_EQ(0, server1.Start(port, nullptr));
brpc::Channel http_channel;
brpc::ChannelOptions chan_options;
chan_options.protocol = "http";
ASSERT_EQ(0, http_channel.Init("0.0.0.0", port, &chan_options));
brpc::Controller cntl;
cntl.http_request().uri() = "/EchoService/Echo";
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_EQ(brpc::EHTTP, cntl.ErrorCode());
LOG(INFO) << cntl.ErrorText();
@@ -576,7 +576,7 @@ TEST_F(ServerTest, missing_required_fields) {
cntl.Reset();
cntl.http_request().uri() = "/EchoService/Echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_EQ(brpc::EHTTP, cntl.ErrorCode());
ASSERT_EQ(brpc::HTTP_STATUS_BAD_REQUEST, cntl.http_response().status_code());
@@ -586,7 +586,7 @@ TEST_F(ServerTest, missing_required_fields) {
cntl.http_request().uri() = "/EchoService/Echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message2\":\"foo\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_EQ(brpc::EHTTP, cntl.ErrorCode());
ASSERT_EQ(brpc::HTTP_STATUS_BAD_REQUEST, cntl.http_response().status_code());
@@ -601,14 +601,14 @@ TEST_F(ServerTest, disallow_http_body_to_pb) {
svc_opt.allow_http_body_to_pb = false;
svc_opt.restful_mappings = "/access_echo1=>Echo";
ASSERT_EQ(0, server1.AddService(&service_v1, svc_opt));
- ASSERT_EQ(0, server1.Start(port, NULL));
+ ASSERT_EQ(0, server1.Start(port, nullptr));
brpc::Channel http_channel;
brpc::ChannelOptions chan_options;
chan_options.protocol = "http";
ASSERT_EQ(0, http_channel.Init("0.0.0.0", port, &chan_options));
brpc::Controller cntl;
cntl.http_request().uri() = "/access_echo1";
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_EQ(brpc::EHTTP, cntl.ErrorCode());
ASSERT_EQ(brpc::HTTP_STATUS_INTERNAL_SERVER_ERROR,
@@ -619,7 +619,7 @@ TEST_F(ServerTest, disallow_http_body_to_pb) {
cntl.http_request().uri() = "/access_echo1";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("heheda");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ("heheda", cntl.response_attachment());
ASSERT_EQ(2, service_v1.ncalled.load());
@@ -748,7 +748,7 @@ TEST_F(ServerTest, restful_mapping) {
ASSERT_FALSE(server10._global_restful_map);
// Access services
- ASSERT_EQ(0, server1.Start(port, NULL));
+ ASSERT_EQ(0, server1.Start(port, nullptr));
brpc::Channel http_channel;
brpc::ChannelOptions chan_options;
chan_options.protocol = "http";
@@ -759,7 +759,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/EchoService/Echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"foo\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_EQ(0, service_v1.ncalled.load());
@@ -768,7 +768,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v1/echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"foo\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, service_v1.ncalled.load());
ASSERT_EQ("{\"message\":\"foo_v1\"}", cntl.response_attachment());
@@ -778,7 +778,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v3/echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"bar\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(2, service_v1.ncalled.load());
ASSERT_EQ("{\"message\":\"bar_v1\"}", cntl.response_attachment());
@@ -788,7 +788,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = " //v1///echo//// ";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"hello\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(3, service_v1.ncalled.load());
ASSERT_EQ("{\"message\":\"hello_v1\"}", cntl.response_attachment());
@@ -798,7 +798,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v3/echo/anything";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"foo\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_EQ(brpc::EHTTP, cntl.ErrorCode());
LOG(INFO) << "Expected error: " << cntl.ErrorText();
@@ -809,7 +809,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v2/echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"hehe\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(4, service_v1.ncalled.load());
ASSERT_EQ("{\"message\":\"hehe_v1\"}", cntl.response_attachment());
@@ -819,7 +819,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v2/echo/anything";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"good\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(5, service_v1.ncalled.load());
ASSERT_EQ("{\"message\":\"good_v1\"}", cntl.response_attachment());
@@ -828,7 +828,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v4_echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"hoho\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(6, service_v1.ncalled.load());
ASSERT_EQ("{\"message\":\"hoho_v1\"}", cntl.response_attachment());
@@ -837,7 +837,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v5/echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"xyz\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(7, service_v1.ncalled.load());
ASSERT_EQ("{\"message\":\"xyz_v1\"}", cntl.response_attachment());
@@ -846,7 +846,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v6/echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"xyz\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(8, service_v1.ncalled.load());
ASSERT_EQ("{\"message\":\"xyz_v1\"}", cntl.response_attachment());
@@ -855,7 +855,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v6/echo/test";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"xyz\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, service_v1.ncalled_echo2.load());
ASSERT_EQ("{\"message\":\"xyz_v1_Echo2\"}", cntl.response_attachment());
@@ -864,7 +864,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v6/abc/heheda/def";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"abc_heheda\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, service_v1.ncalled_echo3.load());
ASSERT_EQ("{\"message\":\"abc_heheda_v1_Echo3\"}", cntl.response_attachment());
@@ -873,7 +873,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v6/abc/def";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"abc\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(2, service_v1.ncalled_echo3.load());
ASSERT_EQ("{\"message\":\"abc_v1_Echo3\"}", cntl.response_attachment());
@@ -883,7 +883,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v6/abc/heheda/def2";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"xyz\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_EQ(2, service_v1.ncalled_echo3.load());
@@ -891,7 +891,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v6/echo/1.flv";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"1.flv\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ("{\"message\":\"1.flv_v1_Echo4\"}", cntl.response_attachment());
ASSERT_EQ(1, service_v1.ncalled_echo4.load());
@@ -900,7 +900,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "//v6//d.flv//";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"d.flv\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ("{\"message\":\"d.flv_v1_Echo5\"}", cntl.response_attachment());
ASSERT_EQ(1, service_v1.ncalled_echo5.load());
@@ -910,7 +910,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "//d.flv//";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"d.flv\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ("{\"message\":\"d.flv_v1\"}", cntl.response_attachment());
ASSERT_EQ(9, service_v1.ncalled.load());
@@ -919,7 +919,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v7/e.flv";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"e.flv\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ("{\"message\":\"e.flv_v1\"}", cntl.response_attachment());
ASSERT_EQ(10, service_v1.ncalled.load());
@@ -928,7 +928,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v0/f.flv";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"f.flv\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ("{\"message\":\"f.flv_v1\"}", cntl.response_attachment());
ASSERT_EQ(11, service_v1.ncalled.load());
@@ -938,21 +938,21 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/v6/ech/1.ts";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"1.ts\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl.Failed());
//Stop the server.
server1.Stop(0);
server1.Join();
- ASSERT_EQ(0, server10.Start(port, NULL));
+ ASSERT_EQ(0, server10.Start(port, nullptr));
// access v1.Echo via /v1/echo.
cntl.Reset();
cntl.http_request().uri() = "/v1/echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"foo\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(12, service_v1.ncalled.load());
ASSERT_EQ("{\"message\":\"foo_v1\"}", cntl.response_attachment());
@@ -962,7 +962,7 @@ TEST_F(ServerTest, restful_mapping) {
cntl.http_request().uri() = "/EchoService/Echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"foo\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(13, service_v1.ncalled.load());
ASSERT_EQ("{\"message\":\"foo_v1\"}", cntl.response_attachment());
@@ -986,7 +986,7 @@ TEST_F(ServerTest, http_error_code) {
brpc::Server server1;
EchoServiceV1 service_v1;
ASSERT_EQ(0, server1.AddService(&service_v1, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server1.Start(port, NULL));
+ ASSERT_EQ(0, server1.Start(port, nullptr));
brpc::Channel http_channel;
brpc::ChannelOptions chan_options;
@@ -994,7 +994,7 @@ TEST_F(ServerTest, http_error_code) {
ASSERT_EQ(0, http_channel.Init("0.0.0.0", port, &chan_options));
brpc::Controller cntl;
cntl.http_request().uri() = "/EchoService/Echo";
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_EQ(brpc::EREQUEST, cntl.ErrorCode());
LOG(INFO) << cntl.ErrorText();
@@ -1010,14 +1010,14 @@ TEST_F(ServerTest, http_error_code) {
svc_opt.allow_http_body_to_pb = false;
svc_opt.restful_mappings = "/access_echo1=>Echo";
ASSERT_EQ(0, server1.AddService(&service_v1, svc_opt));
- ASSERT_EQ(0, server1.Start(port, NULL));
+ ASSERT_EQ(0, server1.Start(port, nullptr));
brpc::Channel http_channel;
brpc::ChannelOptions chan_options;
chan_options.protocol = "http";
ASSERT_EQ(0, http_channel.Init("0.0.0.0", port, &chan_options));
brpc::Controller cntl;
cntl.http_request().uri() = "/access_echo1";
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_EQ(brpc::ERESPONSE, cntl.ErrorCode());
ASSERT_EQ(brpc::HTTP_STATUS_INTERNAL_SERVER_ERROR,
@@ -1059,7 +1059,7 @@ TEST_F(ServerTest, http_error_code) {
ASSERT_TRUE(server1._global_restful_map);
ASSERT_EQ(1UL, server1._global_restful_map->size());
- ASSERT_EQ(0, server1.Start(port, NULL));
+ ASSERT_EQ(0, server1.Start(port, nullptr));
brpc::Channel http_channel;
brpc::ChannelOptions chan_options;
chan_options.protocol = "http";
@@ -1068,7 +1068,7 @@ TEST_F(ServerTest, http_error_code) {
cntl.http_request().uri() = "/v3/echo/anything";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"foo\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_EQ(brpc::ENOMETHOD, cntl.ErrorCode());
LOG(INFO) << "Expected error: " << cntl.ErrorText();
@@ -1085,21 +1085,21 @@ TEST_F(ServerTest, http_error_code) {
server1.MaxConcurrencyOf(&service1, "Echo") = 2;
ASSERT_EQ(2, server1.MaxConcurrencyOf(&service1, "Echo"));
- ASSERT_EQ(0, server1.Start(port, NULL));
+ ASSERT_EQ(0, server1.Start(port, nullptr));
brpc::Channel http_channel;
brpc::ChannelOptions chan_options;
chan_options.protocol = "http";
ASSERT_EQ(0, http_channel.Init("0.0.0.0", port, &chan_options));
brpc::Channel normal_channel;
- ASSERT_EQ(0, normal_channel.Init("0.0.0.0", port, NULL));
+ ASSERT_EQ(0, normal_channel.Init("0.0.0.0", port, nullptr));
test::EchoService_Stub stub(&normal_channel);
brpc::Controller cntl1;
cntl1.http_request().uri() = "/EchoService/Echo";
cntl1.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl1.request_attachment().append("{\"message\":\"hello\",\"sleep_us\":100000}");
- http_channel.CallMethod(NULL, &cntl1, NULL, NULL, brpc::DoNothing());
+ http_channel.CallMethod(nullptr, &cntl1, nullptr, nullptr, brpc::DoNothing());
brpc::Controller cntl2;
test::EchoRequest req;
@@ -1115,7 +1115,7 @@ TEST_F(ServerTest, http_error_code) {
cntl3.http_request().uri() = "/EchoService/Echo";
cntl3.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl3.request_attachment().append("{\"message\":\"hello\"}");
- http_channel.CallMethod(NULL, &cntl3, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl3, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl3.Failed());
ASSERT_EQ(brpc::ELIMIT, cntl3.ErrorCode());
ASSERT_EQ(brpc::HTTP_STATUS_SERVICE_UNAVAILABLE, cntl3.http_response().status_code());
@@ -1140,9 +1140,9 @@ TEST_F(ServerTest, conflict_name_between_restful_mapping_and_builtin) {
brpc::SERVER_DOESNT_OWN_SERVICE,
"/status/hello => Echo"));
ASSERT_EQ(1u, server1.service_count());
- ASSERT_TRUE(server1._global_restful_map == NULL);
+ ASSERT_TRUE(server1._global_restful_map == nullptr);
- ASSERT_EQ(-1, server1.Start(port, NULL));
+ ASSERT_EQ(-1, server1.Start(port, nullptr));
}
TEST_F(ServerTest, restful_mapping_is_tried_after_others) {
@@ -1159,7 +1159,7 @@ TEST_F(ServerTest, restful_mapping_is_tried_after_others) {
ASSERT_TRUE(server1._global_restful_map);
ASSERT_EQ(1UL, server1._global_restful_map->size());
- ASSERT_EQ(0, server1.Start(port, NULL));
+ ASSERT_EQ(0, server1.Start(port, nullptr));
brpc::Channel http_channel;
brpc::ChannelOptions chan_options;
@@ -1169,7 +1169,7 @@ TEST_F(ServerTest, restful_mapping_is_tried_after_others) {
// accessing /status should be OK.
brpc::Controller cntl;
cntl.http_request().uri() = "/status";
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_TRUE(cntl.response_attachment().to_string().find(
service_v1.GetDescriptor()->full_name()) != std::string::npos)
@@ -1180,7 +1180,7 @@ TEST_F(ServerTest, restful_mapping_is_tried_after_others) {
cntl.http_request().uri() = "/EchoService/Echo";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"foo\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl.Failed());
ASSERT_EQ(0, service_v1.ncalled.load());
@@ -1189,7 +1189,7 @@ TEST_F(ServerTest, restful_mapping_is_tried_after_others) {
cntl.http_request().uri() = "/non_exist";
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl.request_attachment().append("{\"message\":\"foo\"}");
- http_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(1, service_v1.ncalled.load());
ASSERT_EQ("{\"message\":\"foo_v1\"}", cntl.response_attachment());
@@ -1218,12 +1218,12 @@ TEST_F(ServerTest, add_remove_service) {
test::EchoService::descriptor()->name()) == &echo_svc);
ASSERT_TRUE(server.FindServiceByFullName(
test::EchoService::descriptor()->full_name()) == &echo_svc);
- ASSERT_TRUE(NULL == server.FindServiceByFullName(
+ ASSERT_TRUE(nullptr == server.FindServiceByFullName(
test::EchoService::descriptor()->name()));
butil::EndPoint ep;
ASSERT_EQ(0, str2endpoint("127.0.0.1:8613", &ep));
- ASSERT_EQ(0, server.Start(ep, NULL));
+ ASSERT_EQ(0, server.Start(ep, nullptr));
ASSERT_EQ(1ul, server.service_count());
ASSERT_TRUE(server.first_service() == &echo_svc);
@@ -1251,7 +1251,7 @@ TEST_F(ServerTest, add_remove_service) {
void SendSleepRPC(butil::EndPoint ep, int sleep_ms, bool succ) {
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init(ep, NULL));
+ ASSERT_EQ(0, channel.Init(ep, nullptr));
brpc::Controller cntl;
test::EchoRequest req;
@@ -1261,7 +1261,7 @@ void SendSleepRPC(butil::EndPoint ep, int sleep_ms, bool succ) {
req.set_sleep_us(sleep_ms * 1000);
}
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
if (succ) {
EXPECT_FALSE(cntl.Failed()) << cntl.ErrorText()
<< " latency=" << cntl.latency_us();
@@ -1278,7 +1278,7 @@ TEST_F(ServerTest, close_idle_connections) {
ASSERT_EQ(0, str2endpoint("127.0.0.1:9776", &ep));
ASSERT_EQ(0, server.Start(ep, &opt));
- const int cfd = tcp_connect(ep, NULL);
+ const int cfd = tcp_connect(ep, nullptr);
ASSERT_GT(cfd, 0);
usleep(10000);
brpc::ServerStatistics stat;
@@ -1301,12 +1301,12 @@ TEST_F(ServerTest, logoff_and_multiple_start) {
// Server::Stop(-1)
{
- ASSERT_EQ(0, server.Start(ep, NULL));
+ ASSERT_EQ(0, server.Start(ep, nullptr));
bthread_t tid;
const int64_t old_count = echo_svc.count.load(butil::memory_order_relaxed);
google::protobuf::Closure* thrd_func =
brpc::NewCallback(SendSleepRPC, ep, 100, true);
- EXPECT_EQ(0, bthread_start_background(&tid, NULL, RunClosure, thrd_func));
+ EXPECT_EQ(0, bthread_start_background(&tid, nullptr, RunClosure, thrd_func));
while (echo_svc.count.load(butil::memory_order_relaxed) == old_count) {
bthread_usleep(1000);
}
@@ -1315,18 +1315,18 @@ TEST_F(ServerTest, logoff_and_multiple_start) {
ASSERT_EQ(0, server.Join());
timer.stop();
EXPECT_TRUE(labs(timer.m_elapsed() - 100) < 15) << timer.m_elapsed();
- bthread_join(tid, NULL);
+ bthread_join(tid, nullptr);
}
// Server::Stop(0)
{
++ep.port;
- ASSERT_EQ(0, server.Start(ep, NULL));
+ ASSERT_EQ(0, server.Start(ep, nullptr));
bthread_t tid;
const int64_t old_count = echo_svc.count.load(butil::memory_order_relaxed);
google::protobuf::Closure* thrd_func =
brpc::NewCallback(SendSleepRPC, ep, 100, true);
- EXPECT_EQ(0, bthread_start_background(&tid, NULL, RunClosure, thrd_func));
+ EXPECT_EQ(0, bthread_start_background(&tid, nullptr, RunClosure, thrd_func));
while (echo_svc.count.load(butil::memory_order_relaxed) == old_count) {
bthread_usleep(1000);
}
@@ -1338,18 +1338,18 @@ TEST_F(ServerTest, logoff_and_multiple_start) {
// Assertion will fail since EchoServiceImpl::Echo is holding
// additional reference to the `Socket'
// EXPECT_TRUE(timer.m_elapsed() < 15) << timer.m_elapsed();
- bthread_join(tid, NULL);
+ bthread_join(tid, nullptr);
}
// Server::Stop(timeout) where timeout < g_sleep_ms
{
++ep.port;
- ASSERT_EQ(0, server.Start(ep, NULL));
+ ASSERT_EQ(0, server.Start(ep, nullptr));
bthread_t tid;
const int64_t old_count = echo_svc.count.load(butil::memory_order_relaxed);
google::protobuf::Closure* thrd_func =
brpc::NewCallback(SendSleepRPC, ep, 100, true);
- EXPECT_EQ(0, bthread_start_background(&tid, NULL, RunClosure, thrd_func));
+ EXPECT_EQ(0, bthread_start_background(&tid, nullptr, RunClosure, thrd_func));
while (echo_svc.count.load(butil::memory_order_relaxed) == old_count) {
bthread_usleep(1000);
}
@@ -1361,18 +1361,18 @@ TEST_F(ServerTest, logoff_and_multiple_start) {
// Assertion will fail since EchoServiceImpl::Echo is holding
// additional reference to the `Socket'
// EXPECT_TRUE(labs(timer.m_elapsed() - 50) < 15) << timer.m_elapsed();
- bthread_join(tid, NULL);
+ bthread_join(tid, nullptr);
}
// Server::Stop(timeout) where timeout > g_sleep_ms
{
++ep.port;
- ASSERT_EQ(0, server.Start(ep, NULL));
+ ASSERT_EQ(0, server.Start(ep, nullptr));
bthread_t tid;
const int64_t old_count = echo_svc.count.load(butil::memory_order_relaxed);
google::protobuf::Closure* thrd_func =
brpc::NewCallback(SendSleepRPC, ep, 100, true);
- EXPECT_EQ(0, bthread_start_background(&tid, NULL, RunClosure, thrd_func));
+ EXPECT_EQ(0, bthread_start_background(&tid, nullptr, RunClosure, thrd_func));
while (echo_svc.count.load(butil::memory_order_relaxed) == old_count) {
bthread_usleep(1000);
}
@@ -1381,13 +1381,13 @@ TEST_F(ServerTest, logoff_and_multiple_start) {
ASSERT_EQ(0, server.Join());
timer.stop();
EXPECT_TRUE(labs(timer.m_elapsed() - 100) < 15) << timer.m_elapsed();
- bthread_join(tid, NULL);
+ bthread_join(tid, nullptr);
}
}
void SendMultipleRPC(butil::EndPoint ep, int count) {
brpc::Channel channel;
- EXPECT_EQ(0, channel.Init(ep, NULL));
+ EXPECT_EQ(0, channel.Init(ep, nullptr));
for (int i = 0; i < count; ++i) {
brpc::Controller cntl;
@@ -1395,7 +1395,7 @@ void SendMultipleRPC(butil::EndPoint ep, int count) {
test::EchoResponse res;
req.set_message(EXP_REQUEST);
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
EXPECT_EQ(EXP_RESPONSE, res.message()) << cntl.ErrorText();
}
@@ -1408,7 +1408,7 @@ TEST_F(ServerTest, serving_requests) {
brpc::SERVER_DOESNT_OWN_SERVICE));
butil::EndPoint ep;
ASSERT_EQ(0, str2endpoint("127.0.0.1:8613", &ep));
- ASSERT_EQ(0, server.Start(ep, NULL));
+ ASSERT_EQ(0, server.Start(ep, nullptr));
const int NUM = 1;
const int COUNT = 1;
@@ -1416,10 +1416,10 @@ TEST_F(ServerTest, serving_requests) {
for (int i = 0; i < NUM; ++i) {
google::protobuf::Closure* thrd_func =
brpc::NewCallback(SendMultipleRPC, ep, COUNT);
- EXPECT_EQ(0, pthread_create(&tids[i], NULL, RunClosure, thrd_func));
+ EXPECT_EQ(0, pthread_create(&tids[i], nullptr, RunClosure, thrd_func));
}
for (int i = 0; i < NUM; ++i) {
- pthread_join(tids[i], NULL);
+ pthread_join(tids[i], nullptr);
}
ASSERT_EQ(NUM * COUNT, echo_svc.count.load());
ASSERT_EQ(0, server.Stop(0));
@@ -1453,10 +1453,10 @@ TEST_F(ServerTest, range_start) {
}
brpc::Server server;
- EXPECT_EQ(-1, server.Start("0.0.0.0", brpc::PortRange(START_PORT, END_PORT - 1), NULL));
+ EXPECT_EQ(-1, server.Start("0.0.0.0", brpc::PortRange(START_PORT, END_PORT - 1), nullptr));
// note: add an extra port after END_PORT to detect the bug that the
// probing does not stop at the first valid port(END_PORT).
- EXPECT_EQ(0, server.Start("0.0.0.0", brpc::PortRange(START_PORT, END_PORT + 1/*note*/), NULL));
+ EXPECT_EQ(0, server.Start("0.0.0.0", brpc::PortRange(START_PORT, END_PORT + 1/*note*/), nullptr));
EXPECT_EQ(END_PORT, server.listen_address().port);
}
@@ -1496,7 +1496,7 @@ TEST_F(ServerTest, base64_to_string) {
service_opt.pb_bytes_to_base64 = (i == 0);
ASSERT_EQ(0, server.AddService(&echo_svc,
service_opt));
- ASSERT_EQ(0, server.Start(8613, NULL));
+ ASSERT_EQ(0, server.Start(8613, nullptr));
brpc::Channel chan;
brpc::ChannelOptions opt;
@@ -1511,7 +1511,7 @@ TEST_F(ServerTest, base64_to_string) {
test::BytesRequest req;
test::BytesResponse res;
req.set_databytes(EXP_REQUEST);
- chan.CallMethod(NULL, &cntl, &req, &res, NULL);
+ chan.CallMethod(nullptr, &cntl, &req, &res, nullptr);
EXPECT_FALSE(cntl.Failed());
EXPECT_EQ(EXP_REQUEST, res.databytes());
server.Stop(0);
@@ -1527,7 +1527,7 @@ TEST_F(ServerTest, single_repeated_to_array) {
service_opt.pb_single_repeated_to_array = (i == 0);
ASSERT_EQ(0, server.AddService(&echo_svc, service_opt));
- ASSERT_EQ(0, server.Start(8613, NULL));
+ ASSERT_EQ(0, server.Start(8613, nullptr));
for (int j = 0; j < 2; ++j) {
brpc::Channel chan;
@@ -1544,7 +1544,7 @@ TEST_F(ServerTest, single_repeated_to_array) {
req.add_requests()->set_message("bar");
test::ComboResponse res;
- chan.CallMethod(NULL, &cntl, &req, &res, NULL);
+ chan.CallMethod(nullptr, &cntl, &req, &res, nullptr);
if (i == j) {
EXPECT_FALSE(cntl.Failed());
EXPECT_EQ(res.responses_size(), req.requests_size());
@@ -1566,7 +1566,7 @@ TEST_F(ServerTest, too_big_message) {
brpc::Server server;
ASSERT_EQ(0, server.AddService(&echo_svc,
brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(8613, NULL));
+ ASSERT_EQ(0, server.Start(8613, nullptr));
#if !BRPC_WITH_GLOG
logging::StringSink log_str;
@@ -1574,13 +1574,13 @@ TEST_F(ServerTest, too_big_message) {
#endif
brpc::Channel chan;
- ASSERT_EQ(0, chan.Init("localhost:8613", NULL));
+ ASSERT_EQ(0, chan.Init("localhost:8613", nullptr));
brpc::Controller cntl;
test::EchoRequest req;
test::EchoResponse res;
req.mutable_message()->resize(brpc::FLAGS_max_body_size + 1);
test::EchoService_Stub stub(&chan);
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
EXPECT_TRUE(cntl.Failed());
#if !BRPC_WITH_GLOG
@@ -1606,21 +1606,21 @@ TEST_F(ServerTest, max_concurrency) {
server1.MaxConcurrencyOf(&service1, "Echo") = 2;
ASSERT_EQ(2, server1.MaxConcurrencyOf(&service1, "Echo"));
- ASSERT_EQ(0, server1.Start(port, NULL));
+ ASSERT_EQ(0, server1.Start(port, nullptr));
brpc::Channel http_channel;
brpc::ChannelOptions chan_options;
chan_options.protocol = "http";
ASSERT_EQ(0, http_channel.Init("0.0.0.0", port, &chan_options));
brpc::Channel normal_channel;
- ASSERT_EQ(0, normal_channel.Init("0.0.0.0", port, NULL));
+ ASSERT_EQ(0, normal_channel.Init("0.0.0.0", port, nullptr));
test::EchoService_Stub stub(&normal_channel);
brpc::Controller cntl1;
cntl1.http_request().uri() = "/EchoService/Echo";
cntl1.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl1.request_attachment().append("{\"message\":\"hello\",\"sleep_us\":100000}");
- http_channel.CallMethod(NULL, &cntl1, NULL, NULL, brpc::DoNothing());
+ http_channel.CallMethod(nullptr, &cntl1, nullptr, nullptr, brpc::DoNothing());
brpc::Controller cntl2;
test::EchoRequest req;
@@ -1636,14 +1636,14 @@ TEST_F(ServerTest, max_concurrency) {
cntl3.http_request().uri() = "/EchoService/Echo";
cntl3.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl3.request_attachment().append("{\"message\":\"hello\"}");
- http_channel.CallMethod(NULL, &cntl3, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl3, nullptr, nullptr, nullptr);
ASSERT_TRUE(cntl3.Failed());
ASSERT_EQ(brpc::EHTTP, cntl3.ErrorCode());
ASSERT_EQ(brpc::HTTP_STATUS_SERVICE_UNAVAILABLE, cntl3.http_response().status_code());
brpc::Controller cntl4;
req.clear_sleep_us();
- stub.Echo(&cntl4, &req, NULL, NULL);
+ stub.Echo(&cntl4, &req, nullptr, nullptr);
ASSERT_TRUE(cntl4.Failed());
ASSERT_EQ(brpc::ELIMIT, cntl4.ErrorCode());
@@ -1656,11 +1656,11 @@ TEST_F(ServerTest, max_concurrency) {
cntl3.http_request().uri() = "/EchoService/Echo";
cntl3.http_request().set_method(brpc::HTTP_METHOD_POST);
cntl3.request_attachment().append("{\"message\":\"hello\"}");
- http_channel.CallMethod(NULL, &cntl3, NULL, NULL, NULL);
+ http_channel.CallMethod(nullptr, &cntl3, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl3.Failed()) << cntl3.ErrorText();
cntl4.Reset();
- stub.Echo(&cntl4, &req, NULL, NULL);
+ stub.Echo(&cntl4, &req, nullptr, nullptr);
ASSERT_FALSE(cntl4.Failed()) << cntl4.ErrorText();
}
@@ -1669,10 +1669,10 @@ TEST_F(ServerTest, user_fields) {
brpc::Server server;
EchoServiceImpl service;
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(port, NULL));
+ ASSERT_EQ(0, server.Start(port, nullptr));
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init("0.0.0.0", port, NULL));
+ ASSERT_EQ(0, channel.Init("0.0.0.0", port, nullptr));
test::EchoService_Stub stub(&channel);
brpc::Controller cntl;
@@ -1680,13 +1680,13 @@ TEST_F(ServerTest, user_fields) {
test::EchoRequest req;
test::EchoResponse res;
req.set_message("hello");
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_TRUE(cntl.has_response_user_fields());
ASSERT_TRUE(!cntl.response_user_fields()->empty());
std::string* val = cntl.response_user_fields()->seek(EXP_USER_FIELD_KEY);
- ASSERT_TRUE(val != NULL);
+ ASSERT_TRUE(val != nullptr);
ASSERT_EQ(*val, EXP_USER_FIELD_VALUE);
}
@@ -1754,7 +1754,7 @@ void TestBaiduMasterService(brpc::Channel& channel, brpc::CompressType compress_
cntl.request_attachment().append(EXP_REQUEST);
cntl.set_request_compress_type(compress_type);
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(EXP_RESPONSE, res.message());
ASSERT_EQ(EXP_RESPONSE, cntl.response_attachment().to_string());
@@ -1816,7 +1816,7 @@ void TestGenericCall(brpc::Channel& channel, brpc::ContentType content_type,
test::EchoService::descriptor()->FindMethodByName("Echo")->name());
cntl.reset_sampled_request(sampled_request);
- channel.CallMethod(NULL, &cntl, &serialized_request, &serialized_response, NULL);
+ channel.CallMethod(nullptr, &cntl, &serialized_request, &serialized_response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_TRUE(brpc::policy::DeserializeRpcMessage(
@@ -1883,7 +1883,7 @@ TEST_F(ServerTest, generic_call) {
}
struct DefaultRpcPBMessages : public brpc::RpcPBMessages {
- DefaultRpcPBMessages() : request(NULL), response(NULL) {}
+ DefaultRpcPBMessages() : request(nullptr), response(nullptr) {}
::google::protobuf::Message* Request() override { return request; }
::google::protobuf::Message* Response() override { return response; }
@@ -1909,8 +1909,8 @@ public:
auto test_messages = static_cast<DefaultRpcPBMessages*>(messages);
butil::return_object(static_cast<v1::EchoRequest*>(test_messages->request));
butil::return_object(static_cast<v1::EchoResponse*>(test_messages->response));
- test_messages->request = NULL;
- test_messages->response = NULL;
+ test_messages->request = nullptr;
+ test_messages->response = nullptr;
butil::return_object(test_messages);
}
};
@@ -1935,7 +1935,7 @@ TEST_F(ServerTest, rpc_pb_message_factory) {
v1::EchoResponse res;
req.set_message(EXP_REQUEST);
v1::EchoService_Stub stub(&baidu_chan);
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(EXP_REQUEST + "_v1", res.message());
}
@@ -1949,7 +1949,7 @@ TEST_F(ServerTest, rpc_pb_message_factory) {
cntl.request_attachment().append(
butil::string_printf(R"({"message":"%s"})", EXP_REQUEST.c_str()));
v1::EchoService_Stub stub(&http_chan);
- stub.Echo(&cntl, NULL, NULL, NULL);
+ stub.Echo(&cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(butil::string_printf(R"({"message":"%s_v1"})", EXP_REQUEST.c_str()),
cntl.response_attachment().to_string());
@@ -1979,7 +1979,7 @@ TEST_F(ServerTest, arena_rpc_pb_message_factory) {
v3::EchoResponse res;
req.set_message(EXP_REQUEST);
v3::EchoService_Stub stub(&baidu_chan);
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(EXP_RESPONSE, res.message());
}
@@ -1993,7 +1993,7 @@ TEST_F(ServerTest, arena_rpc_pb_message_factory) {
cntl.request_attachment().append(
butil::string_printf(R"({"message":"%s"})", EXP_REQUEST.c_str()));
v3::EchoService_Stub stub(&http_chan);
- stub.Echo(&cntl, NULL, NULL, NULL);
+ stub.Echo(&cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(butil::string_printf(R"({"message":"%s"})", EXP_RESPONSE.c_str()),
cntl.response_attachment().to_string());
@@ -2016,7 +2016,7 @@ void TestBaiduStdAuth(const butil::EndPoint& ep,
test::EchoResponse res;
req.set_message(EXP_REQUEST);
test::EchoService_Stub stub(&chan);
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
ASSERT_EQ(cntl.Failed(), failed) << cntl.ErrorText();
ASSERT_EQ(cntl.ErrorCode(), error_code);
}
@@ -2034,7 +2034,7 @@ void TestHttpAuth(const butil::EndPoint& ep,
cntl.request_attachment().append(R"({"message": "hello"})");
cntl.http_request().set_method(brpc::HTTP_METHOD_POST);
test::EchoService_Stub stub(&chan);
- chan.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ chan.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_EQ(cntl.Failed(), failed) << cntl.ErrorText();
ASSERT_EQ(cntl.http_response().status_code(), status_code);
}
@@ -2084,7 +2084,7 @@ void TestClientHost(const butil::EndPoint& ep,
test::EchoResponse res;
req.set_message(EXP_REQUEST);
test::EchoService_Stub stub(&chan);
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
ASSERT_EQ(cntl.Failed(), failed) << cntl.ErrorText();
ASSERT_EQ(cntl.ErrorCode(), error_code);
}
diff --git a/test/brpc_socket_map_unittest.cpp b/test/brpc_socket_map_unittest.cpp
index d40db0e7..c946c7d1 100644
--- a/test/brpc_socket_map_unittest.cpp
+++ b/test/brpc_socket_map_unittest.cpp
@@ -49,7 +49,7 @@ void* worker(void*) {
}
}
}
- return NULL;
+ return nullptr;
}
class SocketMapTest : public ::testing::Test{
@@ -91,10 +91,10 @@ TEST_F(SocketMapTest, idle_timeout) {
brpc::FLAGS_defer_close_second = TIMEOUT;
pthread_t tids[NTHREAD];
for (int i = 0; i < NTHREAD; ++i) {
- ASSERT_EQ(0, pthread_create(&tids[i], NULL, worker, NULL));
+ ASSERT_EQ(0, pthread_create(&tids[i], nullptr, worker, nullptr));
}
for (int i = 0; i < NTHREAD; ++i) {
- ASSERT_EQ(0, pthread_join(tids[i], NULL));
+ ASSERT_EQ(0, pthread_join(tids[i], nullptr));
}
brpc::SocketId id;
// Socket still exists since it has not reached timeout yet
@@ -124,7 +124,7 @@ TEST_F(SocketMapTest, idle_timeout) {
main_ptr.reset();
id = ptr->id();
ptr->ReturnToPool();
- ptr.reset(NULL);
+ ptr.reset(nullptr);
usleep(TIMEOUT * 1000000L + 2000000L);
// Pooled connection should be `ReleaseAdditionalReference',
// which destroyed the Socket. As a result `GetSocketFromPool'
diff --git a/test/brpc_socket_unittest.cpp b/test/brpc_socket_unittest.cpp
index d032bd61..2da9adf3 100644
--- a/test/brpc_socket_unittest.cpp
+++ b/test/brpc_socket_unittest.cpp
@@ -75,7 +75,7 @@ int main(int argc, char* argv[]) {
brpc::SerializeRequestDefault,
brpc::policy::PackHuluRequest,
EchoProcessHuluRequest, EchoProcessHuluRequest,
- NULL, NULL, NULL,
+ nullptr, nullptr, nullptr,
brpc::CONNECTION_TYPE_ALL, "dummy_hulu" };
EXPECT_EQ(0, RegisterProtocol((brpc::ProtocolType)30, dummy_protocol));
return RUN_ALL_TESTS();
@@ -107,13 +107,13 @@ protected:
};
};
-brpc::Socket* global_sock = NULL;
+brpc::Socket* global_sock = nullptr;
class CheckRecycle : public brpc::SocketUser {
void BeforeRecycle(brpc::Socket* s) {
ASSERT_TRUE(global_sock);
ASSERT_EQ(global_sock, s);
- global_sock = NULL;
+ global_sock = nullptr;
delete this;
}
};
@@ -141,7 +141,7 @@ TEST_F(SocketTest, not_recycle_until_zero_nref) {
ASSERT_EQ(0, s->SetFailed());
ASSERT_EQ(s.get(), global_sock);
}
- ASSERT_EQ((brpc::Socket*)NULL, global_sock);
+ ASSERT_EQ((brpc::Socket*)nullptr, global_sock);
close(fds[0]);
brpc::SocketUniquePtr ptr;
@@ -161,7 +161,7 @@ void* auth_fighter(void* arg) {
} else {
EXPECT_EQ(AUTH_ERR, auth_error);
}
- return NULL;
+ return nullptr;
}
TEST_F(SocketTest, authentication) {
@@ -173,10 +173,10 @@ TEST_F(SocketTest, authentication) {
bthread_t th[64];
for (size_t i = 0; i < ARRAY_SIZE(th); ++i) {
- ASSERT_EQ(0, bthread_start_urgent(&th[i], NULL, auth_fighter, s.get()));
+ ASSERT_EQ(0, bthread_start_urgent(&th[i], nullptr, auth_fighter, s.get()));
}
for (size_t i = 0; i < ARRAY_SIZE(th); ++i) {
- ASSERT_EQ(0, bthread_join(th[i], NULL));
+ ASSERT_EQ(0, bthread_join(th[i], nullptr));
}
// Only one fighter wins
ASSERT_EQ(1, winner_count.load());
@@ -186,13 +186,13 @@ TEST_F(SocketTest, authentication) {
ASSERT_NE(0, s->FightAuthentication(&auth_error));
ASSERT_EQ(AUTH_ERR, auth_error);
// Socket has been `SetFailed' when authentication failed
- ASSERT_TRUE(brpc::Socket::Address(s->id(), NULL));
+ ASSERT_TRUE(brpc::Socket::Address(s->id(), nullptr));
}
static butil::atomic<int> g_called_seq(1);
class MyMessage : public brpc::SocketMessage {
public:
- MyMessage(const char* str, size_t len, int* called = NULL)
+ MyMessage(const char* str, size_t len, int* called = nullptr)
: _str(str), _len(len), _called(called) {}
private:
butil::Status AppendAndDestroySelf(butil::IOBuf* out_buf, brpc::Socket*) {
@@ -295,7 +295,7 @@ TEST_F(SocketTest, single_threaded_write) {
}
ASSERT_EQ(0, s->SetFailed());
}
- ASSERT_EQ((brpc::Socket*)NULL, global_sock);
+ ASSERT_EQ((brpc::Socket*)nullptr, global_sock);
close(fds[0]);
}
@@ -310,7 +310,7 @@ void EchoProcessHuluRequest(brpc::InputMessageBase* msg_base) {
class MyConnect : public brpc::AppConnect {
public:
- MyConnect() : _done(NULL), _data(NULL), _called_start_connect(false) {}
+ MyConnect() : _done(nullptr), _data(nullptr), _called_start_connect(false) {}
void StartConnect(const brpc::Socket*,
void (*done)(int err, void* data),
void* data) {
@@ -339,7 +339,7 @@ TEST_F(SocketTest, single_threaded_connect_and_write) {
ANNOTATE_LEAKING_OBJECT_PTR(messenger);
const brpc::InputMessageHandler pairs[] = {
{ brpc::policy::ParseHuluMessage,
- EchoProcessHuluRequest, NULL, NULL, "dummy_hulu" }
+ EchoProcessHuluRequest, nullptr, nullptr, "dummy_hulu" }
};
int listening_fd = -1;
@@ -354,7 +354,7 @@ TEST_F(SocketTest, single_threaded_connect_and_write) {
ASSERT_GT(listening_fd, 0) << berror();
ASSERT_EQ(0, butil::make_non_blocking(listening_fd));
ASSERT_EQ(0, messenger->AddHandler(pairs[0]));
- ASSERT_EQ(0, messenger->StartAccept(listening_fd, -1, NULL, false));
+ ASSERT_EQ(0, messenger->StartAccept(listening_fd, -1, nullptr, false));
brpc::SocketId id = 8888;
brpc::SocketOptions options;
@@ -422,7 +422,7 @@ TEST_F(SocketTest, single_threaded_connect_and_write) {
}
ASSERT_EQ(0, s->SetFailed());
}
- ASSERT_EQ((brpc::Socket*)NULL, global_sock);
+ ASSERT_EQ((brpc::Socket*)nullptr, global_sock);
// The id is invalid.
brpc::SocketUniquePtr ptr;
ASSERT_EQ(-1, brpc::Socket::Address(id, &ptr));
@@ -457,12 +457,12 @@ void* FailedWriter(void* void_arg) {
brpc::SocketUniquePtr sock;
if (brpc::Socket::Address(arg->socket_id, &sock) < 0) {
printf("Fail to address SocketId=%" PRIu64 "\n", arg->socket_id);
- return NULL;
+ return nullptr;
}
char buf[32];
for (size_t i = 0; i < arg->times; ++i) {
bthread_id_t id;
- EXPECT_EQ(0, bthread_id_create(&id, NULL, NULL));
+ EXPECT_EQ(0, bthread_id_create(&id, nullptr, nullptr));
snprintf(buf, sizeof(buf), "%0" BAIDU_SYMBOLSTR(NUMBER_WIDTH) "lu",
i + arg->offset);
butil::IOBuf src;
@@ -475,7 +475,7 @@ void* FailedWriter(void* void_arg) {
// calls `SetFailed' making others' error_code=EINVAL
//EXPECT_EQ(ECONNREFUSED, error_code);
}
- return NULL;
+ return nullptr;
}
TEST_F(SocketTest, fail_to_connect) {
@@ -500,17 +500,17 @@ TEST_F(SocketTest, fail_to_connect) {
args[i].times = REP;
args[i].offset = i * REP;
args[i].socket_id = id;
- ASSERT_EQ(0, pthread_create(&th[i], NULL, FailedWriter, &args[i]));
+ ASSERT_EQ(0, pthread_create(&th[i], nullptr, FailedWriter, &args[i]));
}
for (size_t i = 0; i < ARRAY_SIZE(th); ++i) {
- ASSERT_EQ(0, pthread_join(th[i], NULL));
+ ASSERT_EQ(0, pthread_join(th[i], nullptr));
}
ASSERT_EQ(-1, s->SetFailed()); // already SetFailed
ASSERT_EQ(-1, s->fd());
}
// KeepWrite is possibly still running.
int64_t start_time = butil::cpuwide_time_us();
- while (global_sock != NULL) {
+ while (global_sock != nullptr) {
bthread_usleep(1000);
ASSERT_LT(butil::cpuwide_time_us(), start_time + 1000000L) << "Too long!";
}
@@ -571,11 +571,11 @@ TEST_F(SocketTest, not_health_check_when_nref_hits_0) {
s->ReleaseHCRelatedReference();
}
// StartHealthCheck is possibly still running. Spin until global_sock
- // is NULL(set in CheckRecycle::BeforeRecycle). Notice that you should
+ // is nullptr(set in CheckRecycle::BeforeRecycle). Notice that you should
// not spin until Socket::Status(id) becomes -1 and assert global_sock
- // to be NULL because invalidating id happens before calling BeforeRecycle.
+ // to be nullptr because invalidating id happens before calling BeforeRecycle.
const int64_t start_time = butil::cpuwide_time_us();
- while (global_sock != NULL) {
+ while (global_sock != nullptr) {
bthread_usleep(1000);
ASSERT_LT(butil::cpuwide_time_us(), start_time + 1000000L);
}
@@ -618,7 +618,7 @@ TEST_F(SocketTest, app_level_health_check) {
{
brpc::Controller cntl;
cntl.http_request().uri() = "/";
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
EXPECT_TRUE(cntl.Failed());
ASSERT_EQ(ECONNREFUSED, cntl.ErrorCode());
}
@@ -637,14 +637,14 @@ TEST_F(SocketTest, app_level_health_check) {
brpc::Server server;
HealthCheckTestServiceImpl hc_service;
ASSERT_EQ(0, server.AddService(&hc_service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(point, NULL));
+ ASSERT_EQ(0, server.Start(point, nullptr));
for (int i = 0; i < 4; ++i) {
// although ::connect would succeed, the stall in hc_service makes
// the health check rpc fail.
brpc::Controller cntl;
cntl.http_request().uri() = "/";
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_EQ(EHOSTDOWN, cntl.ErrorCode());
bthread_usleep(1000000 /*1s*/);
}
@@ -654,7 +654,7 @@ TEST_F(SocketTest, app_level_health_check) {
{
brpc::Controller cntl;
cntl.http_request().uri() = "/";
- channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
+ channel.CallMethod(nullptr, &cntl, nullptr, nullptr, nullptr);
ASSERT_FALSE(cntl.Failed());
ASSERT_GT(cntl.response_attachment().size(), (size_t)0);
}
@@ -679,7 +679,7 @@ TEST_F(SocketTest, health_check) {
options.user = new CheckRecycle;
options.health_check_interval_s = kCheckInteval/*s*/;
ASSERT_EQ(0, brpc::Socket::Create(options, &id));
- brpc::Socket* s = NULL;
+ brpc::Socket* s = nullptr;
{
brpc::SocketUniquePtr ptr;
ASSERT_EQ(0, brpc::Socket::Address(id, &ptr));
@@ -751,14 +751,14 @@ TEST_F(SocketTest, health_check) {
const brpc::InputMessageHandler pairs[] = {
{ brpc::policy::ParseHuluMessage,
- EchoProcessHuluRequest, NULL, NULL, "dummy_hulu" }
+ EchoProcessHuluRequest, nullptr, nullptr, "dummy_hulu" }
};
int listening_fd = tcp_listen(point);
ASSERT_TRUE(listening_fd > 0);
butil::make_non_blocking(listening_fd);
ASSERT_EQ(0, messenger->AddHandler(pairs[0]));
- ASSERT_EQ(0, messenger->StartAccept(listening_fd, -1, NULL, false));
+ ASSERT_EQ(0, messenger->StartAccept(listening_fd, -1, nullptr, false));
int64_t start_time = butil::cpuwide_time_us();
nref = -1;
@@ -807,7 +807,7 @@ TEST_F(SocketTest, health_check) {
ASSERT_EQ(0, brpc::Socket::SetFailed(id));
// StartHealthCheck is possibly still addressing the Socket.
start_time = butil::cpuwide_time_us();
- while (global_sock != NULL) {
+ while (global_sock != nullptr) {
bthread_usleep(1000);
ASSERT_LT(butil::cpuwide_time_us(), start_time + 1000000L);
}
@@ -823,7 +823,7 @@ void* Writer(void* void_arg) {
brpc::SocketUniquePtr sock;
if (brpc::Socket::Address(arg->socket_id, &sock) < 0) {
printf("Fail to address SocketId=%" PRIu64 "\n", arg->socket_id);
- return NULL;
+ return nullptr;
}
char buf[32];
for (size_t i = 0; i < arg->times; ++i) {
@@ -843,7 +843,7 @@ void* Writer(void* void_arg) {
break;
}
}
- return NULL;
+ return nullptr;
}
TEST_F(SocketTest, multi_threaded_write) {
@@ -879,7 +879,7 @@ TEST_F(SocketTest, multi_threaded_write) {
args[i].times = REP;
args[i].offset = i * REP;
args[i].socket_id = id;
- ASSERT_EQ(0, pthread_create(&th[i], NULL, Writer, &args[i]));
+ ASSERT_EQ(0, pthread_create(&th[i], nullptr, Writer, &args[i]));
}
if (k == 1) {
@@ -909,7 +909,7 @@ TEST_F(SocketTest, multi_threaded_write) {
char buf[NUMBER_WIDTH + 1];
dest.copy_to(buf, NUMBER_WIDTH);
buf[sizeof(buf)-1] = 0;
- result.push_back(strtol(buf, NULL, 10));
+ result.push_back(strtol(buf, nullptr, 10));
dest.pop_front(NUMBER_WIDTH);
}
if (result.size() >= REP * ARRAY_SIZE(th)) {
@@ -917,7 +917,7 @@ TEST_F(SocketTest, multi_threaded_write) {
}
}
for (size_t i = 0; i < ARRAY_SIZE(th); ++i) {
- ASSERT_EQ(0, pthread_join(th[i], NULL));
+ ASSERT_EQ(0, pthread_join(th[i], nullptr));
}
ASSERT_TRUE(dest.empty());
bthread::g_task_control->print_rq_sizes(std::cout);
@@ -934,7 +934,7 @@ TEST_F(SocketTest, multi_threaded_write) {
ASSERT_EQ(0, s->SetFailed());
s.release()->Dereference();
- ASSERT_EQ((brpc::Socket*)NULL, global_sock);
+ ASSERT_EQ((brpc::Socket*)nullptr, global_sock);
close(fds[0]);
}
}
@@ -944,7 +944,7 @@ void* FastWriter(void* void_arg) {
brpc::SocketUniquePtr sock;
if (brpc::Socket::Address(arg->socket_id, &sock) < 0) {
printf("Fail to address SocketId=%" PRIu64 "\n", arg->socket_id);
- return NULL;
+ return nullptr;
}
char buf[] = "hello reader side!";
int64_t begin_ts = butil::cpuwide_time_us();
@@ -970,7 +970,7 @@ void* FastWriter(void* void_arg) {
int64_t total_time = end_ts - begin_ts;
printf("total=%ld count=%ld nretry=%ld\n",
(long)total_time * 1000/ c, (long)c, (long)nretry);
- return NULL;
+ return nullptr;
}
struct ReaderArg {
@@ -994,7 +994,7 @@ void* reader(void* void_arg) {
arg->nread += nr;
}
free(buf);
- return NULL;
+ return nullptr;
}
TEST_F(SocketTest, multi_threaded_write_perf) {
@@ -1026,12 +1026,12 @@ TEST_F(SocketTest, multi_threaded_write_perf) {
args[i].times = REP;
args[i].offset = i * REP;
args[i].socket_id = id;
- bthread_start_background(&th[i], NULL, FastWriter, &args[i]);
+ bthread_start_background(&th[i], nullptr, FastWriter, &args[i]);
}
pthread_t rth;
ReaderArg reader_arg = { fds[0], 0 };
- pthread_create(&rth, NULL, reader, &reader_arg);
+ pthread_create(&rth, nullptr, reader, &reader_arg);
butil::Timer tm;
ProfilerStart("write.prof");
@@ -1048,12 +1048,12 @@ TEST_F(SocketTest, multi_threaded_write_perf) {
args[i].times = 0;
}
for (size_t i = 0; i < ARRAY_SIZE(th); ++i) {
- ASSERT_EQ(0, bthread_join(th[i], NULL));
+ ASSERT_EQ(0, bthread_join(th[i], nullptr));
}
ASSERT_EQ(0, s->SetFailed());
s.release()->Dereference();
- pthread_join(rth, NULL);
- ASSERT_EQ((brpc::Socket*)NULL, global_sock);
+ pthread_join(rth, nullptr);
+ ASSERT_EQ((brpc::Socket*)nullptr, global_sock);
close(fds[0]);
}
@@ -1297,7 +1297,7 @@ TEST_F(SocketTest, keepalive_input_message) {
}
ASSERT_GT(listening_fd, 0) << berror();
ASSERT_EQ(0, butil::make_non_blocking(listening_fd));
- ASSERT_EQ(0, messenger->StartAccept(listening_fd, -1, NULL, false));
+ ASSERT_EQ(0, messenger->StartAccept(listening_fd, -1, nullptr, false));
int default_keepalive = 0;
int default_keepalive_idle = 0;
@@ -1491,7 +1491,7 @@ TEST_F(SocketTest, socket_buffer_options_before_connect) {
ASSERT_EQ(0, brpc::Socket::Address(id, &ptr)) << "id=" << id;
const timespec duetime = butil::milliseconds_from_now(1000);
- butil::fd_guard connected_fd(ptr->Connect(&duetime, NULL, NULL));
+ butil::fd_guard connected_fd(ptr->Connect(&duetime, nullptr, nullptr));
ASSERT_GT(connected_fd, 0);
CheckSocketBufferValues(connected_fd, expected);
@@ -1510,12 +1510,12 @@ TEST_F(SocketTest, socket_buffer_options_before_accept) {
butil::EndPoint point;
ASSERT_EQ(0, str2endpoint("127.0.0.1:0", &point));
brpc::Server server;
- ASSERT_EQ(0, server.Start(point, NULL));
+ ASSERT_EQ(0, server.Start(point, nullptr));
point = server.listen_address();
brpc::Acceptor* messenger =
brpc::ServerPrivateAccessor(&server).acceptor();
- ASSERT_TRUE(messenger != NULL);
+ ASSERT_TRUE(messenger != nullptr);
ASSERT_GT(messenger->listened_fd(), 0);
CheckSocketBufferValues(messenger->listened_fd(), expected);
@@ -1581,7 +1581,7 @@ TEST_F(SocketTest, tcp_user_timeout) {
}
ASSERT_GT(listening_fd, 0) << berror();
ASSERT_EQ(0, butil::make_non_blocking(listening_fd));
- ASSERT_EQ(0, messenger->StartAccept(listening_fd, -1, NULL, false));
+ ASSERT_EQ(0, messenger->StartAccept(listening_fd, -1, nullptr, false));
{
brpc::SocketOptions options;
@@ -1678,7 +1678,7 @@ TEST_F(SocketTest, notify_on_success) {
pthread_t rth;
ReaderArg reader_arg = { fds[0], 0 };
- pthread_create(&rth, NULL, reader, &reader_arg);
+ pthread_create(&rth, nullptr, reader, &reader_arg);
size_t success_count = 0;
char buf[] = "hello reader side!";
@@ -1706,9 +1706,9 @@ TEST_F(SocketTest, notify_on_success) {
ASSERT_EQ(0, s->SetFailed());
s.release()->Dereference();
- pthread_join(rth, NULL);
+ pthread_join(rth, nullptr);
ASSERT_EQ(REP, success_count);
- ASSERT_EQ((brpc::Socket*)NULL, global_sock);
+ ASSERT_EQ((brpc::Socket*)nullptr, global_sock);
close(fds[0]);
}
@@ -1737,7 +1737,7 @@ void* ShutdownWriter(void* void_arg) {
brpc::SocketUniquePtr sock;
if (brpc::Socket::Address(arg->socket_id, &sock) < 0) {
LOG(INFO) << "Fail to address SocketId=" << arg->socket_id;
- return NULL;
+ return nullptr;
}
for (size_t c = 0; c < arg->times; ++c) {
bthread_id_t write_id;
@@ -1758,7 +1758,7 @@ void* ShutdownWriter(void* void_arg) {
}
}
}
- return NULL;
+ return nullptr;
}
void TestShutdownWrite() {
@@ -1787,7 +1787,7 @@ void TestShutdownWrite() {
pthread_t rth;
ReaderArg reader_arg = { fds[0], 0 };
- pthread_create(&rth, NULL, reader, &reader_arg);
+ pthread_create(&rth, nullptr, reader, &reader_arg);
bthread_t th[3];
ShutdownWriterArg args[ARRAY_SIZE(th)];
@@ -1796,11 +1796,11 @@ void TestShutdownWrite() {
args[i].socket_id = id;
args[i].total_count = 0;
args[i].success_count = 0;
- bthread_start_background(&th[i], NULL, ShutdownWriter, &args[i]);
+ bthread_start_background(&th[i], nullptr, ShutdownWriter, &args[i]);
}
for (size_t i = 0; i < ARRAY_SIZE(th); ++i) {
- ASSERT_EQ(0, bthread_join(th[i], NULL));
+ ASSERT_EQ(0, bthread_join(th[i], nullptr));
}
bthread_usleep(50 * 1000);
@@ -1808,8 +1808,8 @@ void TestShutdownWrite() {
ASSERT_FALSE(s->Failed());
ASSERT_EQ(0, s->SetFailed());
s.release()->Dereference();
- pthread_join(rth, NULL);
- ASSERT_EQ((brpc::Socket*)NULL, global_sock);
+ pthread_join(rth, nullptr);
+ ASSERT_EQ((brpc::Socket*)nullptr, global_sock);
close(fds[0]);
size_t total_count = 0;
diff --git a/test/brpc_sofa_pbrpc_protocol_unittest.cpp b/test/brpc_sofa_pbrpc_protocol_unittest.cpp
index 3996de0e..5a44e89c 100644
--- a/test/brpc_sofa_pbrpc_protocol_unittest.cpp
+++ b/test/brpc_sofa_pbrpc_protocol_unittest.cpp
@@ -109,7 +109,7 @@ protected:
virtual void TearDown() {};
void VerifyMessage(brpc::InputMessageBase* msg) {
- if (msg->_socket == NULL) {
+ if (msg->_socket == nullptr) {
_socket->ReAddress(&msg->_socket);
}
msg->_arg = &_server;
@@ -118,7 +118,7 @@ protected:
void ProcessMessage(void (*process)(brpc::InputMessageBase*),
brpc::InputMessageBase* msg, bool set_eof) {
- if (msg->_socket == NULL) {
+ if (msg->_socket == nullptr) {
_socket->ReAddress(&msg->_socket);
}
msg->_arg = &_server;
@@ -169,7 +169,7 @@ protected:
butil::IOPortal buf;
EXPECT_EQ((ssize_t)bytes_in_pipe,
buf.append_from_file_descriptor(_pipe_fds[0], 1024));
- brpc::ParseResult pr = brpc::policy::ParseSofaMessage(&buf, NULL, false, NULL);
+ brpc::ParseResult pr = brpc::policy::ParseSofaMessage(&buf, nullptr, false, nullptr);
EXPECT_EQ(brpc::PARSE_OK, pr.error());
brpc::policy::MostCommonMessage* msg =
static_cast<brpc::policy::MostCommonMessage*>(pr.message());
@@ -193,13 +193,13 @@ protected:
brpc::SerializeRequestDefault(&request_buf, &cntl, &req);
ASSERT_FALSE(cntl.Failed());
brpc::policy::PackSofaRequest(
- &total_buf, NULL, cntl.call_id().value,
+ &total_buf, nullptr, cntl.call_id().value,
test::EchoService::descriptor()->method(0),
&cntl, request_buf, &_auth);
ASSERT_FALSE(cntl.Failed());
brpc::ParseResult req_pr =
- brpc::policy::ParseSofaMessage(&total_buf, NULL, false, NULL);
+ brpc::policy::ParseSofaMessage(&total_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, req_pr.error());
brpc::InputMessageBase* req_msg = req_pr.message();
ProcessMessage(brpc::policy::ProcessSofaRequest, req_msg, false);
@@ -307,13 +307,13 @@ TEST_F(SofaTest, complete_flow) {
brpc::SerializeRequestDefault(&request_buf, &cntl, &req);
ASSERT_FALSE(cntl.Failed());
brpc::policy::PackSofaRequest(
- &total_buf, NULL, cntl.call_id().value,
+ &total_buf, nullptr, cntl.call_id().value,
test::EchoService::descriptor()->method(0), &cntl, request_buf, &_auth);
ASSERT_FALSE(cntl.Failed());
// Verify and handle request
brpc::ParseResult req_pr =
- brpc::policy::ParseSofaMessage(&total_buf, NULL, false, NULL);
+ brpc::policy::ParseSofaMessage(&total_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, req_pr.error());
brpc::InputMessageBase* req_msg = req_pr.message();
VerifyMessage(req_msg);
@@ -323,7 +323,7 @@ TEST_F(SofaTest, complete_flow) {
butil::IOPortal response_buf;
response_buf.append_from_file_descriptor(_pipe_fds[0], 1024);
brpc::ParseResult res_pr =
- brpc::policy::ParseSofaMessage(&response_buf, NULL, false, NULL);
+ brpc::policy::ParseSofaMessage(&response_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, res_pr.error());
brpc::InputMessageBase* res_msg = res_pr.message();
ProcessMessage(brpc::policy::ProcessSofaResponse, res_msg, false);
@@ -344,13 +344,13 @@ TEST_F(SofaTest, close_in_callback) {
brpc::SerializeRequestDefault(&request_buf, &cntl, &req);
ASSERT_FALSE(cntl.Failed());
brpc::policy::PackSofaRequest(
- &total_buf, NULL, cntl.call_id().value,
+ &total_buf, nullptr, cntl.call_id().value,
test::EchoService::descriptor()->method(0), &cntl, request_buf, &_auth);
ASSERT_FALSE(cntl.Failed());
// Handle request
brpc::ParseResult req_pr =
- brpc::policy::ParseSofaMessage(&total_buf, NULL, false, NULL);
+ brpc::policy::ParseSofaMessage(&total_buf, nullptr, false, nullptr);
ASSERT_EQ(brpc::PARSE_OK, req_pr.error());
brpc::InputMessageBase* req_msg = req_pr.message();
ProcessMessage(brpc::policy::ProcessSofaRequest, req_msg, false);
@@ -372,7 +372,7 @@ TEST_F(SofaTest, reject_oversized_body) {
butil::IOBuf buf;
AppendSofaTestHeader(&buf, 0, body_size, body_size);
brpc::ParseResult pr =
- brpc::policy::ParseSofaMessage(&buf, _socket.get(), false, NULL);
+ brpc::policy::ParseSofaMessage(&buf, _socket.get(), false, nullptr);
ASSERT_EQ(brpc::PARSE_ERROR_TOO_BIG_DATA, pr.error());
}
@@ -383,7 +383,7 @@ TEST_F(SofaTest, reject_oversized_meta) {
butil::IOBuf buf;
AppendSofaTestHeader(&buf, meta_size, 0, meta_size);
brpc::ParseResult pr =
- brpc::policy::ParseSofaMessage(&buf, _socket.get(), false, NULL);
+ brpc::policy::ParseSofaMessage(&buf, _socket.get(), false, nullptr);
ASSERT_EQ(brpc::PARSE_ERROR_TOO_BIG_DATA, pr.error());
}
} //namespace
diff --git a/test/brpc_ssl_unittest.cpp b/test/brpc_ssl_unittest.cpp
index a6f7affc..6825709e 100644
--- a/test/brpc_ssl_unittest.cpp
+++ b/test/brpc_ssl_unittest.cpp
@@ -91,7 +91,7 @@ protected:
void* RunClosure(void* arg) {
google::protobuf::Closure* done = (google::protobuf::Closure*)arg;
done->Run();
- return NULL;
+ return nullptr;
}
void SendMultipleRPC(brpc::Channel* channel, int count) {
@@ -101,7 +101,7 @@ void SendMultipleRPC(brpc::Channel* channel, int count) {
test::EchoResponse res;
req.set_message(EXP_REQUEST);
test::EchoService_Stub stub(channel);
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
EXPECT_EQ(EXP_RESPONSE, res.message()) << cntl.ErrorText();
}
@@ -135,7 +135,7 @@ TEST_F(SSLTest, sanity) {
brpc::Controller cntl;
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
EXPECT_EQ(EXP_RESPONSE, res.message()) << cntl.ErrorText();
}
@@ -152,10 +152,10 @@ TEST_F(SSLTest, sanity) {
for (int i = 0; i < NUM; ++i) {
google::protobuf::Closure* thrd_func =
brpc::NewCallback(SendMultipleRPC, &channel, COUNT);
- EXPECT_EQ(0, pthread_create(&tids[i], NULL, RunClosure, thrd_func));
+ EXPECT_EQ(0, pthread_create(&tids[i], nullptr, RunClosure, thrd_func));
}
for (int i = 0; i < NUM; ++i) {
- pthread_join(tids[i], NULL);
+ pthread_join(tids[i], nullptr);
}
}
{
@@ -169,10 +169,10 @@ TEST_F(SSLTest, sanity) {
for (int i = 0; i < NUM; ++i) {
google::protobuf::Closure* thrd_func =
brpc::NewCallback(SendMultipleRPC, &channel, COUNT);
- EXPECT_EQ(0, pthread_create(&tids[i], NULL, RunClosure, thrd_func));
+ EXPECT_EQ(0, pthread_create(&tids[i], nullptr, RunClosure, thrd_func));
}
for (int i = 0; i < NUM; ++i) {
- pthread_join(tids[i], NULL);
+ pthread_join(tids[i], nullptr);
}
}
@@ -210,18 +210,18 @@ TEST_F(SSLTest, force_ssl) {
brpc::Controller cntl;
test::EchoService_Stub stub(&channel);
test::EchoResponse res;
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
ASSERT_EQ(EXP_RESPONSE, res.message()) << cntl.ErrorText();
}
{
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init("localhost", port, NULL));
+ ASSERT_EQ(0, channel.Init("localhost", port, nullptr));
brpc::Controller cntl;
test::EchoService_Stub stub(&channel);
test::EchoResponse res;
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
ASSERT_TRUE(cntl.Failed());
}
@@ -239,7 +239,7 @@ void CallServerWithExpectedPeerName(int port, const char* server_address,
brpc::VerifyMode::VERIFY_PEER;
options.mutable_ssl_options()->verify.verify_depth = 1;
options.mutable_ssl_options()->verify.ca_file_path = "cert1.crt";
- if (expected_peer_name != NULL) {
+ if (expected_peer_name != nullptr) {
options.mutable_ssl_options()->verify.expected_peer_name = expected_peer_name;
}
std::string url = server_address;
@@ -251,7 +251,7 @@ void CallServerWithExpectedPeerName(int port, const char* server_address,
req.set_message(EXP_REQUEST);
brpc::Controller cntl;
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &req, &res, NULL);
+ stub.Echo(&cntl, &req, &res, nullptr);
if (expect_success) {
EXPECT_FALSE(cntl.Failed()) << cntl.ErrorText();
EXPECT_EQ(EXP_RESPONSE, res.message());
@@ -274,8 +274,8 @@ TEST_F(SSLTest, verify_peer_name) {
&echo_svc, brpc::SERVER_DOESNT_OWN_SERVICE));
ASSERT_EQ(0, server.Start(port, &server_options));
- CallServerWithExpectedPeerName(port, "https://localhost", NULL, true);
- CallServerWithExpectedPeerName(port, "https://127.0.0.1", NULL, false);
+ CallServerWithExpectedPeerName(port, "https://localhost", nullptr, true);
+ CallServerWithExpectedPeerName(port, "https://127.0.0.1", nullptr, false);
CallServerWithExpectedPeerName(
port, "https://localhost", "wrong.local", false);
@@ -286,11 +286,11 @@ TEST_F(SSLTest, verify_peer_name) {
TEST_F(SSLTest, expected_peer_name_requires_peer_verification) {
brpc::ChannelSSLOptions options;
options.verify.expected_peer_name = "localhost";
- EXPECT_EQ(NULL, brpc::CreateClientSSLContext(options));
+ EXPECT_EQ(nullptr, brpc::CreateClientSSLContext(options));
options.verify.verify_depth = 1;
options.verify.verify_mode = brpc::VerifyMode::VERIFY_NONE;
- EXPECT_EQ(NULL, brpc::CreateClientSSLContext(options));
+ EXPECT_EQ(nullptr, brpc::CreateClientSSLContext(options));
}
TEST_F(SSLTest, peer_name_verification_capability) {
@@ -311,7 +311,7 @@ void ProcessResponse(brpc::InputMessageBase* msg_base) {
ASSERT_EQ(0, response_meta.error_code()) << response_meta.error_text();
const brpc::CallId cid = { static_cast<uint64_t>(meta.correlation_id()) };
- brpc::Controller* cntl = NULL;
+ brpc::Controller* cntl = nullptr;
ASSERT_EQ(0, bthread_id_lock(cid, (void**)&cntl));
ASSERT_NE(nullptr, cntl);
ASSERT_TRUE(brpc::ParsePbFromIOBuf(cntl->response(), msg->payload));
@@ -321,14 +321,14 @@ void ProcessResponse(brpc::InputMessageBase* msg_base) {
TEST_F(SSLTest, connect_on_create) {
brpc::Protocol dummy_protocol = {
brpc::policy::ParseRpcMessage, brpc::SerializeRequestDefault,
- brpc::policy::PackRpcRequest,NULL, ProcessResponse,
- NULL, NULL, NULL, brpc::CONNECTION_TYPE_ALL, "ssl_ut_baidu"
+ brpc::policy::PackRpcRequest,nullptr, ProcessResponse,
+ nullptr, nullptr, nullptr, brpc::CONNECTION_TYPE_ALL, "ssl_ut_baidu"
};
ASSERT_EQ(0, RegisterProtocol((brpc::ProtocolType)30, dummy_protocol));
brpc::InputMessageHandler dummy_handler ={
dummy_protocol.parse, dummy_protocol.process_response,
- NULL, NULL, dummy_protocol.name
+ nullptr, nullptr, dummy_protocol.name
};
brpc::InputMessenger messenger;
ASSERT_EQ(0, messenger.AddHandler(dummy_handler));
@@ -378,9 +378,9 @@ TEST_F(SSLTest, connect_on_create) {
cntl._response = &res;
const brpc::CallId correlation_id = cntl.call_id();
brpc::SerializeRequestDefault(&request_body, &cntl, &req);
- brpc::policy::PackRpcRequest(&request_buf, NULL, correlation_id.value,
+ brpc::policy::PackRpcRequest(&request_buf, nullptr, correlation_id.value,
test::EchoService_Stub::descriptor()->method(0),
- &cntl, request_body, NULL);
+ &cntl, request_body, nullptr);
ASSERT_EQ(0, ptr->Write(&request_buf));
brpc::Join(correlation_id);
ASSERT_EQ(EXP_RESPONSE, res.message());
@@ -408,7 +408,7 @@ void CheckCert(const char* cname, const char* cert) {
ASSERT_EQ(0, brpc::Socket::Address(ids[0], &sock));
X509* x509 = sock->GetPeerCertificate();
- ASSERT_TRUE(x509 != NULL);
+ ASSERT_TRUE(x509 != nullptr);
std::vector<std::string> cnames;
brpc::ExtractHostnames(x509, &cnames);
ASSERT_EQ(cert, cnames[0]) << x509;
@@ -528,7 +528,7 @@ void* ssl_perf_client(void* arg) {
<< size * REP / tm.u_elapsed() << "M/s"
<< ", latency=" << tm.u_elapsed() / REP << "us";
}
- return NULL;
+ return nullptr;
}
void* ssl_perf_server(void* arg) {
@@ -541,23 +541,23 @@ void* ssl_perf_server(void* arg) {
SSL_read(ssl, buf, size);
}
}
- return NULL;
+ return nullptr;
}
TEST_F(SSLTest, ssl_perf) {
const butil::EndPoint ep(butil::IP_ANY, 5961);
butil::fd_guard listenfd(butil::tcp_listen(ep));
ASSERT_GT(listenfd, 0);
- int clifd = tcp_connect(ep, NULL);
+ int clifd = tcp_connect(ep, nullptr);
ASSERT_GT(clifd, 0);
- int servfd = accept(listenfd, NULL, NULL);
+ int servfd = accept(listenfd, nullptr, nullptr);
ASSERT_GT(servfd, 0);
brpc::ChannelSSLOptions opt;
SSL_CTX* cli_ctx = brpc::CreateClientSSLContext(opt);
SSL_CTX* serv_ctx =
brpc::CreateServerSSLContext("cert1.crt", "cert1.key",
- brpc::SSLOptions(), NULL, NULL);
+ brpc::SSLOptions(), nullptr, nullptr);
SSL* cli_ssl = brpc::CreateSSLSession(cli_ctx, 0, clifd, false);
#if defined(SSL_CTRL_SET_TLSEXT_HOSTNAME) || defined(USE_MESALINK)
SSL_set_tlsext_host_name(cli_ssl, "localhost");
@@ -565,10 +565,10 @@ TEST_F(SSLTest, ssl_perf) {
SSL* serv_ssl = brpc::CreateSSLSession(serv_ctx, 0, servfd, true);
pthread_t cpid;
pthread_t spid;
- ASSERT_EQ(0, pthread_create(&cpid, NULL, ssl_perf_client, cli_ssl));
- ASSERT_EQ(0, pthread_create(&spid, NULL, ssl_perf_server , serv_ssl));
- ASSERT_EQ(0, pthread_join(cpid, NULL));
- ASSERT_EQ(0, pthread_join(spid, NULL));
+ ASSERT_EQ(0, pthread_create(&cpid, nullptr, ssl_perf_client, cli_ssl));
+ ASSERT_EQ(0, pthread_create(&spid, nullptr, ssl_perf_server , serv_ssl));
+ ASSERT_EQ(0, pthread_join(cpid, nullptr));
+ ASSERT_EQ(0, pthread_join(spid, nullptr));
SSL_free(cli_ssl);
SSL_free(serv_ssl);
@@ -584,7 +584,7 @@ TEST_F(SSLTest, ssl_perf) {
void* tls13_do_handshake(void* arg) {
SSL* ssl = (SSL*)arg;
EXPECT_EQ(1, SSL_do_handshake(ssl));
- return NULL;
+ return nullptr;
}
TEST_F(SSLTest, tls13_protocol_string) {
@@ -592,9 +592,9 @@ TEST_F(SSLTest, tls13_protocol_string) {
const butil::EndPoint ep(butil::IP_ANY, 8613);
butil::fd_guard listenfd(butil::tcp_listen(ep));
ASSERT_GT(listenfd, 0);
- int clifd = tcp_connect(ep, NULL);
+ int clifd = tcp_connect(ep, nullptr);
ASSERT_GT(clifd, 0);
- int servfd = accept(listenfd, NULL, NULL);
+ int servfd = accept(listenfd, nullptr, nullptr);
ASSERT_GT(servfd, 0);
brpc::ChannelSSLOptions opt;
@@ -603,7 +603,7 @@ TEST_F(SSLTest, tls13_protocol_string) {
ASSERT_NE(nullptr, cli_ctx);
SSL_CTX* serv_ctx =
brpc::CreateServerSSLContext("cert1.crt", "cert1.key",
- brpc::SSLOptions(), NULL, NULL);
+ brpc::SSLOptions(), nullptr, nullptr);
ASSERT_NE(nullptr, serv_ctx);
SSL* cli_ssl = brpc::CreateSSLSession(cli_ctx, 0, clifd, false);
#if defined(SSL_CTRL_SET_TLSEXT_HOSTNAME) || defined(USE_MESALINK)
@@ -614,13 +614,13 @@ TEST_F(SSLTest, tls13_protocol_string) {
ASSERT_NE(nullptr, serv_ssl);
pthread_t cpid;
pthread_t spid;
- ASSERT_EQ(0, pthread_create(&cpid, NULL, tls13_do_handshake, cli_ssl));
- ASSERT_EQ(0, pthread_create(&spid, NULL, tls13_do_handshake, serv_ssl));
- ASSERT_EQ(0, pthread_join(cpid, NULL));
- ASSERT_EQ(0, pthread_join(spid, NULL));
+ ASSERT_EQ(0, pthread_create(&cpid, nullptr, tls13_do_handshake, cli_ssl));
+ ASSERT_EQ(0, pthread_create(&spid, nullptr, tls13_do_handshake, serv_ssl));
+ ASSERT_EQ(0, pthread_join(cpid, nullptr));
+ ASSERT_EQ(0, pthread_join(spid, nullptr));
const char* version = SSL_get_version(cli_ssl);
- ASSERT_TRUE(version != NULL);
+ ASSERT_TRUE(version != nullptr);
EXPECT_STREQ("TLSv1.3", version) << "negotiated protocol=" << version;
SSL_free(cli_ssl);
@@ -637,7 +637,7 @@ TEST_F(SSLTest, tls13_protocol_string) {
brpc::ChannelSSLOptions opt;
opt.protocols = "TLSv1.3";
SSL_CTX* ctx = brpc::CreateClientSSLContext(opt);
- ASSERT_TRUE(ctx != NULL);
+ ASSERT_TRUE(ctx != nullptr);
SSL_CTX_free(ctx);
}
diff --git a/test/brpc_streaming_rpc_unittest.cpp b/test/brpc_streaming_rpc_unittest.cpp
index a759bae5..46401d6d 100644
--- a/test/brpc_streaming_rpc_unittest.cpp
+++ b/test/brpc_streaming_rpc_unittest.cpp
@@ -41,7 +41,7 @@ class MyServiceWithStream : public test::EchoService {
public:
MyServiceWithStream(const brpc::StreamOptions& options)
: _options(options)
- , _after_accept_stream(NULL)
+ , _after_accept_stream(nullptr)
{}
MyServiceWithStream(const brpc::StreamOptions& options,
AfterAcceptStream* after_accept_stream)
@@ -50,7 +50,7 @@ public:
{}
MyServiceWithStream()
: _options()
- , _after_accept_stream(NULL)
+ , _after_accept_stream(nullptr)
{}
void Echo(::google::protobuf::RpcController* controller,
@@ -150,7 +150,7 @@ static void* SendTwoMessagesOnServerExtraStream(void* arg) {
// the remote settings are ready. Check the acquire flag first
// before reading the non-atomic host pointer.
if (s->_connected.load(butil::memory_order_acquire) &&
- s->_host_socket != NULL) {
+ s->_host_socket != nullptr) {
connected = true;
break;
}
@@ -162,7 +162,7 @@ static void* SendTwoMessagesOnServerExtraStream(void* arg) {
state->server_first_write_rc.store(ETIMEDOUT, std::memory_order_relaxed);
state->server_second_write_rc.store(ETIMEDOUT, std::memory_order_relaxed);
state->server_write_done.store(true, std::memory_order_release);
- return NULL;
+ return nullptr;
}
// 1) Send a payload exactly equal to max_buf_size(64).
@@ -192,7 +192,7 @@ static void* SendTwoMessagesOnServerExtraStream(void* arg) {
}
state->server_second_write_rc.store(rc, std::memory_order_relaxed);
state->server_write_done.store(true, std::memory_order_release);
- return NULL;
+ return nullptr;
}
class MyServiceWithBatchStream : public test::EchoService {
@@ -249,15 +249,15 @@ TEST_F(StreamingRpcTest, sanity) {
brpc::Server server;
MyServiceWithStream service;
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(9007, NULL));
+ ASSERT_EQ(0, server.Start(9007, nullptr));
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init("127.0.0.1:9007", NULL));
+ ASSERT_EQ(0, channel.Init("127.0.0.1:9007", nullptr));
brpc::Controller cntl;
brpc::StreamId request_stream;
- ASSERT_EQ(0, StreamCreate(&request_stream, cntl, NULL));
+ ASSERT_EQ(0, StreamCreate(&request_stream, cntl, nullptr));
brpc::ScopedStream stream_guard(request_stream);
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &request, &response, NULL);
+ stub.Echo(&cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << " request_stream=" << request_stream;
usleep(10);
brpc::StreamClose(request_stream);
@@ -276,10 +276,10 @@ TEST_F(StreamingRpcTest, batch_create_stream_feedback_race) {
brpc::Server server;
MyServiceWithBatchStream service(server_stream_opt, &state);
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(9007, NULL));
+ ASSERT_EQ(0, server.Start(9007, nullptr));
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init("127.0.0.1:9007", NULL));
+ ASSERT_EQ(0, channel.Init("127.0.0.1:9007", nullptr));
brpc::Controller cntl;
brpc::StreamIds request_streams;
@@ -302,7 +302,7 @@ TEST_F(StreamingRpcTest, batch_create_stream_feedback_race) {
}
if (state.server_send_tid) {
- bthread_join(state.server_send_tid, NULL);
+ bthread_join(state.server_send_tid, nullptr);
}
server.Stop(0);
server.Join();
@@ -347,7 +347,7 @@ struct HandlerControl {
class OrderedInputHandler : public brpc::StreamInputHandler {
public:
- explicit OrderedInputHandler(HandlerControl *cntl = NULL)
+ explicit OrderedInputHandler(HandlerControl *cntl = nullptr)
: _expected_next_value(0)
, _failed(false)
, _stopped(false)
@@ -407,9 +407,9 @@ TEST_F(StreamingRpcTest, received_in_order) {
brpc::Server server;
MyServiceWithStream service(opt);
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(9007, NULL));
+ ASSERT_EQ(0, server.Start(9007, nullptr));
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init("127.0.0.1:9007", NULL));
+ ASSERT_EQ(0, channel.Init("127.0.0.1:9007", nullptr));
brpc::Controller cntl;
brpc::StreamId request_stream;
brpc::StreamOptions request_stream_options;
@@ -417,7 +417,7 @@ TEST_F(StreamingRpcTest, received_in_order) {
ASSERT_EQ(0, StreamCreate(&request_stream, cntl, &request_stream_options));
brpc::ScopedStream stream_guard(request_stream);
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &request, &response, NULL);
+ stub.Echo(&cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << " request_stream=" << request_stream;
const int N = 10000;
for (int i = 0; i < N; ++i) {
@@ -455,9 +455,9 @@ TEST_F(StreamingRpcTest, block) {
brpc::Server server;
MyServiceWithStream service(opt);
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(9007, NULL));
+ ASSERT_EQ(0, server.Start(9007, nullptr));
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init("127.0.0.1:9007", NULL));
+ ASSERT_EQ(0, channel.Init("127.0.0.1:9007", nullptr));
brpc::Controller cntl;
brpc::StreamId request_stream;
brpc::ScopedStream stream_guard(request_stream);
@@ -465,7 +465,7 @@ TEST_F(StreamingRpcTest, block) {
request_stream_options.max_buf_size = sizeof(uint32_t) * N;
ASSERT_EQ(0, StreamCreate(&request_stream, cntl, &request_stream_options));
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &request, &response, NULL);
+ stub.Echo(&cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << " request_stream="
<< request_stream;
for (int i = 0; i < N; ++i) {
@@ -488,7 +488,7 @@ TEST_F(StreamingRpcTest, block) {
hc.block = true;
// async wait
for (int i = N; i < N + N; ++i) {
- ASSERT_EQ(0, brpc::StreamWait(request_stream, NULL));
+ ASSERT_EQ(0, brpc::StreamWait(request_stream, nullptr));
int network = htonl(i);
butil::IOBuf out;
out.append(&network, sizeof(network));
@@ -500,7 +500,7 @@ TEST_F(StreamingRpcTest, block) {
hc.block = false;
std::pair<bool, int> p = std::make_pair(false, 0);
usleep(10);
- brpc::StreamWait(request_stream, NULL, on_writable, &p);
+ brpc::StreamWait(request_stream, nullptr, on_writable, &p);
while (!p.first) {
usleep(100);
}
@@ -554,9 +554,9 @@ TEST_F(StreamingRpcTest, auto_close_if_host_socket_closed) {
brpc::Server server;
MyServiceWithStream service(opt);
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(9007, NULL));
+ ASSERT_EQ(0, server.Start(9007, nullptr));
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init("127.0.0.1:9007", NULL));
+ ASSERT_EQ(0, channel.Init("127.0.0.1:9007", nullptr));
brpc::Controller cntl;
brpc::StreamId request_stream;
brpc::StreamOptions request_stream_options;
@@ -564,7 +564,7 @@ TEST_F(StreamingRpcTest, auto_close_if_host_socket_closed) {
ASSERT_EQ(0, StreamCreate(&request_stream, cntl, &request_stream_options));
brpc::ScopedStream stream_guard(request_stream);
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &request, &response, NULL);
+ stub.Echo(&cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << " request_stream=" << request_stream;
{
@@ -573,7 +573,7 @@ TEST_F(StreamingRpcTest, auto_close_if_host_socket_closed) {
brpc::Stream* s = ptr.get();
ASSERT_TRUE(s->_connected.load(butil::memory_order_acquire));
brpc::Socket* host_socket = s->_host_socket;
- ASSERT_TRUE(host_socket != NULL);
+ ASSERT_TRUE(host_socket != nullptr);
host_socket->SetFailed();
}
@@ -597,9 +597,9 @@ TEST_F(StreamingRpcTest, failed_when_rst) {
brpc::Server server;
MyServiceWithStream service(opt);
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(9007, NULL));
+ ASSERT_EQ(0, server.Start(9007, nullptr));
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init("127.0.0.1:9007", NULL));
+ ASSERT_EQ(0, channel.Init("127.0.0.1:9007", nullptr));
brpc::Controller cntl;
brpc::StreamId request_stream;
brpc::StreamOptions request_stream_options;
@@ -607,7 +607,7 @@ TEST_F(StreamingRpcTest, failed_when_rst) {
ASSERT_EQ(0, StreamCreate(&request_stream, cntl, &request_stream_options));
brpc::ScopedStream stream_guard(request_stream);
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &request, &response, NULL);
+ stub.Echo(&cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << " request_stream=" << request_stream;
const int N = 10000;
for (int i = 0; i < N; ++i) {
@@ -625,7 +625,7 @@ TEST_F(StreamingRpcTest, failed_when_rst) {
ASSERT_EQ(0, brpc::Stream::Address(request_stream, &ptr));
brpc::Stream* s = ptr.get();
ASSERT_TRUE(s->_connected.load(butil::memory_order_acquire));
- ASSERT_TRUE(s->_host_socket != NULL);
+ ASSERT_TRUE(s->_host_socket != nullptr);
brpc::policy::SendStreamRst(s->_host_socket,
s->_remote_settings.stream_id());
}
@@ -652,9 +652,9 @@ TEST_F(StreamingRpcTest, idle_timeout) {
brpc::Server server;
MyServiceWithStream service(opt);
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(9007, NULL));
+ ASSERT_EQ(0, server.Start(9007, nullptr));
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init("127.0.0.1:9007", NULL));
+ ASSERT_EQ(0, channel.Init("127.0.0.1:9007", nullptr));
brpc::Controller cntl;
brpc::StreamId request_stream;
brpc::StreamOptions request_stream_options;
@@ -662,7 +662,7 @@ TEST_F(StreamingRpcTest, idle_timeout) {
ASSERT_EQ(0, StreamCreate(&request_stream, cntl, &request_stream_options));
brpc::ScopedStream stream_guard(request_stream);
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &request, &response, NULL);
+ stub.Echo(&cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << " request_stream=" << request_stream;
usleep(10 * 1000 + 800);
ASSERT_EQ(0, brpc::StreamClose(request_stream));
@@ -741,9 +741,9 @@ TEST_F(StreamingRpcTest, ping_pong) {
brpc::Server server;
MyServiceWithStream service(opt);
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(9007, NULL));
+ ASSERT_EQ(0, server.Start(9007, nullptr));
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init("127.0.0.1:9007", NULL));
+ ASSERT_EQ(0, channel.Init("127.0.0.1:9007", nullptr));
brpc::Controller cntl;
brpc::StreamId request_stream;
brpc::StreamOptions request_stream_options;
@@ -754,7 +754,7 @@ TEST_F(StreamingRpcTest, ping_pong) {
ASSERT_EQ(0, StreamCreate(&request_stream, cntl, &request_stream_options));
brpc::ScopedStream stream_guard(request_stream);
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &request, &response, NULL);
+ stub.Echo(&cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << " request_stream=" << request_stream;
int send = 0;
butil::IOBuf out;
@@ -795,9 +795,9 @@ TEST_F(StreamingRpcTest, server_send_data_before_run_done) {
brpc::Server server;
MyServiceWithStream service(opt, &after_accept);
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(9007, NULL));
+ ASSERT_EQ(0, server.Start(9007, nullptr));
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init("127.0.0.1:9007", NULL));
+ ASSERT_EQ(0, channel.Init("127.0.0.1:9007", nullptr));
OrderedInputHandler handler;
brpc::StreamOptions request_stream_options;
request_stream_options.handler = &handler;
@@ -806,7 +806,7 @@ TEST_F(StreamingRpcTest, server_send_data_before_run_done) {
ASSERT_EQ(0, StreamCreate(&request_stream, cntl, &request_stream_options));
brpc::ScopedStream stream_guard(request_stream);
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &request, &response, NULL);
+ stub.Echo(&cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << " request_stream=" << request_stream;
// wait flushing all the pending messages
while (handler._expected_next_value != N) {
@@ -829,16 +829,16 @@ TEST_F(StreamingRpcTest, segment_stream_data_automatically) {
brpc::Server server;
MyServiceWithStream service(opt);
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(9007, NULL));
+ ASSERT_EQ(0, server.Start(9007, nullptr));
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init("127.0.0.1:9007", NULL));
+ ASSERT_EQ(0, channel.Init("127.0.0.1:9007", nullptr));
brpc::Controller cntl;
brpc::StreamId request_stream;
brpc::StreamOptions request_stream_options;
ASSERT_EQ(0, StreamCreate(&request_stream, cntl, &request_stream_options));
brpc::ScopedStream stream_guard(request_stream);
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &request, &response, NULL);
+ stub.Echo(&cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText() << " request_stream=" << request_stream;
const int N = 1000;
for (int i = 0; i < N; ++i) {
@@ -854,7 +854,7 @@ TEST_F(StreamingRpcTest, segment_stream_data_automatically) {
ASSERT_EQ(0, brpc::Stream::Address(request_stream, &ptr));
ASSERT_TRUE(ptr->_connected.load(butil::memory_order_acquire));
brpc::Socket* host_socket = ptr->_host_socket;
- ASSERT_TRUE(host_socket != NULL);
+ ASSERT_TRUE(host_socket != nullptr);
host_socket->ReAddress(&host_socket_ptr);
}
@@ -884,11 +884,11 @@ TEST_F(StreamingRpcTest, create_request_stream_twice_on_same_controller_returns_
brpc::Controller cntl;
brpc::StreamId first_stream = brpc::INVALID_STREAM_ID;
- ASSERT_EQ(0, brpc::StreamCreate(&first_stream, cntl, NULL));
+ ASSERT_EQ(0, brpc::StreamCreate(&first_stream, cntl, nullptr));
brpc::ScopedStream stream_guard(first_stream);
brpc::StreamId second_stream = brpc::INVALID_STREAM_ID;
- ASSERT_EQ(-1, brpc::StreamCreate(&second_stream, cntl, NULL));
+ ASSERT_EQ(-1, brpc::StreamCreate(&second_stream, cntl, nullptr));
ASSERT_EQ(brpc::INVALID_STREAM_ID, second_stream);
}
@@ -1020,10 +1020,10 @@ TEST_F(StreamingRpcTest, batch_create_extra_stream) {
brpc::Server server;
MyServiceWithExtraStream service(server_stream_opt, STREAM_COUNT, N);
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(9007, NULL));
+ ASSERT_EQ(0, server.Start(9007, nullptr));
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init("127.0.0.1:9007", NULL));
+ ASSERT_EQ(0, channel.Init("127.0.0.1:9007", nullptr));
brpc::Controller cntl;
brpc::StreamOptions client_stream_opt;
@@ -1034,7 +1034,7 @@ TEST_F(StreamingRpcTest, batch_create_extra_stream) {
ASSERT_EQ(STREAM_COUNT, request_streams.size());
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &request, &response, NULL);
+ stub.Echo(&cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
// Every stream, including the extra streams, must end up connected with a valid host_socket.
@@ -1046,7 +1046,7 @@ TEST_F(StreamingRpcTest, batch_create_extra_stream) {
return false;
}
brpc::Stream* s = ptr.get();
- return s->_host_socket != NULL &&
+ return s->_host_socket != nullptr &&
s->_connected.load(butil::memory_order_acquire);
}, 5000)) << "stream_index=" << i;
}
@@ -1101,10 +1101,10 @@ TEST_F(StreamingRpcTest, batch_create_extra_stream_upstream_only) {
// n = 0: server never sends downstream data on any accepted stream.
MyServiceWithExtraStream service(server_stream_opt, STREAM_COUNT, 0);
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(9007, NULL));
+ ASSERT_EQ(0, server.Start(9007, nullptr));
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init("127.0.0.1:9007", NULL));
+ ASSERT_EQ(0, channel.Init("127.0.0.1:9007", nullptr));
brpc::Controller cntl;
// No downstream handler is needed on the client side.
@@ -1116,7 +1116,7 @@ TEST_F(StreamingRpcTest, batch_create_extra_stream_upstream_only) {
ASSERT_EQ(STREAM_COUNT, request_streams.size());
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &request, &response, NULL);
+ stub.Echo(&cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
// Without any downstream data, extra streams have no chance to get their
@@ -1131,7 +1131,7 @@ TEST_F(StreamingRpcTest, batch_create_extra_stream_upstream_only) {
return false;
}
brpc::Stream* s = ptr.get();
- return s->_host_socket != NULL &&
+ return s->_host_socket != nullptr &&
s->_connected.load(butil::memory_order_acquire);
}, 5000)) << "stream_index=" << i;
}
@@ -1198,10 +1198,10 @@ TEST_F(StreamingRpcTest, unconsumed_bytes_reclaimed_on_stream_close) {
brpc::Server server;
MyServiceWithStream service(opt);
ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE));
- ASSERT_EQ(0, server.Start(9007, NULL));
+ ASSERT_EQ(0, server.Start(9007, nullptr));
brpc::Channel channel;
- ASSERT_EQ(0, channel.Init("127.0.0.1:9007", NULL));
+ ASSERT_EQ(0, channel.Init("127.0.0.1:9007", nullptr));
brpc::Controller cntl;
brpc::StreamId request_stream;
@@ -1211,7 +1211,7 @@ TEST_F(StreamingRpcTest, unconsumed_bytes_reclaimed_on_stream_close) {
brpc::ScopedStream stream_guard(request_stream);
test::EchoService_Stub stub(&channel);
- stub.Echo(&cntl, &request, &response, NULL);
+ stub.Echo(&cntl, &request, &response, nullptr);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
brpc::SocketUniquePtr host_socket;
@@ -1219,7 +1219,7 @@ TEST_F(StreamingRpcTest, unconsumed_bytes_reclaimed_on_stream_close) {
brpc::StreamUniquePtr ptr;
ASSERT_EQ(0, brpc::Stream::Address(request_stream, &ptr));
ASSERT_TRUE(ptr->_connected.load(butil::memory_order_acquire));
- ASSERT_TRUE(ptr->_host_socket != NULL);
+ ASSERT_TRUE(ptr->_host_socket != nullptr);
ptr->_host_socket->ReAddress(&host_socket);
}
int64_t baseline = host_socket->_total_streams_unconsumed_size.load(
diff --git a/test/brpc_ubring_unittest.cpp b/test/brpc_ubring_unittest.cpp
index 4340e7a0..14b2ef1b 100644
--- a/test/brpc_ubring_unittest.cpp
+++ b/test/brpc_ubring_unittest.cpp
@@ -182,14 +182,14 @@ TEST_F(UBShmEndpointTest, construct_initial_state) {
TEST_F(UBShmEndpointTest, allocate_client_resources_real_shm) {
brpc::ubring::SHM local_trx_shm =
- {NULL, 4 * 1024 * 1024, 0, {0}, (uint32_t)_socket->fd()};
+ {nullptr, 4 * 1024 * 1024, 0, {0}, (uint32_t)_socket->fd()};
int ret = _ep->AllocateClientResources(&local_trx_shm, "UBRING_ut_client");
EXPECT_EQ(0, ret);
}
TEST_F(UBShmEndpointTest, reset_cleans_up_resources) {
brpc::ubring::SHM local_trx_shm =
- {NULL, 4 * 1024 * 1024, 0, {0}, (uint32_t)_socket->fd()};
+ {nullptr, 4 * 1024 * 1024, 0, {0}, (uint32_t)_socket->fd()};
_ep->AllocateClientResources(&local_trx_shm, "UBRING_ut_reset");
_ep->Reset();
}
diff --git a/test/bthread_butex_unittest.cpp b/test/bthread_butex_unittest.cpp
index 8f2f4f5f..730eac7b 100644
--- a/test/bthread_butex_unittest.cpp
+++ b/test/bthread_butex_unittest.cpp
@@ -47,13 +47,13 @@ TEST(ButexTest, wait_on_already_timedout_butex) {
void* sleeper(void* arg) {
bthread_usleep((uint64_t)arg);
- return NULL;
+ return nullptr;
}
void* joiner(void* arg) {
const long t1 = butil::gettimeofday_us();
for (bthread_t* th = (bthread_t*)arg; *th; ++th) {
- if (0 != bthread_join(*th, NULL)) {
+ if (0 != bthread_join(*th, nullptr)) {
LOG(FATAL) << "fail to join thread_" << th - (bthread_t*)arg;
}
long elp = butil::gettimeofday_us() - t1;
@@ -63,9 +63,9 @@ void* joiner(void* arg) {
<< bthread_self() << "]";
}
for (bthread_t* th = (bthread_t*)arg; *th; ++th) {
- EXPECT_EQ(0, bthread_join(*th, NULL));
+ EXPECT_EQ(0, bthread_join(*th, nullptr));
}
- return NULL;
+ return nullptr;
}
struct A {
@@ -97,18 +97,18 @@ TEST(ButexTest, join) {
}
th[N] = 0; // joiner will join tids in `th' until seeing 0.
for (size_t i = 0; i < M; ++i) {
- ASSERT_EQ(0, bthread_start_urgent(&jth[i], NULL, joiner, th));
+ ASSERT_EQ(0, bthread_start_urgent(&jth[i], nullptr, joiner, th));
}
for (size_t i = 0; i < M; ++i) {
- ASSERT_EQ(0, pthread_create(&pth[i], NULL, joiner, th));
+ ASSERT_EQ(0, pthread_create(&pth[i], nullptr, joiner, th));
}
for (size_t i = 0; i < M; ++i) {
- ASSERT_EQ(0, bthread_join(jth[i], NULL))
+ ASSERT_EQ(0, bthread_join(jth[i], nullptr))
<< "i=" << i << " error=" << berror();
}
for (size_t i = 0; i < M; ++i) {
- ASSERT_EQ(0, pthread_join(pth[i], NULL));
+ ASSERT_EQ(0, pthread_join(pth[i], nullptr));
}
}
@@ -132,7 +132,7 @@ void* waiter(void* arg) {
EXPECT_EQ(wa->expected_result, errno) << bthread_self();
}
LOG(INFO) << "after wait, time=" << (t2-t1) << "us";
- return NULL;
+ return nullptr;
}
TEST(ButexTest, sanity) {
@@ -152,10 +152,10 @@ TEST(ButexTest, sanity) {
unmatched_arg->expected_value = *b1 + 1;
unmatched_arg->expected_result = EWOULDBLOCK;
unmatched_arg->butex = b1;
- unmatched_arg->ptimeout = NULL;
- pthread_create(&t2, NULL, waiter, unmatched_arg);
+ unmatched_arg->ptimeout = nullptr;
+ pthread_create(&t2, nullptr, waiter, unmatched_arg);
bthread_t th;
- ASSERT_EQ(0, bthread_start_urgent(&th, NULL, waiter, unmatched_arg));
+ ASSERT_EQ(0, bthread_start_urgent(&th, nullptr, waiter, unmatched_arg));
const timespec abstime = butil::seconds_from_now(1);
for (size_t i = 0; i < 4*N; ++i) {
@@ -163,15 +163,15 @@ TEST(ButexTest, sanity) {
args[i].butex = b1;
if ((i % 2) == 0) {
args[i].expected_result = 0;
- args[i].ptimeout = NULL;
+ args[i].ptimeout = nullptr;
} else {
args[i].expected_result = ETIMEDOUT;
args[i].ptimeout = &abstime;
}
if (i < 2*N) {
- pthread_create(&t1, NULL, waiter, &args[i]);
+ pthread_create(&t1, nullptr, waiter, &args[i]);
} else {
- ASSERT_EQ(0, bthread_start_urgent(&th, NULL, waiter, &args[i]));
+ ASSERT_EQ(0, bthread_start_urgent(&th, nullptr, waiter, &args[i]));
}
}
@@ -203,7 +203,7 @@ void* wait_butex(void* void_arg) {
} else {
EXPECT_EQ(0, rc);
}
- return NULL;
+ return nullptr;
}
TEST(ButexTest, wait_without_stop) {
@@ -219,7 +219,7 @@ TEST(ButexTest, wait_without_stop) {
tm.start();
ASSERT_EQ(0, bthread_start_urgent(&th, &attr, wait_butex, &arg));
- ASSERT_EQ(0, bthread_join(th, NULL));
+ ASSERT_EQ(0, bthread_join(th, nullptr));
tm.stop();
ASSERT_LT(labs(tm.m_elapsed() - WAIT_MSEC), 250);
@@ -243,7 +243,7 @@ TEST(ButexTest, stop_after_running) {
ASSERT_EQ(0, bthread_start_urgent(&th, &attr, wait_butex, &arg));
ASSERT_EQ(0, bthread_usleep(SLEEP_MSEC * 1000L));
ASSERT_EQ(0, bthread_stop(th));
- ASSERT_EQ(0, bthread_join(th, NULL));
+ ASSERT_EQ(0, bthread_join(th, nullptr));
tm.stop();
ASSERT_LT(labs(tm.m_elapsed() - SLEEP_MSEC), 25);
@@ -270,7 +270,7 @@ TEST(ButexTest, stop_before_running) {
ASSERT_EQ(0, bthread_start_background(&th, &attr, wait_butex, &arg));
ASSERT_EQ(0, bthread_stop(th));
bthread_flush();
- ASSERT_EQ(0, bthread_join(th, NULL));
+ ASSERT_EQ(0, bthread_join(th, nullptr));
tm.stop();
ASSERT_LT(tm.m_elapsed(), 5);
@@ -282,8 +282,8 @@ TEST(ButexTest, stop_before_running) {
}
void* join_the_waiter(void* arg) {
- EXPECT_EQ(0, bthread_join((bthread_t)arg, NULL));
- return NULL;
+ EXPECT_EQ(0, bthread_join((bthread_t)arg, nullptr));
+ return nullptr;
}
TEST(ButexTest, join_cant_be_wakeup) {
@@ -298,7 +298,7 @@ TEST(ButexTest, join_cant_be_wakeup) {
(i == 0 ? BTHREAD_ATTR_PTHREAD : BTHREAD_ATTR_NORMAL);
tm.start();
bthread_t th, th2;
- ASSERT_EQ(0, bthread_start_urgent(&th, NULL, wait_butex, &arg));
+ ASSERT_EQ(0, bthread_start_urgent(&th, nullptr, wait_butex, &arg));
ASSERT_EQ(0, bthread_start_urgent(&th2, &attr, join_the_waiter, (void*)th));
ASSERT_EQ(0, bthread_stop(th2));
ASSERT_EQ(0, bthread_usleep(WAIT_MSEC / 2 * 1000L));
@@ -306,8 +306,8 @@ TEST(ButexTest, join_cant_be_wakeup) {
ASSERT_TRUE(bthread::TaskGroup::exists(th2));
ASSERT_EQ(0, bthread_usleep(WAIT_MSEC / 2 * 1000L));
ASSERT_EQ(0, bthread_stop(th));
- ASSERT_EQ(0, bthread_join(th2, NULL));
- ASSERT_EQ(0, bthread_join(th, NULL));
+ ASSERT_EQ(0, bthread_join(th2, nullptr));
+ ASSERT_EQ(0, bthread_join(th, nullptr));
tm.stop();
ASSERT_LT(tm.m_elapsed(), WAIT_MSEC + 15);
ASSERT_EQ(EINVAL, bthread_stop(th));
@@ -330,7 +330,7 @@ TEST(ButexTest, stop_after_slept) {
&th, &attr, sleeper, (void*)(SLEEP_MSEC*1000L)));
ASSERT_EQ(0, bthread_usleep(WAIT_MSEC * 1000L));
ASSERT_EQ(0, bthread_stop(th));
- ASSERT_EQ(0, bthread_join(th, NULL));
+ ASSERT_EQ(0, bthread_join(th, nullptr));
tm.stop();
if (attr.stack_type == BTHREAD_STACKTYPE_PTHREAD) {
ASSERT_LT(labs(tm.m_elapsed() - SLEEP_MSEC), 15);
@@ -355,7 +355,7 @@ TEST(ButexTest, stop_just_when_sleeping) {
ASSERT_EQ(0, bthread_start_urgent(
&th, &attr, sleeper, (void*)(SLEEP_MSEC*1000L)));
ASSERT_EQ(0, bthread_stop(th));
- ASSERT_EQ(0, bthread_join(th, NULL));
+ ASSERT_EQ(0, bthread_join(th, nullptr));
tm.stop();
if (attr.stack_type == BTHREAD_STACKTYPE_PTHREAD) {
ASSERT_LT(labs(tm.m_elapsed() - SLEEP_MSEC), 15);
@@ -382,7 +382,7 @@ TEST(ButexTest, stop_before_sleeping) {
(void*)(SLEEP_MSEC*1000L)));
ASSERT_EQ(0, bthread_stop(th));
bthread_flush();
- ASSERT_EQ(0, bthread_join(th, NULL));
+ ASSERT_EQ(0, bthread_join(th, nullptr));
tm.stop();
if (attr.stack_type == BTHREAD_STACKTYPE_PTHREAD) {
@@ -408,7 +408,7 @@ void* trigger_signal(void* arg) {
}
const long t2 = butil::gettimeofday_us();
LOG(INFO) << "trigger signal thread end, elapsed=" << (t2-t1) << "us";
- return NULL;
+ return nullptr;
}
TEST(ButexTest, wait_with_signal_triggered) {
@@ -429,17 +429,17 @@ TEST(ButexTest, wait_with_signal_triggered) {
waiter_args.expected_result = ETIMEDOUT;
waiter_args.ptimeout = &abstime;
tm.start();
- pthread_create(&waiter_th, NULL, waiter, &waiter_args);
- pthread_create(&tigger_th, NULL, trigger_signal, &waiter_th);
+ pthread_create(&waiter_th, nullptr, waiter, &waiter_args);
+ pthread_create(&tigger_th, nullptr, trigger_signal, &waiter_th);
- ASSERT_EQ(0, pthread_join(waiter_th, NULL));
+ ASSERT_EQ(0, pthread_join(waiter_th, nullptr));
tm.stop();
auto wait_elapsed_ms = tm.m_elapsed();;
LOG(INFO) << "waiter thread end, elapsed " << wait_elapsed_ms << " ms";
ASSERT_LT(labs(wait_elapsed_ms - WAIT_MSEC), 250);
- ASSERT_EQ(0, pthread_join(tigger_th, NULL));
+ ASSERT_EQ(0, pthread_join(tigger_th, nullptr));
bthread::butex_destroy(butex);
}
diff --git a/test/bthread_cond_bug_unittest.cpp b/test/bthread_cond_bug_unittest.cpp
index 90881f56..96b67e40 100644
--- a/test/bthread_cond_bug_unittest.cpp
+++ b/test/bthread_cond_bug_unittest.cpp
@@ -123,10 +123,10 @@ void* consume_func(void* arg) {
TEST(BthreadCondBugTest, test_bug) {
bthread_t tids[PRODUCER_NUM];
for (int i = 0; i < PRODUCER_NUM; i++) {
- bthread_start_background(&tids[i], NULL, produce_func, (void*)(int64_t)i);
+ bthread_start_background(&tids[i], nullptr, produce_func, (void*)(int64_t)i);
}
bthread_t tid;
- bthread_start_background(&tid, NULL, consume_func, NULL);
+ bthread_start_background(&tid, nullptr, consume_func, nullptr);
int64_t ret = (int64_t)print_func(nullptr);
diff --git a/test/bthread_cond_unittest.cpp b/test/bthread_cond_unittest.cpp
index f2dcddfe..85181691 100644
--- a/test/bthread_cond_unittest.cpp
+++ b/test/bthread_cond_unittest.cpp
@@ -46,7 +46,7 @@ void* signaler(void* void_arg) {
bthread_usleep(SIGNAL_INTERVAL_US);
bthread_cond_signal(&a->c);
}
- return NULL;
+ return nullptr;
}
void* waiter(void* void_arg) {
@@ -60,13 +60,13 @@ void* waiter(void* void_arg) {
wake_time.push_back(butil::gettimeofday_us());
}
bthread_mutex_unlock(&a->m);
- return NULL;
+ return nullptr;
}
TEST(CondTest, sanity) {
Arg a;
- ASSERT_EQ(0, bthread_mutex_init(&a.m, NULL));
- ASSERT_EQ(0, bthread_cond_init(&a.c, NULL));
+ ASSERT_EQ(0, bthread_mutex_init(&a.m, nullptr));
+ ASSERT_EQ(0, bthread_cond_init(&a.c, nullptr));
// has no effect
ASSERT_EQ(0, bthread_cond_signal(&a.c));
@@ -79,11 +79,11 @@ TEST(CondTest, sanity) {
bthread_t wth[8];
const size_t NW = ARRAY_SIZE(wth);
for (size_t i = 0; i < NW; ++i) {
- ASSERT_EQ(0, bthread_start_urgent(&wth[i], NULL, waiter, &a));
+ ASSERT_EQ(0, bthread_start_urgent(&wth[i], nullptr, waiter, &a));
}
bthread_t sth;
- ASSERT_EQ(0, bthread_start_urgent(&sth, NULL, signaler, &a));
+ ASSERT_EQ(0, bthread_start_urgent(&sth, nullptr, signaler, &a));
bthread_usleep(SIGNAL_INTERVAL_US * 200);
@@ -96,9 +96,9 @@ TEST(CondTest, sanity) {
bthread_cond_signal(&a.c);
}
- bthread_join(sth, NULL);
+ bthread_join(sth, nullptr);
for (size_t i = 0; i < NW; ++i) {
- bthread_join(wth[i], NULL);
+ bthread_join(wth[i], nullptr);
}
printf("wake up for %lu times\n", wake_tid.size());
@@ -150,7 +150,7 @@ void* cv_signaler(void* void_arg) {
bthread_usleep(SIGNAL_INTERVAL_US);
a->cond.notify_one();
}
- return NULL;
+ return nullptr;
}
void* cv_bmutex_waiter(void* void_arg) {
@@ -159,7 +159,7 @@ void* cv_bmutex_waiter(void* void_arg) {
while (!stop) {
a->cond.wait(lck);
}
- return NULL;
+ return nullptr;
}
void* cv_mutex_waiter(void* void_arg) {
@@ -168,7 +168,7 @@ void* cv_mutex_waiter(void* void_arg) {
while (!stop) {
a->cond.wait(lck);
}
- return NULL;
+ return nullptr;
}
@@ -177,7 +177,7 @@ void* cv_bmutex_waiter_with_pred(void* void_arg) {
std::unique_lock<bthread_mutex_t> lck(*a->mutex.native_handler());
a->cond.wait(lck, [&] { return a->ready; });
WrapperArg::wake_time.fetch_add(1);
- return NULL;
+ return nullptr;
}
void* cv_mutex_waiter_with_pred(void* void_arg) {
@@ -185,7 +185,7 @@ void* cv_mutex_waiter_with_pred(void* void_arg) {
std::unique_lock<bthread::Mutex> lck(a->mutex);
a->cond.wait(lck, [&] { return a->ready; });
WrapperArg::wake_time.fetch_add(1);
- return NULL;
+ return nullptr;
}
#define COND_IN_PTHREAD
@@ -203,22 +203,22 @@ TEST(CondTest, cpp_wrapper) {
pthread_t signal_thread;
WrapperArg a;
for (size_t i = 0; i < ARRAY_SIZE(bmutex_waiter_threads); ++i) {
- ASSERT_EQ(0, pthread_create(&bmutex_waiter_threads[i], NULL,
+ ASSERT_EQ(0, pthread_create(&bmutex_waiter_threads[i], nullptr,
cv_bmutex_waiter, &a));
- ASSERT_EQ(0, pthread_create(&mutex_waiter_threads[i], NULL,
+ ASSERT_EQ(0, pthread_create(&mutex_waiter_threads[i], nullptr,
cv_mutex_waiter, &a));
}
- ASSERT_EQ(0, pthread_create(&signal_thread, NULL, cv_signaler, &a));
+ ASSERT_EQ(0, pthread_create(&signal_thread, nullptr, cv_signaler, &a));
bthread_usleep(100L * 1000);
{
BAIDU_SCOPED_LOCK(a.mutex);
stop = true;
}
- pthread_join(signal_thread, NULL);
+ pthread_join(signal_thread, nullptr);
a.cond.notify_all();
for (size_t i = 0; i < ARRAY_SIZE(bmutex_waiter_threads); ++i) {
- pthread_join(bmutex_waiter_threads[i], NULL);
- pthread_join(mutex_waiter_threads[i], NULL);
+ pthread_join(bmutex_waiter_threads[i], nullptr);
+ pthread_join(mutex_waiter_threads[i], nullptr);
}
}
@@ -230,12 +230,12 @@ TEST(CondTest, cpp_wrapper2) {
pthread_t signal_thread;
WrapperArg a;
for (size_t i = 0; i < ARRAY_SIZE(bmutex_waiter_threads); ++i) {
- ASSERT_EQ(0, pthread_create(&bmutex_waiter_threads[i], NULL,
+ ASSERT_EQ(0, pthread_create(&bmutex_waiter_threads[i], nullptr,
cv_bmutex_waiter_with_pred, &a));
- ASSERT_EQ(0, pthread_create(&mutex_waiter_threads[i], NULL,
+ ASSERT_EQ(0, pthread_create(&mutex_waiter_threads[i], nullptr,
cv_mutex_waiter_with_pred, &a));
}
- ASSERT_EQ(0, pthread_create(&signal_thread, NULL, cv_signaler, &a));
+ ASSERT_EQ(0, pthread_create(&signal_thread, nullptr, cv_signaler, &a));
bthread_usleep(100L * 1000);
ASSERT_EQ(WrapperArg::wake_time, 0);
{
@@ -244,11 +244,11 @@ TEST(CondTest, cpp_wrapper2) {
a.ready = true;
}
- pthread_join(signal_thread, NULL);
+ pthread_join(signal_thread, nullptr);
a.cond.notify_all();
for (size_t i = 0; i < ARRAY_SIZE(bmutex_waiter_threads); ++i) {
- pthread_join(bmutex_waiter_threads[i], NULL);
- pthread_join(mutex_waiter_threads[i], NULL);
+ pthread_join(bmutex_waiter_threads[i], nullptr);
+ pthread_join(mutex_waiter_threads[i], nullptr);
}
ASSERT_EQ(WrapperArg::wake_time, 16);
}
@@ -305,7 +305,7 @@ void *ping_pong_thread(void* arg) {
++local_count;
}
a->total_count.fetch_add(local_count);
- return NULL;
+ return nullptr;
}
TEST(CondTest, ping_pong) {
@@ -315,14 +315,14 @@ TEST(CondTest, ping_pong) {
bthread_t threads[2];
ProfilerStart("cond.prof");
for (int i = 0; i < 2; ++i) {
- ASSERT_EQ(0, bthread_start_urgent(&threads[i], NULL, ping_pong_thread, &arg));
+ ASSERT_EQ(0, bthread_start_urgent(&threads[i], nullptr, ping_pong_thread, &arg));
}
usleep(1000 * 1000);
arg.stopped = true;
arg.sig1.notify();
arg.sig2.notify();
for (int i = 0; i < 2; ++i) {
- ASSERT_EQ(0, bthread_join(threads[i], NULL));
+ ASSERT_EQ(0, bthread_join(threads[i], nullptr));
}
ProfilerStop();
LOG(INFO) << "total_count=" << arg.total_count.load();
@@ -351,7 +351,7 @@ void* wait_thread(void* arg) {
ba->wait_cond.wait(lck);
}
}
- return NULL;
+ return nullptr;
}
void* broadcast_thread(void* arg) {
@@ -366,7 +366,7 @@ void* broadcast_thread(void* arg) {
--ba->rounds;
ba->wait_cond.notify_all();
}
- return NULL;
+ return nullptr;
}
void* disturb_thread(void* arg) {
@@ -376,7 +376,7 @@ void* disturb_thread(void* arg) {
lck.unlock();
lck.lock();
}
- return NULL;
+ return nullptr;
}
TEST(CondTest, mixed_usage) {
@@ -389,30 +389,30 @@ TEST(CondTest, mixed_usage) {
bthread_t normal_threads[NTHREADS];
for (int i = 0; i < NTHREADS; ++i) {
- ASSERT_EQ(0, bthread_start_urgent(&normal_threads[i], NULL, wait_thread, &ba));
+ ASSERT_EQ(0, bthread_start_urgent(&normal_threads[i], nullptr, wait_thread, &ba));
}
pthread_t pthreads[NTHREADS];
for (int i = 0; i < NTHREADS; ++i) {
- ASSERT_EQ(0, pthread_create(&pthreads[i], NULL,
+ ASSERT_EQ(0, pthread_create(&pthreads[i], nullptr,
wait_thread, &ba));
}
pthread_t broadcast;
pthread_t disturb;
- ASSERT_EQ(0, pthread_create(&broadcast, NULL, broadcast_thread, &ba));
- ASSERT_EQ(0, pthread_create(&disturb, NULL, disturb_thread, &ba));
+ ASSERT_EQ(0, pthread_create(&broadcast, nullptr, broadcast_thread, &ba));
+ ASSERT_EQ(0, pthread_create(&disturb, nullptr, disturb_thread, &ba));
for (int i = 0; i < NTHREADS; ++i) {
- bthread_join(normal_threads[i], NULL);
- pthread_join(pthreads[i], NULL);
+ bthread_join(normal_threads[i], nullptr);
+ pthread_join(pthreads[i], nullptr);
}
- pthread_join(broadcast, NULL);
- pthread_join(disturb, NULL);
+ pthread_join(broadcast, nullptr);
+ pthread_join(disturb, nullptr);
}
class BthreadCond {
public:
BthreadCond() {
- bthread_cond_init(&_cond, NULL);
- bthread_mutex_init(&_mutex, NULL);
+ bthread_cond_init(&_cond, nullptr);
+ bthread_mutex_init(&_mutex, nullptr);
_count = 1;
}
~BthreadCond() {
@@ -457,7 +457,7 @@ void* usleep_thread(void *) {
while (!g_stop) {
bthread_usleep(1000L * 1000L);
}
- return NULL;
+ return nullptr;
}
void* wait_cond_thread(void* arg) {
@@ -465,7 +465,7 @@ void* wait_cond_thread(void* arg) {
started_wait = true;
c->Wait();
ended_wait = true;
- return NULL;
+ return nullptr;
}
static void launch_many_bthreads() {
@@ -480,7 +480,7 @@ static void launch_many_bthreads() {
tm.start();
for (size_t i = 0; i < 32768; ++i) {
bthread_t t0;
- ASSERT_EQ(0, bthread_start_background(&t0, NULL, usleep_thread, NULL));
+ ASSERT_EQ(0, bthread_start_background(&t0, nullptr, usleep_thread, nullptr));
tids.push_back(t0);
}
tm.stop();
@@ -488,10 +488,10 @@ static void launch_many_bthreads() {
usleep(3 * 1000 * 1000L);
c.Signal();
g_stop = true;
- bthread_join(tid, NULL);
+ bthread_join(tid, nullptr);
for (size_t i = 0; i < tids.size(); ++i) {
LOG_EVERY_SECOND(INFO) << "Joined " << i << " threads";
- bthread_join(tids[i], NULL);
+ bthread_join(tids[i], nullptr);
}
LOG_EVERY_SECOND(INFO) << "Joined " << tids.size() << " threads";
}
@@ -503,14 +503,14 @@ TEST(CondTest, too_many_bthreads_from_pthread) {
static void* run_launch_many_bthreads(void*) {
launch_many_bthreads();
- return NULL;
+ return nullptr;
}
TEST(CondTest, too_many_bthreads_from_bthread) {
bthread_setconcurrency(16);
bthread_t th;
- ASSERT_EQ(0, bthread_start_urgent(&th, NULL, run_launch_many_bthreads, NULL));
- bthread_join(th, NULL);
+ ASSERT_EQ(0, bthread_start_urgent(&th, nullptr, run_launch_many_bthreads, nullptr));
+ bthread_join(th, nullptr);
}
#endif // BUTIL_USE_ASAN
} // namespace
diff --git a/test/bthread_countdown_event_unittest.cpp b/test/bthread_countdown_event_unittest.cpp
index bed8f17e..f6fa5f1e 100644
--- a/test/bthread_countdown_event_unittest.cpp
+++ b/test/bthread_countdown_event_unittest.cpp
@@ -32,7 +32,7 @@ void *signaler(void *arg) {
Arg* a = (Arg*)arg;
a->num_sig.fetch_sub(1, butil::memory_order_relaxed);
a->event.signal();
- return NULL;
+ return nullptr;
}
TEST(CountdonwEventTest, sanity) {
@@ -43,14 +43,14 @@ TEST(CountdonwEventTest, sanity) {
a.event.reset(n);
for (int i = 0; i < n; ++i) {
bthread_t tid;
- ASSERT_EQ(0, bthread_start_urgent(&tid, NULL, signaler, &a));
+ ASSERT_EQ(0, bthread_start_urgent(&tid, nullptr, signaler, &a));
tids.push_back(tid);
}
a.event.wait();
ASSERT_EQ(0, a.num_sig.load(butil::memory_order_relaxed));
}
for (size_t i = 0; i < tids.size(); ++i) {
- bthread_join(tids[i], NULL);
+ bthread_join(tids[i], nullptr);
}
}
diff --git a/test/bthread_dispatcher_unittest.cpp b/test/bthread_dispatcher_unittest.cpp
index 411c392e..0696df9a 100644
--- a/test/bthread_dispatcher_unittest.cpp
+++ b/test/bthread_dispatcher_unittest.cpp
@@ -86,11 +86,11 @@ void* process_thread(void* arg) {
continue;
} else {
PLOG(FATAL) << "Fail to read fd=" << m->fd;
- return NULL;
+ return nullptr;
}
} else {
LOG(FATAL) << "Another end closed fd=" << m->fd;
- return NULL;
+ return nullptr;
}
} while (1);
@@ -103,7 +103,7 @@ void* process_thread(void* arg) {
break;
}
} while (1);
- return NULL;
+ return nullptr;
}
void* epoll_thread(void* arg) {
@@ -126,7 +126,7 @@ void* epoll_thread(void* arg) {
}
#elif defined(OS_MACOSX)
timespec ts = { 0, 100L * 1000L * 1000L };
- const int n = kevent(em->epfd, NULL, 0, e, ARRAY_SIZE(e), &ts);
+ const int n = kevent(em->epfd, nullptr, 0, e, ARRAY_SIZE(e), &ts);
if (n == 0) {
continue;
}
@@ -162,7 +162,7 @@ void* epoll_thread(void* arg) {
}
}
}
- return NULL;
+ return nullptr;
}
void* client_thread(void* arg) {
@@ -190,7 +190,7 @@ void* client_thread(void* arg) {
if (n < 0) {
if (errno != EINTR) {
PLOG(FATAL) << "Fail to write fd=" << m->fd;
- return NULL;
+ return nullptr;
}
} else {
++m->times;
@@ -202,7 +202,7 @@ void* client_thread(void* arg) {
}
}
free(buf);
- return NULL;
+ return nullptr;
}
inline uint32_t fmix32 ( uint32_t h ) {
@@ -257,14 +257,14 @@ TEST(DispatcherTest, dispatch_tasks) {
#elif defined(OS_MACOSX)
struct kevent kqueue_event;
EV_SET(&kqueue_event, m->fd, EVFILT_READ, EV_ADD | EV_ENABLE | EV_CLEAR, 0, 0, m);
- ASSERT_EQ(0, kevent(m->epfd, &kqueue_event, 1, NULL, 0, NULL));
+ ASSERT_EQ(0, kevent(m->epfd, &kqueue_event, 1, nullptr, 0, nullptr));
#endif
cm[i] = new ClientMeta;
cm[i]->fd = fds[i * 2 + 1];
cm[i]->times = 0;
cm[i]->bytes = 0;
- ASSERT_EQ(0, pthread_create(&cth[i], NULL, client_thread, cm[i]));
+ ASSERT_EQ(0, pthread_create(&cth[i], nullptr, client_thread, cm[i]));
}
ProfilerStart("dispatcher.prof");
@@ -276,9 +276,9 @@ TEST(DispatcherTest, dispatch_tasks) {
em[i] = m;
m->epfd = epfd[i];
#ifdef RUN_EPOLL_IN_BTHREAD
- ASSERT_EQ(0, bthread_start_background(ð[i], NULL, epoll_thread, m));
+ ASSERT_EQ(0, bthread_start_background(ð[i], nullptr, epoll_thread, m));
#else
- ASSERT_EQ(0, pthread_create(ð[i], NULL, epoll_thread, m));
+ ASSERT_EQ(0, pthread_create(ð[i], nullptr, epoll_thread, m));
#endif
}
@@ -304,16 +304,16 @@ TEST(DispatcherTest, dispatch_tasks) {
client_stop = true;
for (size_t i = 0; i < NCLIENT; ++i) {
- pthread_join(cth[i], NULL);
+ pthread_join(cth[i], nullptr);
}
server_stop = true;
// epoll_thread polls server_stop with a finite timeout, so it exits on its
// own without needing an external fd to wake up epoll_wait.
for (size_t i = 0; i < NEPOLL; ++i) {
#ifdef RUN_EPOLL_IN_BTHREAD
- bthread_join(eth[i], NULL);
+ bthread_join(eth[i], nullptr);
#else
- pthread_join(eth[i], NULL);
+ pthread_join(eth[i], nullptr);
#endif
}
bthread::stop_and_join_epoll_threads();
diff --git a/test/bthread_execution_queue_unittest.cpp b/test/bthread_execution_queue_unittest.cpp
index 1baaa777..2e19a7b2 100644
--- a/test/bthread_execution_queue_unittest.cpp
+++ b/test/bthread_execution_queue_unittest.cpp
@@ -37,12 +37,12 @@ struct LongIntTask {
long value;
bthread::CountdownEvent* event;
LongIntTask(long v)
- : value(v), event(NULL)
+ : value(v), event(nullptr)
{}
LongIntTask(long v, bthread::CountdownEvent* e)
: value(v), event(e)
{}
- LongIntTask() : value(0), event(NULL) {}
+ LongIntTask() : value(0), event(nullptr) {}
};
int add(void* meta, bthread::TaskIterator<LongIntTask> &iter) {
@@ -166,7 +166,7 @@ void* push_thread(void *arg) {
timer.start();
int num = 0;
bthread::CountdownEvent e;
- LongIntTask t(num, pa->wait_task_completed ? &e : NULL);
+ LongIntTask t(num, pa->wait_task_completed ? &e : nullptr);
if (pa->wait_task_completed) {
e.reset(1);
}
@@ -182,7 +182,7 @@ void* push_thread(void *arg) {
pa->expected_value.fetch_add(sum, butil::memory_order_relaxed);
pa->total_num.fetch_add(num);
pa->total_time.fetch_add(timer.n_elapsed());
- return NULL;
+ return nullptr;
}
void* push_thread_which_addresses_execq(void *arg) {
@@ -203,7 +203,7 @@ void* push_thread_which_addresses_execq(void *arg) {
pa->expected_value.fetch_add(sum, butil::memory_order_relaxed);
pa->total_num.fetch_add(num);
pa->total_time.fetch_add(timer.n_elapsed());
- return NULL;
+ return nullptr;
}
void test_performance(bool use_pthread) {
@@ -227,12 +227,12 @@ void test_performance(bool use_pthread) {
pa.stopped = false;
ProfilerStart("execq.prof");
for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
- pthread_create(&threads[i], NULL, &push_thread_which_addresses_execq, &pa);
+ pthread_create(&threads[i], nullptr, &push_thread_which_addresses_execq, &pa);
}
usleep(500 * 1000);
ASSERT_EQ(0, bthread::execution_queue_stop(queue_id));
for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
- pthread_join(threads[i], NULL);
+ pthread_join(threads[i], nullptr);
}
ProfilerStop();
ASSERT_EQ(0, bthread::execution_queue_join(queue_id));
@@ -253,12 +253,12 @@ void test_performance(bool use_pthread) {
pa.stopped = false;
ProfilerStart("execq_id.prof");
for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
- pthread_create(&threads[i], NULL, &push_thread, &pa);
+ pthread_create(&threads[i], nullptr, &push_thread, &pa);
}
usleep(500 * 1000);
ASSERT_EQ(0, bthread::execution_queue_stop(queue_id));
for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
- pthread_join(threads[i], NULL);
+ pthread_join(threads[i], nullptr);
}
ProfilerStop();
ASSERT_EQ(0, bthread::execution_queue_join(queue_id));
@@ -335,7 +335,7 @@ void test_execute_urgent(bool use_pthread) {
pa.stopped = false;
pa.wait_task_completed = true;
for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
- pthread_create(&threads[i], NULL, &push_thread, &pa);
+ pthread_create(&threads[i], nullptr, &push_thread, &pa);
}
g_suspending = false;
usleep(1000);
@@ -354,7 +354,7 @@ void test_execute_urgent(bool use_pthread) {
pa.stopped = true;
ASSERT_EQ(0, bthread::execution_queue_stop(queue_id));
for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
- pthread_join(threads[i], NULL);
+ pthread_join(threads[i], nullptr);
}
LOG(INFO) << "result=" << result;
ASSERT_EQ(0, bthread::execution_queue_join(queue_id));
@@ -419,7 +419,7 @@ void* push_thread_with_id(void* arg) {
for (int i = 0; i < 100000; ++i) {
bthread::execution_queue_execute(id, ((long)thread_id << 32) | i);
}
- return NULL;
+ return nullptr;
}
int check_order(void* meta, bthread::TaskIterator<LongIntTask>& iter) {
@@ -451,10 +451,10 @@ void test_multi_threaded_order(bool use_pthread) {
check_order, &disorder_times));
pthread_t threads[12];
for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
- pthread_create(&threads[i], NULL, &push_thread_with_id, (void *)queue_id.value);
+ pthread_create(&threads[i], nullptr, &push_thread_with_id, (void *)queue_id.value);
}
for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
- pthread_join(threads[i], NULL);
+ pthread_join(threads[i], nullptr);
}
ASSERT_EQ(0, bthread::execution_queue_stop(queue_id));
ASSERT_EQ(0, bthread::execution_queue_join(queue_id));
@@ -513,7 +513,7 @@ void *run_first_tasks(void* arg) {
task.thread_id = pthread_self();
EXPECT_EQ(0, bthread::execution_queue_execute(
queue_id, task, &bthread::TASK_OPTIONS_INPLACE));
- return NULL;
+ return nullptr;
}
int stuck_and_check_running_thread(void* arg, bthread::TaskIterator<InPlaceTask>& iter) {
@@ -526,7 +526,7 @@ int stuck_and_check_running_thread(void* arg, bthread::TaskIterator<InPlaceTask>
futex->store(1);
bthread::futex_wake_private(futex, 1);
while (futex->load() != 2) {
- bthread::futex_wait_private(futex, 1, NULL);
+ bthread::futex_wait_private(futex, 1, nullptr);
}
++iter;
EXPECT_FALSE(iter);
@@ -553,9 +553,9 @@ void test_should_start_new_thread_on_more_tasks(bool use_pthread) {
stuck_and_check_running_thread,
(void*)&futex));
pthread_t thread;
- ASSERT_EQ(0, pthread_create(&thread, NULL, run_first_tasks, (void*)queue_id.value));
+ ASSERT_EQ(0, pthread_create(&thread, nullptr, run_first_tasks, (void*)queue_id.value));
while (futex.load() != 1) {
- bthread::futex_wait_private(&futex, 0, NULL);
+ bthread::futex_wait_private(&futex, 0, nullptr);
}
for (size_t i = 0; i < 100; ++i) {
InPlaceTask task;
@@ -584,7 +584,7 @@ void* inplace_push_thread(void* arg) {
bthread::execution_queue_execute(id, ((long)thread_id << 32) | i,
&bthread::TASK_OPTIONS_INPLACE);
}
- return NULL;
+ return nullptr;
}
void test_inplace_and_order(bool use_pthread) {
@@ -602,10 +602,10 @@ void test_inplace_and_order(bool use_pthread) {
check_order, &disorder_times));
pthread_t threads[12];
for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
- pthread_create(&threads[i], NULL, &inplace_push_thread, (void *)queue_id.value);
+ pthread_create(&threads[i], nullptr, &inplace_push_thread, (void *)queue_id.value);
}
for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
- pthread_join(threads[i], NULL);
+ pthread_join(threads[i], nullptr);
}
ASSERT_EQ(0, bthread::execution_queue_stop(queue_id));
ASSERT_EQ(0, bthread::execution_queue_join(queue_id));
@@ -657,14 +657,14 @@ void test_cancel(bool use_pthread) {
add_with_suspend2, &result));
g_suspending = false;
bthread::TaskHandle handle0;
- ASSERT_EQ(0, bthread::execution_queue_execute(queue_id, -100, NULL, &handle0));
+ ASSERT_EQ(0, bthread::execution_queue_execute(queue_id, -100, nullptr, &handle0));
while (!g_suspending) {
usleep(10);
}
ASSERT_EQ(1, bthread::execution_queue_cancel(handle0));
ASSERT_EQ(1, bthread::execution_queue_cancel(handle0));
bthread::TaskHandle handle1;
- ASSERT_EQ(0, bthread::execution_queue_execute(queue_id, 100, NULL, &handle1));
+ ASSERT_EQ(0, bthread::execution_queue_execute(queue_id, 100, nullptr, &handle1));
ASSERT_EQ(0, bthread::execution_queue_cancel(handle1));
g_suspending = false;
ASSERT_EQ(-1, bthread::execution_queue_cancel(handle1));
@@ -686,7 +686,7 @@ struct CancelSelf {
int cancel_self(void* /*meta*/, bthread::TaskIterator<CancelSelf*>& iter) {
for (; iter; ++iter) {
- while ((*iter)->handle == NULL) {
+ while ((*iter)->handle == nullptr) {
usleep(10);
}
EXPECT_EQ(1, bthread::execution_queue_cancel(*(*iter)->handle.load()));
@@ -706,11 +706,11 @@ void test_cancel_self(bool use_pthread) {
LOG(INFO) << "================ bthread ================";
}
ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, &options,
- cancel_self, NULL));
+ cancel_self, nullptr));
CancelSelf task;
- task.handle = NULL;
+ task.handle = nullptr;
bthread::TaskHandle handle;
- ASSERT_EQ(0, bthread::execution_queue_execute(queue_id, &task, NULL, &handle));
+ ASSERT_EQ(0, bthread::execution_queue_execute(queue_id, &task, nullptr, &handle));
task.handle.store(&handle);
ASSERT_EQ(0, bthread::execution_queue_stop(queue_id));
ASSERT_EQ(0, bthread::execution_queue_join(queue_id));
@@ -768,7 +768,7 @@ void test_random_cancel(bool use_pthread) {
m.succ_times.store(0);
m.fail_times.store(0);
m.race_times.store(0);
- ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, NULL,
+ ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, nullptr,
add_with_cancel, &m));
int64_t expected = 0;
for (int i = 0; i < 100000; ++i) {
@@ -776,7 +776,7 @@ void test_random_cancel(bool use_pthread) {
AddTask t;
t.value = i;
t.cancel_task = false;
- ASSERT_EQ(0, bthread::execution_queue_execute(queue_id, t, NULL, &h));
+ ASSERT_EQ(0, bthread::execution_queue_execute(queue_id, t, nullptr, &h));
const int r = butil::fast_rand_less_than(4);
expected += i;
if (r == 0) {
@@ -787,7 +787,7 @@ void test_random_cancel(bool use_pthread) {
t.cancel_task = true;
t.cancel_value = i;
t.handle = h;
- ASSERT_EQ(0, bthread::execution_queue_execute(queue_id, t, NULL));
+ ASSERT_EQ(0, bthread::execution_queue_execute(queue_id, t, nullptr));
} else if (r == 2) {
t.cancel_task = true;
t.cancel_value = i;
diff --git a/test/bthread_fd_unittest.cpp b/test/bthread_fd_unittest.cpp
index 1f68ffc4..02c579c1 100644
--- a/test/bthread_fd_unittest.cpp
+++ b/test/bthread_fd_unittest.cpp
@@ -92,13 +92,13 @@ void* process_thread(void* arg) {
ssize_t n = read(m->fd, &count, sizeof(count));
if (n != sizeof(count)) {
LOG(FATAL) << "Should not happen in this test";
- return NULL;
+ return nullptr;
}
count += NCLIENT;
//printf("write result=%lu to fd=%d\n", count, m->fd);
if (write(m->fd, &count, sizeof(count)) != sizeof(count)) {
LOG(FATAL) << "Should not happen in this test";
- return NULL;
+ return nullptr;
}
#ifdef CREATE_THREAD_TO_PROCESS
# if defined(OS_LINUX)
@@ -110,10 +110,10 @@ void* process_thread(void* arg) {
struct kevent kqueue_event;
EV_SET(&kqueue_event, m->fd, EVFILT_READ, EV_ADD | EV_ENABLE | EV_ONESHOT,
0, 0, m);
- kevent(m->epfd, &kqueue_event, 1, NULL, 0, NULL);
+ kevent(m->epfd, &kqueue_event, 1, nullptr, 0, nullptr);
# endif
#endif
- return NULL;
+ return nullptr;
}
void* epoll_thread(void* arg) {
@@ -148,7 +148,7 @@ void* epoll_thread(void* arg) {
}
# endif
#elif defined(OS_MACOSX)
- const int n = kevent(epfd, NULL, 0, e, ARRAY_SIZE(e), NULL);
+ const int n = kevent(epfd, nullptr, 0, e, ARRAY_SIZE(e), nullptr);
if (stop) {
break;
}
@@ -190,7 +190,7 @@ void* epoll_thread(void* arg) {
}
#endif
}
- return NULL;
+ return nullptr;
}
void* client_thread(void* arg) {
@@ -198,7 +198,7 @@ void* client_thread(void* arg) {
for (size_t i = 0; i < m->times; ++i) {
if (write(m->fd, &m->count, sizeof(m->count)) != sizeof(m->count)) {
LOG(FATAL) << "Should not happen in this test";
- return NULL;
+ return nullptr;
}
#ifdef RUN_CLIENT_IN_BTHREAD
ssize_t rc;
@@ -216,10 +216,10 @@ void* client_thread(void* arg) {
#endif
if (rc != sizeof(m->count)) {
PLOG(FATAL) << "Should not happen in this test, rc=" << rc;
- return NULL;
+ return nullptr;
}
}
- return NULL;
+ return nullptr;
}
inline uint32_t fmix32 ( uint32_t h ) {
@@ -295,7 +295,7 @@ TEST(FDTest, ping_pong) {
#if defined(OS_LINUX)
ASSERT_EQ(0, epoll_ctl(m->epfd, EPOLL_CTL_ADD, m->fd, &evt));
#elif defined(OS_MACOSX)
- ASSERT_EQ(0, kevent(m->epfd, &kqueue_event, 1, NULL, 0, NULL));
+ ASSERT_EQ(0, kevent(m->epfd, &kqueue_event, 1, nullptr, 0, nullptr));
#endif
cm[i].reset(new ClientMeta);
cm[i]->fd = fds[i * 2 + 1];
@@ -303,9 +303,9 @@ TEST(FDTest, ping_pong) {
cm[i]->times = REP;
#ifdef RUN_CLIENT_IN_BTHREAD
butil::make_non_blocking(cm[i]->fd);
- ASSERT_EQ(0, bthread_start_urgent(&cth[i], NULL, client_thread, cm[i].get()));
+ ASSERT_EQ(0, bthread_start_urgent(&cth[i], nullptr, client_thread, cm[i].get()));
#else
- ASSERT_EQ(0, pthread_create(&cth[i], NULL, client_thread, cm[i].get()));
+ ASSERT_EQ(0, pthread_create(&cth[i], nullptr, client_thread, cm[i].get()));
#endif
}
@@ -318,17 +318,17 @@ TEST(FDTest, ping_pong) {
EpollMeta* em = em_arr[i].get();
em->epfd = epfd[i];
#ifdef RUN_EPOLL_IN_BTHREAD
- ASSERT_EQ(0, bthread_start_urgent(ð[i], epoll_thread, em, NULL);
+ ASSERT_EQ(0, bthread_start_urgent(ð[i], epoll_thread, em, nullptr);
#else
- ASSERT_EQ(0, pthread_create(ð[i], NULL, epoll_thread, em));
+ ASSERT_EQ(0, pthread_create(ð[i], nullptr, epoll_thread, em));
#endif
}
for (size_t i = 0; i < NCLIENT; ++i) {
#ifdef RUN_CLIENT_IN_BTHREAD
- bthread_join(cth[i], NULL);
+ bthread_join(cth[i], nullptr);
#else
- pthread_join(cth[i], NULL);
+ pthread_join(cth[i], nullptr);
#endif
ASSERT_EQ(i + REP * NCLIENT, cm[i]->count);
}
@@ -338,17 +338,17 @@ TEST(FDTest, ping_pong) {
stop = true;
for (size_t i = 0; i < NEPOLL; ++i) {
#if defined(OS_LINUX)
- epoll_event evt = { EPOLLOUT, { NULL } };
+ epoll_event evt = { EPOLLOUT, { nullptr } };
ASSERT_EQ(0, epoll_ctl(epfd[i], EPOLL_CTL_ADD, 0, &evt));
#elif defined(OS_MACOSX)
struct kevent kqueue_event;
- EV_SET(&kqueue_event, 0, EVFILT_WRITE, EV_ADD | EV_ENABLE, 0, 0, NULL);
- ASSERT_EQ(0, kevent(epfd[i], &kqueue_event, 1, NULL, 0, NULL));
+ EV_SET(&kqueue_event, 0, EVFILT_WRITE, EV_ADD | EV_ENABLE, 0, 0, nullptr);
+ ASSERT_EQ(0, kevent(epfd[i], &kqueue_event, 1, nullptr, 0, nullptr));
#endif
#ifdef RUN_EPOLL_IN_BTHREAD
- bthread_join(eth[i], NULL);
+ bthread_join(eth[i], nullptr);
#else
- pthread_join(eth[i], NULL);
+ pthread_join(eth[i], nullptr);
#endif
}
//bthread::stop_and_join_epoll_threads();
@@ -371,7 +371,7 @@ TEST(FDTest, mod_closed_fd) {
int new_fd[2];
int fd[2];
ASSERT_EQ(0, pipe(fd));
- epoll_event e = { EPOLLIN, { NULL } };
+ epoll_event e = { EPOLLIN, { nullptr } };
errno = 0;
ASSERT_EQ(-1, epoll_ctl(epfd, EPOLL_CTL_MOD, fd[0], &e));
ASSERT_EQ(ENOENT, errno);
@@ -402,7 +402,7 @@ TEST(FDTest, mod_closed_fd) {
TEST(FDTest, add_existing_fd) {
#if defined(OS_LINUX)
const int epfd = epoll_create(1024);
- epoll_event e = { EPOLLIN, { NULL } };
+ epoll_event e = { EPOLLIN, { nullptr } };
ASSERT_EQ(0, epoll_ctl(epfd, EPOLL_CTL_ADD, 0, &e));
errno = 0;
ASSERT_EQ(-1, epoll_ctl(epfd, EPOLL_CTL_ADD, 0, &e));
@@ -419,12 +419,12 @@ void* epoll_waiter(void* arg) {
}
#elif defined(OS_MACOSX)
struct kevent e;
- if (1 == kevent((int)(intptr_t)arg, NULL, 0, &e, 1, NULL)) {
+ if (1 == kevent((int)(intptr_t)arg, nullptr, 0, &e, 1, nullptr)) {
std::cout << e.flags << std::endl;
}
#endif
std::cout << pthread_self() << " quits" << std::endl;
- return NULL;
+ return nullptr;
}
TEST(FDTest, interrupt_pthread) {
@@ -434,22 +434,22 @@ TEST(FDTest, interrupt_pthread) {
const int epfd = kqueue();
#endif
pthread_t th, th2;
- ASSERT_EQ(0, pthread_create(&th, NULL, epoll_waiter, (void*)(intptr_t)epfd));
- ASSERT_EQ(0, pthread_create(&th2, NULL, epoll_waiter, (void*)(intptr_t)epfd));
+ ASSERT_EQ(0, pthread_create(&th, nullptr, epoll_waiter, (void*)(intptr_t)epfd));
+ ASSERT_EQ(0, pthread_create(&th2, nullptr, epoll_waiter, (void*)(intptr_t)epfd));
bthread_usleep(100000L);
std::cout << "wake up " << th << std::endl;
bthread::interrupt_pthread(th);
bthread_usleep(100000L);
std::cout << "wake up " << th2 << std::endl;
bthread::interrupt_pthread(th2);
- pthread_join(th, NULL);
- pthread_join(th2, NULL);
+ pthread_join(th, nullptr);
+ pthread_join(th2, nullptr);
}
void* close_the_fd(void* arg) {
bthread_usleep(10000/*10ms*/);
EXPECT_EQ(0, bthread_close(*(int*)arg));
- return NULL;
+ return nullptr;
}
TEST(FDTest, invalid_epoll_events) {
@@ -462,9 +462,9 @@ TEST(FDTest, invalid_epoll_events) {
ASSERT_EQ(EINVAL, errno);
errno = 0;
#if defined(OS_LINUX)
- ASSERT_EQ(-1, bthread_fd_timedwait(-1, EPOLLIN, NULL));
+ ASSERT_EQ(-1, bthread_fd_timedwait(-1, EPOLLIN, nullptr));
#elif defined(OS_MACOSX)
- ASSERT_EQ(-1, bthread_fd_timedwait(-1, EVFILT_READ, NULL));
+ ASSERT_EQ(-1, bthread_fd_timedwait(-1, EVFILT_READ, nullptr));
#endif
ASSERT_EQ(EINVAL, errno);
@@ -475,7 +475,7 @@ TEST(FDTest, invalid_epoll_events) {
ASSERT_EQ(EINVAL, errno);
#endif
bthread_t th;
- ASSERT_EQ(0, bthread_start_urgent(&th, NULL, close_the_fd, &fds[1]));
+ ASSERT_EQ(0, bthread_start_urgent(&th, nullptr, close_the_fd, &fds[1]));
butil::Timer tm;
tm.start();
#if defined(OS_LINUX)
@@ -485,7 +485,7 @@ TEST(FDTest, invalid_epoll_events) {
#endif
tm.stop();
ASSERT_LT(tm.m_elapsed(), 20);
- ASSERT_EQ(0, bthread_join(th, NULL));
+ ASSERT_EQ(0, bthread_join(th, nullptr));
ASSERT_EQ(0, bthread_close(fds[0]));
}
@@ -496,20 +496,20 @@ void* wait_for_the_fd(void* arg) {
#elif defined(OS_MACOSX)
bthread_fd_timedwait(*(int*)arg, EVFILT_READ, &ts);
#endif
- return NULL;
+ return nullptr;
}
TEST(FDTest, timeout) {
int fds[2];
ASSERT_EQ(0, pipe(fds));
pthread_t th;
- ASSERT_EQ(0, pthread_create(&th, NULL, wait_for_the_fd, &fds[0]));
+ ASSERT_EQ(0, pthread_create(&th, nullptr, wait_for_the_fd, &fds[0]));
bthread_t bth;
- ASSERT_EQ(0, bthread_start_urgent(&bth, NULL, wait_for_the_fd, &fds[0]));
+ ASSERT_EQ(0, bthread_start_urgent(&bth, nullptr, wait_for_the_fd, &fds[0]));
butil::Timer tm;
tm.start();
- ASSERT_EQ(0, pthread_join(th, NULL));
- ASSERT_EQ(0, bthread_join(bth, NULL));
+ ASSERT_EQ(0, pthread_join(th, nullptr));
+ ASSERT_EQ(0, bthread_join(bth, nullptr));
tm.stop();
ASSERT_LT(tm.m_elapsed(), 80);
ASSERT_EQ(0, bthread_close(fds[0]));
@@ -520,19 +520,19 @@ TEST(FDTest, close_should_wakeup_waiter) {
int fds[2];
ASSERT_EQ(0, pipe(fds));
bthread_t bth;
- ASSERT_EQ(0, bthread_start_urgent(&bth, NULL, wait_for_the_fd, &fds[0]));
+ ASSERT_EQ(0, bthread_start_urgent(&bth, nullptr, wait_for_the_fd, &fds[0]));
butil::Timer tm;
tm.start();
ASSERT_EQ(0, bthread_close(fds[0]));
- ASSERT_EQ(0, bthread_join(bth, NULL));
+ ASSERT_EQ(0, bthread_join(bth, nullptr));
tm.stop();
ASSERT_LT(tm.m_elapsed(), 5);
// Launch again, should quit soon due to EBADF
#if defined(OS_LINUX)
- ASSERT_EQ(-1, bthread_fd_timedwait(fds[0], EPOLLIN, NULL));
+ ASSERT_EQ(-1, bthread_fd_timedwait(fds[0], EPOLLIN, nullptr));
#elif defined(OS_MACOSX)
- ASSERT_EQ(-1, bthread_fd_timedwait(fds[0], EVFILT_READ, NULL));
+ ASSERT_EQ(-1, bthread_fd_timedwait(fds[0], EVFILT_READ, nullptr));
#endif
ASSERT_EQ(EBADF, errno);
@@ -617,7 +617,7 @@ void TestConnectInterruptImpl(bool timed) {
... 5672 lines suppressed ...
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org