Loading cmds/statsd/src/StatsLogProcessor.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -39,7 +39,8 @@ enum DumpReportReason { GET_DATA_CALLED = 4, GET_DATA_CALLED = 4, ADB_DUMP = 5, ADB_DUMP = 5, CONFIG_RESET = 6, CONFIG_RESET = 6, STATSCOMPANION_DIED = 7 STATSCOMPANION_DIED = 7, TERMINATION_SIGNAL_RECEIVED = 8 }; }; class StatsLogProcessor : public ConfigListener { class StatsLogProcessor : public ConfigListener { Loading cmds/statsd/src/StatsService.cpp +7 −0 Original line number Original line Diff line number Diff line Loading @@ -867,6 +867,13 @@ void StatsService::Startup() { mConfigManager->Startup(); mConfigManager->Startup(); } } void StatsService::Terminate() { ALOGI("StatsService::Terminating"); if (mProcessor != nullptr) { mProcessor->WriteDataToDisk(TERMINATION_SIGNAL_RECEIVED); } } void StatsService::OnLogEvent(LogEvent* event) { void StatsService::OnLogEvent(LogEvent* event) { mProcessor->OnLogEvent(event); mProcessor->OnLogEvent(event); if (mShellSubscriber != nullptr) { if (mShellSubscriber != nullptr) { Loading cmds/statsd/src/StatsService.h +5 −0 Original line number Original line Diff line number Diff line Loading @@ -83,6 +83,11 @@ public: */ */ void Startup(); void Startup(); /** * Called when terminiation signal received. */ void Terminate(); /** /** * Called by LogReader when there's a log event to process. * Called by LogReader when there's a log event to process. */ */ Loading cmds/statsd/src/main.cpp +29 −6 Original line number Original line Diff line number Diff line Loading @@ -46,6 +46,27 @@ struct log_reader_thread_data { sp<StatsService> service; sp<StatsService> service; }; }; sp<StatsService> gStatsService = nullptr; void sigHandler(int sig) { if (gStatsService != nullptr) { gStatsService->Terminate(); } } void registerSigHandler() { struct sigaction sa; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sa.sa_handler = sigHandler; sigaction(SIGHUP, &sa, nullptr); sigaction(SIGINT, &sa, nullptr); sigaction(SIGQUIT, &sa, nullptr); sigaction(SIGTERM, &sa, nullptr); } int main(int /*argc*/, char** /*argv*/) { int main(int /*argc*/, char** /*argv*/) { // Set up the looper // Set up the looper sp<Looper> looper(Looper::prepare(0 /* opts */)); sp<Looper> looper(Looper::prepare(0 /* opts */)); Loading @@ -60,23 +81,25 @@ int main(int /*argc*/, char** /*argv*/) { ::android::hardware::configureRpcThreadpool(1 /*threads*/, false /*willJoin*/); ::android::hardware::configureRpcThreadpool(1 /*threads*/, false /*willJoin*/); // Create the service // Create the service sp<StatsService> service = new StatsService(looper); gStatsService = new StatsService(looper); if (defaultServiceManager()->addService(String16("stats"), service) != 0) { if (defaultServiceManager()->addService(String16("stats"), gStatsService) != 0) { ALOGE("Failed to add service as AIDL service"); ALOGE("Failed to add service as AIDL service"); return -1; return -1; } } auto ret = service->registerAsService(); auto ret = gStatsService->registerAsService(); if (ret != ::android::OK) { if (ret != ::android::OK) { ALOGE("Failed to add service as HIDL service"); ALOGE("Failed to add service as HIDL service"); return 1; // or handle error return 1; // or handle error } } service->sayHiToStatsCompanion(); registerSigHandler(); gStatsService->sayHiToStatsCompanion(); service->Startup(); gStatsService->Startup(); sp<StatsSocketListener> socketListener = new StatsSocketListener(service); sp<StatsSocketListener> socketListener = new StatsSocketListener(gStatsService); ALOGI("using statsd socket"); ALOGI("using statsd socket"); // Backlog and /proc/sys/net/unix/max_dgram_qlen set to large value // Backlog and /proc/sys/net/unix/max_dgram_qlen set to large value Loading cmds/statsd/src/stats_log.proto +1 −0 Original line number Original line Diff line number Diff line Loading @@ -271,6 +271,7 @@ message ConfigMetricsReport { ADB_DUMP = 5; ADB_DUMP = 5; CONFIG_RESET = 6; CONFIG_RESET = 6; STATSCOMPANION_DIED = 7; STATSCOMPANION_DIED = 7; TERMINATION_SIGNAL_RECEIVED = 8; } } optional DumpReportReason dump_report_reason = 8; optional DumpReportReason dump_report_reason = 8; Loading Loading
cmds/statsd/src/StatsLogProcessor.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -39,7 +39,8 @@ enum DumpReportReason { GET_DATA_CALLED = 4, GET_DATA_CALLED = 4, ADB_DUMP = 5, ADB_DUMP = 5, CONFIG_RESET = 6, CONFIG_RESET = 6, STATSCOMPANION_DIED = 7 STATSCOMPANION_DIED = 7, TERMINATION_SIGNAL_RECEIVED = 8 }; }; class StatsLogProcessor : public ConfigListener { class StatsLogProcessor : public ConfigListener { Loading
cmds/statsd/src/StatsService.cpp +7 −0 Original line number Original line Diff line number Diff line Loading @@ -867,6 +867,13 @@ void StatsService::Startup() { mConfigManager->Startup(); mConfigManager->Startup(); } } void StatsService::Terminate() { ALOGI("StatsService::Terminating"); if (mProcessor != nullptr) { mProcessor->WriteDataToDisk(TERMINATION_SIGNAL_RECEIVED); } } void StatsService::OnLogEvent(LogEvent* event) { void StatsService::OnLogEvent(LogEvent* event) { mProcessor->OnLogEvent(event); mProcessor->OnLogEvent(event); if (mShellSubscriber != nullptr) { if (mShellSubscriber != nullptr) { Loading
cmds/statsd/src/StatsService.h +5 −0 Original line number Original line Diff line number Diff line Loading @@ -83,6 +83,11 @@ public: */ */ void Startup(); void Startup(); /** * Called when terminiation signal received. */ void Terminate(); /** /** * Called by LogReader when there's a log event to process. * Called by LogReader when there's a log event to process. */ */ Loading
cmds/statsd/src/main.cpp +29 −6 Original line number Original line Diff line number Diff line Loading @@ -46,6 +46,27 @@ struct log_reader_thread_data { sp<StatsService> service; sp<StatsService> service; }; }; sp<StatsService> gStatsService = nullptr; void sigHandler(int sig) { if (gStatsService != nullptr) { gStatsService->Terminate(); } } void registerSigHandler() { struct sigaction sa; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sa.sa_handler = sigHandler; sigaction(SIGHUP, &sa, nullptr); sigaction(SIGINT, &sa, nullptr); sigaction(SIGQUIT, &sa, nullptr); sigaction(SIGTERM, &sa, nullptr); } int main(int /*argc*/, char** /*argv*/) { int main(int /*argc*/, char** /*argv*/) { // Set up the looper // Set up the looper sp<Looper> looper(Looper::prepare(0 /* opts */)); sp<Looper> looper(Looper::prepare(0 /* opts */)); Loading @@ -60,23 +81,25 @@ int main(int /*argc*/, char** /*argv*/) { ::android::hardware::configureRpcThreadpool(1 /*threads*/, false /*willJoin*/); ::android::hardware::configureRpcThreadpool(1 /*threads*/, false /*willJoin*/); // Create the service // Create the service sp<StatsService> service = new StatsService(looper); gStatsService = new StatsService(looper); if (defaultServiceManager()->addService(String16("stats"), service) != 0) { if (defaultServiceManager()->addService(String16("stats"), gStatsService) != 0) { ALOGE("Failed to add service as AIDL service"); ALOGE("Failed to add service as AIDL service"); return -1; return -1; } } auto ret = service->registerAsService(); auto ret = gStatsService->registerAsService(); if (ret != ::android::OK) { if (ret != ::android::OK) { ALOGE("Failed to add service as HIDL service"); ALOGE("Failed to add service as HIDL service"); return 1; // or handle error return 1; // or handle error } } service->sayHiToStatsCompanion(); registerSigHandler(); gStatsService->sayHiToStatsCompanion(); service->Startup(); gStatsService->Startup(); sp<StatsSocketListener> socketListener = new StatsSocketListener(service); sp<StatsSocketListener> socketListener = new StatsSocketListener(gStatsService); ALOGI("using statsd socket"); ALOGI("using statsd socket"); // Backlog and /proc/sys/net/unix/max_dgram_qlen set to large value // Backlog and /proc/sys/net/unix/max_dgram_qlen set to large value Loading
cmds/statsd/src/stats_log.proto +1 −0 Original line number Original line Diff line number Diff line Loading @@ -271,6 +271,7 @@ message ConfigMetricsReport { ADB_DUMP = 5; ADB_DUMP = 5; CONFIG_RESET = 6; CONFIG_RESET = 6; STATSCOMPANION_DIED = 7; STATSCOMPANION_DIED = 7; TERMINATION_SIGNAL_RECEIVED = 8; } } optional DumpReportReason dump_report_reason = 8; optional DumpReportReason dump_report_reason = 8; Loading