Merge "Close session during capacity check." into udc-qpr-dev
This commit is contained in:
@@ -384,6 +384,9 @@ CdmResponseType CdmUsageTable::InvalidateEntryInternal(
|
||||
// sent back to the caller for the CDM as a whole to handle.
|
||||
const uint32_t pre_defrag_store_counter = store_table_counter_;
|
||||
const CdmResponseType status = DefragTable(device_files, metrics);
|
||||
if (status != NO_ERROR) {
|
||||
LOGW("Failed to defrag usage table: sts = %s", status.ToString().c_str());
|
||||
}
|
||||
if (pre_defrag_store_counter == store_table_counter_) {
|
||||
// It is possible that DefragTable() does not result in any
|
||||
// changes to the table, and as a result, it will not store the
|
||||
@@ -470,6 +473,10 @@ bool CdmUsageTable::CapacityCheck(CryptoSession* const crypto_session) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Session must be closed before invalidating, otherwise Shrink() will
|
||||
// fail in call to InvalidateEntry().
|
||||
local_crypto_session->Close();
|
||||
|
||||
status =
|
||||
InvalidateEntry(temporary_entry_index,
|
||||
/* defrag_table = */ true, device_files_.get(), metrics);
|
||||
@@ -482,7 +489,10 @@ bool CdmUsageTable::CapacityCheck(CryptoSession* const crypto_session) {
|
||||
// The entry should have been deleted from the usage table,
|
||||
// not just marked as type unknown. Failure to call
|
||||
// Shrink() may be an indicator of other issues.
|
||||
LOGE("Failed to shrink table for capacity test");
|
||||
LOGE(
|
||||
"Failed to shrink table for capacity test: "
|
||||
"post_check_size = %zu, check_usage_entry_number = %u",
|
||||
entry_info_list_.size(), temporary_entry_index);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -954,7 +964,12 @@ CdmResponseType CdmUsageTable::DefragTable(DeviceFiles* device_files,
|
||||
if (entries_to_move.empty()) {
|
||||
LOGD("No valid entries found, shrinking entire table: size = %zu",
|
||||
entry_info_list_.size());
|
||||
return Shrink(metrics, static_cast<uint32_t>(entry_info_list_.size()));
|
||||
const CdmResponseType status =
|
||||
Shrink(metrics, static_cast<uint32_t>(entry_info_list_.size()));
|
||||
if (status != NO_ERROR) {
|
||||
LOGE("Failed to shrink table: sts = %s", status.ToString().c_str());
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// Step 3: Ignore invalid entries that are after the last valid
|
||||
@@ -978,7 +993,11 @@ CdmResponseType CdmUsageTable::DefragTable(DeviceFiles* device_files,
|
||||
last_valid_entry - 1;
|
||||
LOGD("Removing all entries after the last valid entry: count = %u",
|
||||
to_remove);
|
||||
return Shrink(metrics, to_remove);
|
||||
const CdmResponseType status = Shrink(metrics, to_remove);
|
||||
if (status != NO_ERROR) {
|
||||
LOGE("Failed to shrink table: sts = %s", status.ToString().c_str());
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// Step 4: Move the valid entries to overwrite the invalid entries.
|
||||
@@ -1106,7 +1125,12 @@ CdmResponseType CdmUsageTable::DefragTable(DeviceFiles* device_files,
|
||||
LOGD(
|
||||
"All entries have been invalidated, shrinking entire table: size = %zu",
|
||||
entry_info_list_.size());
|
||||
return Shrink(metrics, static_cast<uint32_t>(entry_info_list_.size()));
|
||||
const CdmResponseType status =
|
||||
Shrink(metrics, static_cast<uint32_t>(entry_info_list_.size()));
|
||||
if (status != NO_ERROR) {
|
||||
LOGE("Failed to shrink table: sts = %s", status.ToString().c_str());
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
const UsageEntryIndex to_remove =
|
||||
@@ -1125,7 +1149,11 @@ CdmResponseType CdmUsageTable::DefragTable(DeviceFiles* device_files,
|
||||
|
||||
// Step 6: Shrink table to the new size.
|
||||
LOGD("Clean up complete, shrinking table: count = %u", to_remove);
|
||||
return Shrink(metrics, to_remove);
|
||||
const CdmResponseType status = Shrink(metrics, to_remove);
|
||||
if (status != NO_ERROR) {
|
||||
LOGE("Failed to shrink table: sts = %s", status.ToString().c_str());
|
||||
}
|
||||
return status;
|
||||
} // End Defrag().
|
||||
|
||||
CdmResponseType CdmUsageTable::ReleaseOldestEntry(
|
||||
|
||||
Reference in New Issue
Block a user