From e659655886ca808d0fcdc4f5f58146909db4ec6e Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Sun, 3 Sep 2017 15:51:46 -0700 Subject: [PATCH] Call pthread_join to clean up watchdog thread Merge from Widevine repo of http://go/wvgerrit/32880 This CL calls pthread_join on the watchdog thread to clean up its stack and other memory usage. Test: unit tests on bullhead, GTS tests run in loop, Play Movies on bullhead. bug: 65302198 Change-Id: I90f993333dfd019c1ffb96647a6472e4828d50aa --- .../cdm/core/src/oemcrypto_adapter_dynamic.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp b/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp index be1b2042..35a1c85a 100644 --- a/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp +++ b/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp @@ -503,6 +503,10 @@ class WatchDog { status_ = OEMCrypto_ERROR_INIT_FAILED; LOGE("XXX WATCH DOG ERROR XXX"); SaveFailureInformation(); + // This tells the worker thread to clean up after itself. It is not + // really needed since we are going to abort. However, if somebody + // removes the "abort()" below, then this is needed. + pthread_detach(thread_); // This is controversial. The argument for an abort here is that if we // do not abort, we will suck all the life out of the user's battery. By // saving information to the file system, above, we can still track @@ -514,7 +518,10 @@ class WatchDog { bool should_delete = !gave_up_; OEMCryptoResult status = status_; pthread_mutex_unlock(&mutex_); - if (should_delete) delete this; + if (should_delete) { + pthread_join(thread_, NULL); + delete this; + } return status; }