Lock session list in CdmEngine OnTimerEvent

This is a copy of the widevine CL:
https://widevine-internal-review.googlesource.com/#/c/12742/

If a session is closed at the same time as an OnTimerEvent is
processing an event, there could be a race condition between the two
threads.  This CL adds a lock that prevents a session from being
removed from the list while the timer is currently processing an
event.

If CloseSession is called while the OnTimerEvent method is active, the
session will be added to a dead list, and deleted when the timer event
has finished.

This CL does not address the main problem in bug 19252886, but
one bugreport, netflix_log_3.txt, indicates there may have been
a problem with the CDM timer.
bug: 19252886

Change-Id: I17190edaeb3eef1295d4d204232cc4262cb5fa9b
This commit is contained in:
Fred Gylys-Colwell
2015-02-06 19:13:30 -08:00
parent 6408ce05d4
commit 802fe3b35c
2 changed files with 43 additions and 9 deletions

View File

@@ -9,6 +9,7 @@
#include "certificate_provisioning.h"
#include "crypto_session.h"
#include "initialization_data.h"
#include "lock.h"
#include "oemcrypto_adapter.h"
#include "scoped_ptr.h"
#include "wv_cdm_types.h"
@@ -154,6 +155,12 @@ class CdmEngine {
scoped_ptr<UsagePropertySet> usage_property_set_;
int64_t last_usage_information_update_time_;
Lock session_list_lock_;
// If the timer is currently active -- do not delete any sessions.
bool timer_event_active_;
// Sessions to be deleted after the timer has finished.
std::vector<CdmSession*> dead_sessions_;
CORE_DISALLOW_COPY_AND_ASSIGN(CdmEngine);
};