Loading cmds/statsd/src/StatsLogProcessor.h +2 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,8 @@ enum DumpReportReason { GET_DATA_CALLED = 4, ADB_DUMP = 5, CONFIG_RESET = 6, STATSCOMPANION_DIED = 7 STATSCOMPANION_DIED = 7, TERMINATION_SIGNAL_RECEIVED = 8 }; class StatsLogProcessor : public ConfigListener { Loading cmds/statsd/src/StatsService.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -881,6 +881,13 @@ void StatsService::Startup() { mConfigManager->Startup(); } void StatsService::Terminate() { ALOGI("StatsService::Terminating"); if (mProcessor != nullptr) { mProcessor->WriteDataToDisk(TERMINATION_SIGNAL_RECEIVED); } } void StatsService::OnLogEvent(LogEvent* event, bool reconnectionStarts) { mProcessor->OnLogEvent(event, reconnectionStarts); } Loading cmds/statsd/src/StatsService.h +5 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,11 @@ public: */ void Startup(); /** * Called when terminiation signal received. */ void Terminate(); /** * Called by LogReader when there's a log event to process. */ Loading cmds/statsd/src/main.cpp +30 −6 Original line number Diff line number Diff line Loading @@ -96,6 +96,27 @@ static status_t start_log_reader_thread(const sp<StatsService>& service) { return NO_ERROR; } 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*/) { // Set up the looper sp<Looper> looper(Looper::prepare(0 /* opts */)); Loading @@ -108,21 +129,24 @@ int main(int /*argc*/, char** /*argv*/) { IPCThreadState::self()->disableBackgroundScheduling(true); // Create the service sp<StatsService> service = new StatsService(looper); if (defaultServiceManager()->addService(String16("stats"), service) != 0) { gStatsService = new StatsService(looper); if (defaultServiceManager()->addService(String16("stats"), gStatsService) != 0) { ALOGE("Failed to add service"); return -1; } service->sayHiToStatsCompanion(); service->Startup(); registerSigHandler(); gStatsService->sayHiToStatsCompanion(); gStatsService->Startup(); sp<StatsSocketListener> socketListener = new StatsSocketListener(service); sp<StatsSocketListener> socketListener = new StatsSocketListener(gStatsService); if (kUseLogd) { ALOGI("using logd"); // Start the log reader thread status_t err = start_log_reader_thread(service); status_t err = start_log_reader_thread(gStatsService); if (err != NO_ERROR) { return 1; } Loading cmds/statsd/src/stats_log.proto +1 −0 Original line number Diff line number Diff line Loading @@ -265,6 +265,7 @@ message ConfigMetricsReport { ADB_DUMP = 5; CONFIG_RESET = 6; STATSCOMPANION_DIED = 7; TERMINATION_SIGNAL_RECEIVED = 8; } optional DumpReportReason dump_report_reason = 8; Loading Loading
cmds/statsd/src/StatsLogProcessor.h +2 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,8 @@ enum DumpReportReason { GET_DATA_CALLED = 4, ADB_DUMP = 5, CONFIG_RESET = 6, STATSCOMPANION_DIED = 7 STATSCOMPANION_DIED = 7, TERMINATION_SIGNAL_RECEIVED = 8 }; class StatsLogProcessor : public ConfigListener { Loading
cmds/statsd/src/StatsService.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -881,6 +881,13 @@ void StatsService::Startup() { mConfigManager->Startup(); } void StatsService::Terminate() { ALOGI("StatsService::Terminating"); if (mProcessor != nullptr) { mProcessor->WriteDataToDisk(TERMINATION_SIGNAL_RECEIVED); } } void StatsService::OnLogEvent(LogEvent* event, bool reconnectionStarts) { mProcessor->OnLogEvent(event, reconnectionStarts); } Loading
cmds/statsd/src/StatsService.h +5 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,11 @@ public: */ void Startup(); /** * Called when terminiation signal received. */ void Terminate(); /** * Called by LogReader when there's a log event to process. */ Loading
cmds/statsd/src/main.cpp +30 −6 Original line number Diff line number Diff line Loading @@ -96,6 +96,27 @@ static status_t start_log_reader_thread(const sp<StatsService>& service) { return NO_ERROR; } 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*/) { // Set up the looper sp<Looper> looper(Looper::prepare(0 /* opts */)); Loading @@ -108,21 +129,24 @@ int main(int /*argc*/, char** /*argv*/) { IPCThreadState::self()->disableBackgroundScheduling(true); // Create the service sp<StatsService> service = new StatsService(looper); if (defaultServiceManager()->addService(String16("stats"), service) != 0) { gStatsService = new StatsService(looper); if (defaultServiceManager()->addService(String16("stats"), gStatsService) != 0) { ALOGE("Failed to add service"); return -1; } service->sayHiToStatsCompanion(); service->Startup(); registerSigHandler(); gStatsService->sayHiToStatsCompanion(); gStatsService->Startup(); sp<StatsSocketListener> socketListener = new StatsSocketListener(service); sp<StatsSocketListener> socketListener = new StatsSocketListener(gStatsService); if (kUseLogd) { ALOGI("using logd"); // Start the log reader thread status_t err = start_log_reader_thread(service); status_t err = start_log_reader_thread(gStatsService); if (err != NO_ERROR) { return 1; } Loading
cmds/statsd/src/stats_log.proto +1 −0 Original line number Diff line number Diff line Loading @@ -265,6 +265,7 @@ message ConfigMetricsReport { ADB_DUMP = 5; CONFIG_RESET = 6; STATSCOMPANION_DIED = 7; TERMINATION_SIGNAL_RECEIVED = 8; } optional DumpReportReason dump_report_reason = 8; Loading