File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -157,14 +157,20 @@ region_reserve(struct region *region, size_t size)
157157 if (size <= rslab_unused (slab ))
158158 return (char * ) rslab_data (slab ) + slab -> used ;
159159 /* Try to get a slab from the region cache. */
160- slab = rlist_last_entry (& region -> slabs .slabs ,
161- struct rslab ,
162- slab .next_in_list );
163- if (slab -> used == 0 && size <= rslab_unused (slab )) {
164- /* Move this slab to the head. */
160+ while ((slab = rlist_last_entry (& region -> slabs .slabs ,
161+ struct rslab ,
162+ slab .next_in_list ))-> used == 0 ) {
165163 slab_list_del (& region -> slabs , & slab -> slab , next_in_list );
166- slab_list_add (& region -> slabs , & slab -> slab , next_in_list );
167- return (char * ) rslab_data (slab );
164+ if (size <= rslab_unused (slab )) {
165+ /* Move this slab to the head. */
166+ slab_list_add (& region -> slabs , & slab -> slab , next_in_list );
167+ return (char * ) rslab_data (slab );
168+ }
169+ /*
170+ * This cached slab could not be used so free it
171+ * and try to use the next one.
172+ */
173+ slab_put (region -> cache , (struct slab * )slab );
168174 }
169175 }
170176 return region_reserve_slow (region , size );
You can’t perform that action at this time.
0 commit comments