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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions tools/parallel_http/parallel_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ void* access_thread(void* void_args) {
done->cntl.http_request().uri() = url;
done->args = args;
done->url = url;
channel.CallMethod(NULL, &done->cntl, NULL, NULL, done);
channel.CallMethod(nullptr, &done->cntl, nullptr, nullptr, done);
}
return NULL;
return nullptr;
}

int main(int argc, char** argv) {
Expand All @@ -106,7 +106,7 @@ int main(int argc, char** argv) {
// }

butil::ScopedFILE fp_guard;
FILE* fp = NULL;
FILE* fp = nullptr;
if (!FLAGS_url_file.empty()) {
fp_guard.reset(fopen(FLAGS_url_file.c_str(), "r"));
if (!fp_guard) {
Expand All @@ -117,7 +117,7 @@ int main(int argc, char** argv) {
} else {
fp = stdin;
}
char* line_buf = NULL;
char* line_buf = nullptr;
size_t line_len = 0;
ssize_t nr = 0;
std::deque<std::string> url_list;
Expand All @@ -144,7 +144,7 @@ int main(int argc, char** argv) {
std::vector<bthread_t> tids;
tids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
CHECK_EQ(0, bthread_start_background(&tids[i], NULL, access_thread, &args[i]));
CHECK_EQ(0, bthread_start_background(&tids[i], nullptr, access_thread, &args[i]));
}
std::deque<std::pair<std::string, butil::IOBuf> > output_queue;
size_t nprinted = 0;
Expand Down Expand Up @@ -200,7 +200,7 @@ int main(int argc, char** argv) {
}

for (int i = 0; i < FLAGS_thread_num; ++i) {
bthread_join(tids[i], NULL);
bthread_join(tids[i], nullptr);
}
for (int i = 0; i < FLAGS_thread_num; ++i) {
while (args[i].current_concurrency.load(butil::memory_order_relaxed) != 0) {
Expand Down
16 changes: 8 additions & 8 deletions tools/rpc_press/info_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ namespace brpc {
InfoThread::InfoThread()
: _stop(false)
, _tid(0) {
pthread_mutex_init(&_mutex, NULL);
pthread_cond_init(&_cond, NULL);
pthread_mutex_init(&_mutex, nullptr);
pthread_cond_init(&_cond, nullptr);
}

InfoThread::~InfoThread() {
Expand Down Expand Up @@ -96,19 +96,19 @@ void InfoThread::run() {

static void* run_info_thread(void* arg) {
((InfoThread*)arg)->run();
return NULL;
return nullptr;
}

bool InfoThread::start(const InfoThreadOptions& options) {
if (options.latency_recorder == NULL ||
options.error_count == NULL ||
options.sent_count == NULL) {
if (options.latency_recorder == nullptr ||
options.error_count == nullptr ||
options.sent_count == nullptr) {
LOG(ERROR) << "Some required options are NULL";
return false;
}
_options = options;
_stop = false;
if (pthread_create(&_tid, NULL, run_info_thread, this) != 0) {
if (pthread_create(&_tid, nullptr, run_info_thread, this) != 0) {
LOG(ERROR) << "Fail to create info_thread";
return false;
}
Expand All @@ -124,7 +124,7 @@ void InfoThread::stop() {
_stop = true;
pthread_cond_signal(&_cond);
}
pthread_join(_tid, NULL);
pthread_join(_tid, nullptr);
}

} // namespace brpc
6 changes: 3 additions & 3 deletions tools/rpc_press/info_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ struct InfoThreadOptions {
bvar::Adder<int64_t>* error_count;

InfoThreadOptions()
: latency_recorder(NULL)
, sent_count(NULL)
, error_count(NULL) {}
: latency_recorder(nullptr)
, sent_count(nullptr)
, error_count(nullptr) {}
};

class InfoThread {
Expand Down
4 changes: 2 additions & 2 deletions tools/rpc_press/json_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ bool JsonLoader::Reader::read_some() {
// Ignore json only with spaces and newline
static bool possibly_valid_json(const butil::IOBuf& json) {
butil::IOBufAsZeroCopyInputStream it(json);
const void* data = NULL;
const void* data = nullptr;
for (int size = 0; it.Next(&data, &size); ) {
for (int i = 0; i < size; ++i) {
char c = ((const char*)data)[i];
Expand All @@ -97,7 +97,7 @@ bool JsonLoader::Reader::get_next_json(butil::IOBuf* json1) {
json1->clear();
while (1) {
butil::IOBufAsZeroCopyInputStream it(_file_buf);
const void* data = NULL;
const void* data = nullptr;
int size = 0;
int total_size = 0;
int skipped = 0;
Expand Down
10 changes: 5 additions & 5 deletions tools/rpc_press/pb_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ const MethodDescriptor* find_method_by_name(const string& service_name,
Importer* importer) {
const ServiceDescriptor* descriptor =
importer->pool()->FindServiceByName(service_name);
if (NULL == descriptor) {
if (nullptr == descriptor) {
LOG(FATAL) << "Fail to find service=" << service_name;
return NULL;
return nullptr;
}
return descriptor->FindMethodByName(method_name);
}
Expand All @@ -47,11 +47,11 @@ const Message* get_prototype_by_method_descriptor(
const MethodDescriptor* descripter,
bool is_input,
DynamicMessageFactory* factory) {
if (NULL == descripter) {
if (nullptr == descripter) {
LOG(FATAL) <<"Param[descripter] is NULL";
return NULL;
return nullptr;
}
const Descriptor* message_descriptor = NULL;
const Descriptor* message_descriptor = nullptr;
if (is_input) {
message_descriptor = descripter->input_type();
} else {
Expand Down
18 changes: 9 additions & 9 deletions tools/rpc_press/rpc_press_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int PressClient::init() {
}
_method_descriptor = find_method_by_name(
_options->service, _options->method, _importer);
if (NULL == _method_descriptor) {
if (nullptr == _method_descriptor) {
LOG(ERROR) << "Fail to find method=" << _options->service << '.'
<< _options->method;
return -1;
Expand All @@ -92,22 +92,22 @@ void PressClient::call_method(brpc::Controller* cntl, Message* request,
}

RpcPress::RpcPress()
: _pbrpc_client(NULL)
: _pbrpc_client(nullptr)
, _started(false)
, _stop(false)
, _output_json(NULL) {
, _output_json(nullptr) {
}

RpcPress::~RpcPress() {
if (_output_json) {
fclose(_output_json);
_output_json = NULL;
_output_json = nullptr;
}
delete _importer;
}

int RpcPress::init(const PressOptions* options) {
if (NULL == options) {
if (nullptr == options) {
LOG(ERROR) << "Param[options] is NULL" ;
return -1;
}
Expand All @@ -133,7 +133,7 @@ int RpcPress::init(const PressOptions* options) {
}
ImportErrorPrinter error_printer;
_importer = new google::protobuf::compiler::Importer(&sourceTree, &error_printer);
if (_importer->Import(proto_file.c_str()) == NULL) {
if (_importer->Import(proto_file.c_str()) == nullptr) {
LOG(ERROR) << "Fail to import " << proto_file;
return -1;
}
Expand Down Expand Up @@ -187,7 +187,7 @@ int RpcPress::init(const PressOptions* options) {

void* RpcPress::sync_call_thread(void* arg) {
((RpcPress*)arg)->sync_client();
return NULL;
return nullptr;
}

void RpcPress::handle_response(brpc::Controller* cntl,
Expand Down Expand Up @@ -267,7 +267,7 @@ int RpcPress::start() {
_ttid.resize(_options.test_thread_num);
int ret = 0;
for (int i = 0; i < _options.test_thread_num; i++) {
if ((ret = pthread_create(&_ttid[i], NULL, sync_call_thread, this)) != 0) {
if ((ret = pthread_create(&_ttid[i], nullptr, sync_call_thread, this)) != 0) {
LOG(ERROR) << "Fail to create sending threads";
return -1;
}
Expand All @@ -289,7 +289,7 @@ int RpcPress::stop() {
}
_stop = true;
for (size_t i = 0; i < _ttid.size(); i++) {
pthread_join(_ttid[i], NULL);
pthread_join(_ttid[i], nullptr);
}
_info_thr.stop();
return 0;
Expand Down
4 changes: 2 additions & 2 deletions tools/rpc_press/rpc_press_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ class PressClient {
PressClient(const PressOptions* options,
google::protobuf::compiler::Importer* importer,
google::protobuf::DynamicMessageFactory* factory) {
_method_descriptor = NULL;
_response_prototype = NULL;
_method_descriptor = nullptr;
_response_prototype = nullptr;
_options = options;
_importer = importer;
_factory = factory;
Expand Down
16 changes: 8 additions & 8 deletions tools/rpc_replay/info_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ namespace brpc {
InfoThread::InfoThread()
: _stop(false)
, _tid(0) {
pthread_mutex_init(&_mutex, NULL);
pthread_cond_init(&_cond, NULL);
pthread_mutex_init(&_mutex, nullptr);
pthread_cond_init(&_cond, nullptr);
}

InfoThread::~InfoThread() {
Expand Down Expand Up @@ -96,19 +96,19 @@ void InfoThread::run() {

static void* run_info_thread(void* arg) {
((InfoThread*)arg)->run();
return NULL;
return nullptr;
}

bool InfoThread::start(const InfoThreadOptions& options) {
if (options.latency_recorder == NULL ||
options.error_count == NULL ||
options.sent_count == NULL) {
if (options.latency_recorder == nullptr ||
options.error_count == nullptr ||
options.sent_count == nullptr) {
LOG(ERROR) << "Some required options are NULL";
return false;
}
_options = options;
_stop = false;
if (pthread_create(&_tid, NULL, run_info_thread, this) != 0) {
if (pthread_create(&_tid, nullptr, run_info_thread, this) != 0) {
LOG(ERROR) << "Fail to create info_thread";
return false;
}
Expand All @@ -124,7 +124,7 @@ void InfoThread::stop() {
_stop = true;
pthread_cond_signal(&_cond);
}
pthread_join(_tid, NULL);
pthread_join(_tid, nullptr);
}

} // brpc
6 changes: 3 additions & 3 deletions tools/rpc_replay/info_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ struct InfoThreadOptions {
bvar::Adder<int64_t>* error_count;

InfoThreadOptions()
: latency_recorder(NULL)
, sent_count(NULL)
, error_count(NULL) {}
: latency_recorder(nullptr)
, sent_count(nullptr)
, error_count(nullptr) {}
};

class InfoThread {
Expand Down
26 changes: 13 additions & 13 deletions tools/rpc_replay/rpc_replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ChannelGroup {
if ((size_t)type < _chans.size()) {
return _chans[(size_t)type];
}
return NULL;
return nullptr;
}

private:
Expand Down Expand Up @@ -148,14 +148,14 @@ static void* replay_thread(void* arg) {
brpc::SampleIterator it(FLAGS_dir);
int j = 0;
for (brpc::SampledRequest* sample = it.Next();
!brpc::IsAskedToQuit() && sample != NULL; sample = it.Next(), ++j) {
!brpc::IsAskedToQuit() && sample != nullptr; sample = it.Next(), ++j) {
std::unique_ptr<brpc::SampledRequest> sample_guard(sample);
if ((j % FLAGS_thread_num) != thread_offset) {
continue;
}
brpc::Channel* chan =
chan_group->channel(sample->meta.protocol_type());
if (chan == NULL) {
if (chan == nullptr) {
LOG(ERROR) << "No channel on protocol="
<< sample->meta.protocol_type();
continue;
Expand All @@ -175,7 +175,7 @@ static void* replay_thread(void* arg) {
cntl->http_request().SetHeader("Host", FLAGS_http_host);
}
cntl->request_attachment() = http_message.body().movable();
req_ptr = NULL;
req_ptr = nullptr;
} else if (sample->meta.protocol_type() == brpc::PROTOCOL_NSHEAD) {
nshead_req.Clear();
memcpy(&nshead_req.head, sample->meta.nshead().c_str(), sample->meta.nshead().length());
Expand All @@ -192,14 +192,14 @@ static void* replay_thread(void* arg) {
g_sent_count << 1;
const int64_t start_time = butil::cpuwide_time_us();
if (FLAGS_qps <= 0) {
chan->CallMethod(NULL/*use rpc_dump_context in cntl instead*/,
cntl, req_ptr, NULL/*ignore response*/, NULL);
chan->CallMethod(nullptr/*use rpc_dump_context in cntl instead*/,
cntl, req_ptr, nullptr/*ignore response*/, nullptr);
handle_response(cntl, start_time, true);
} else {
google::protobuf::Closure* done =
brpc::NewCallback(handle_response, cntl, start_time, false);
chan->CallMethod(NULL/*use rpc_dump_context in cntl instead*/,
cntl, req_ptr, NULL/*ignore response*/, done);
chan->CallMethod(nullptr/*use rpc_dump_context in cntl instead*/,
cntl, req_ptr, nullptr/*ignore response*/, done);
int64_t end_time = butil::monotonic_time_ns();
int64_t expected_time = last_expected_time + interval;
if (end_time < expected_time) {
Expand All @@ -212,7 +212,7 @@ static void* replay_thread(void* arg) {
}
}
}
return NULL;
return nullptr;
}

int main(int argc, char* argv[]) {
Expand Down Expand Up @@ -262,7 +262,7 @@ int main(int argc, char* argv[]) {
if (!FLAGS_use_bthread) {
pids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create(&pids[i], NULL, replay_thread, &chan_group) != 0) {
if (pthread_create(&pids[i], nullptr, replay_thread, &chan_group) != 0) {
LOG(ERROR) << "Fail to create pthread";
return -1;
}
Expand All @@ -271,7 +271,7 @@ int main(int argc, char* argv[]) {
bids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (bthread_start_background(
&bids[i], NULL, replay_thread, &chan_group) != 0) {
&bids[i], nullptr, replay_thread, &chan_group) != 0) {
LOG(ERROR) << "Fail to create bthread";
return -1;
}
Expand All @@ -290,9 +290,9 @@ int main(int argc, char* argv[]) {

for (int i = 0; i < FLAGS_thread_num; ++i) {
if (!FLAGS_use_bthread) {
pthread_join(pids[i], NULL);
pthread_join(pids[i], nullptr);
} else {
bthread_join(bids[i], NULL);
bthread_join(bids[i], nullptr);
}
}
info_thr.stop();
Expand Down
2 changes: 1 addition & 1 deletion tools/rpc_view/rpc_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class ViewServiceImpl : public ViewService {
// Keep content as it is.
client_cntl->request_attachment() = server_cntl->request_attachment();

http_chan.CallMethod(NULL, client_cntl, NULL, NULL,
http_chan.CallMethod(nullptr, client_cntl, nullptr, nullptr,
brpc::NewCallback(
handle_response, client_cntl, target,
server_cntl, done_guard.release()));
Expand Down
Loading
Loading