using namespace std;
-AccessLogThread *access_log = NULL;
-ServerPool *servers = NULL;
+AccessLogThread *access_log = nullptr;
+ServerPool *servers = nullptr;
volatile bool hupped = false;
volatile bool stopped = false;
{
vector<Acceptor *> acceptors;
for (const AcceptorConfig &acceptor_config : config.acceptors) {
- Acceptor *acceptor = NULL;
+ Acceptor *acceptor = nullptr;
const auto deserialized_acceptor_it = deserialized_acceptors->find(acceptor_config);
if (deserialized_acceptor_it != deserialized_acceptors->end()) {
acceptor = deserialized_acceptor_it->second;
InputWithRefcount iwr;
iwr.input = create_input(src, encoding);
- if (iwr.input == NULL) {
+ if (iwr.input == nullptr) {
log(ERROR, "did not understand URL '%s' or source encoding was invalid, clients will not get any data.",
src.c_str());
return;
return false;
case 0:
// Child.
- execlp(argv0_copy, argv0_copy, "--test-config", config_filename_copy, NULL);
+ execlp(argv0_copy, argv0_copy, "--test-config", config_filename_copy, nullptr);
log_perror(argv0_copy);
_exit(1);
default:
char argv0_canon[PATH_MAX];
char config_filename_canon[PATH_MAX];
- if (realpath("/proc/self/exe", argv0_canon) == NULL) {
+ if (realpath("/proc/self/exe", argv0_canon) == nullptr) {
log_perror(argv[0]);
exit(1);
}
- if (realpath(config_filename.c_str(), config_filename_canon) == NULL) {
+ if (realpath(config_filename.c_str(), config_filename_canon) == nullptr) {
log_perror(config_filename.c_str());
exit(1);
}
}
// Start writing statistics.
- StatsThread *stats_thread = NULL;
+ unique_ptr<StatsThread> stats_thread;
if (!config.stats_file.empty()) {
- stats_thread = new StatsThread(config.stats_file, config.stats_interval);
+ stats_thread.reset(new StatsThread(config.stats_file, config.stats_interval));
stats_thread->run();
}
- InputStatsThread *input_stats_thread = NULL;
+ unique_ptr<InputStatsThread> input_stats_thread;
if (!config.input_stats_file.empty()) {
vector<Input*> inputs_no_refcount;
for (const auto &key_and_input_with_refcount : inputs) {
inputs_no_refcount.push_back(key_and_input_with_refcount.second.input);
}
- input_stats_thread = new InputStatsThread(config.input_stats_file, config.input_stats_interval, inputs_no_refcount);
+ input_stats_thread.reset(new InputStatsThread(config.input_stats_file, config.input_stats_interval, inputs_no_refcount));
input_stats_thread->run();
}
err = clock_gettime(CLOCK_MONOTONIC, &serialize_start);
assert(err != -1);
- if (input_stats_thread != NULL) {
+ if (input_stats_thread != nullptr) {
input_stats_thread->stop();
- delete input_stats_thread;
+ input_stats_thread.reset();
}
- if (stats_thread != NULL) {
+ if (stats_thread != nullptr) {
stats_thread->stop();
- delete stats_thread;
+ stats_thread.reset();
}
for (Acceptor *acceptor : acceptors) {
acceptor->stop();
sprintf(buf, "%d", state_fd);
for ( ;; ) {
- execlp(argv0_canon, argv0_canon, config_filename_canon, "--state", buf, NULL);
+ execlp(argv0_canon, argv0_canon, config_filename_canon, "--state", buf, nullptr);
open_logs(config.log_destinations);
log_perror("execlp");
log(ERROR, "re-exec of %s failed. Waiting 0.2 seconds and trying again...", argv0_canon);