[#2924] Correctly update head in MemoryRegionCache.trim()
Motivation: When MemoryRegionCache.trim() is called, some unused cache entries will be freed (started from head). However, in MeoryRegionCache.trim() the head is not updated, which make entry list's head point to an entry whose chunk is null now and following allocate of MeoryRegionCache will return false immediately. In other word, cache is no longer usable once trim happen. Modifications: Update head to correct idx after free entries in trim(). Result: MemoryRegionCache behaves correctly even after calling trim().
This commit is contained in:
parent
a25c585f39
commit
858de5699b
@ -445,10 +445,14 @@ final class PoolThreadCache {
|
||||
for (; free > 0; free--) {
|
||||
if (!freeEntry(entries[i])) {
|
||||
// all freed
|
||||
return;
|
||||
break;
|
||||
}
|
||||
i = nextIdx(i);
|
||||
}
|
||||
|
||||
// Update head to point to te correct entry
|
||||
// See https://github.com/netty/netty/issues/2924
|
||||
head = i;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
|
Loading…
Reference in New Issue
Block a user