Fix for zero-sized corrupted license files
Netflix reported that after pulling power while their app is active, the app isn't able to restart. This is because the license file for session keys isn't getting synched to disk, so the data is still in the buffer cache when the device shuts down. Calling fflush and fsync on the file ensures the data is persisted to disk. fclose alone doesn't do fsync. In testing, I also noticed that the license file was being rewritten every second which is hard on the flash filesystem. The timer thread was modified to avoid these frequent writes. Merge of https://widevine-internal-review.googlesource.com/#/c/12431/ from the widevine cdm repo. bug: 19108207 Change-Id: Ibe81e40a3c1f5d25563523da43fefdccdaa6ddcf
This commit is contained in:
@@ -568,13 +568,12 @@ void CdmSession::OnTimerEvent(bool update_usage) {
|
||||
if (update_usage && has_decrypted_recently_) {
|
||||
policy_engine_->DecryptionEvent();
|
||||
has_decrypted_recently_ = false;
|
||||
if (is_offline_ && !is_release_) {
|
||||
StoreLicense(DeviceFiles::kLicenseStateActive);
|
||||
}
|
||||
}
|
||||
policy_engine_->OnTimerEvent(&event_occurred, &event);
|
||||
|
||||
if (is_offline_ && !is_release_) {
|
||||
StoreLicense(DeviceFiles::kLicenseStateActive);
|
||||
}
|
||||
|
||||
if (event_occurred) {
|
||||
for (CdmEventListenerIter iter = listeners_.begin();
|
||||
iter != listeners_.end(); ++iter) {
|
||||
|
||||
@@ -71,7 +71,9 @@ bool File::Open(const std::string& name, int flags) {
|
||||
}
|
||||
|
||||
void File::Close() {
|
||||
if (impl_->file_) {
|
||||
if (impl_->file_){
|
||||
fflush(impl_->file_);
|
||||
fsync(fileno(impl_->file_));
|
||||
fclose(impl_->file_);
|
||||
impl_->file_ = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user