* Reclaim caches recently unreferenced */
| 89 | * Reclaim caches recently unreferenced |
| 90 | */ |
| 91 | static void |
| 92 | sepgsql_avc_reclaim(void) |
| 93 | { |
| 94 | ListCell *cell; |
| 95 | int index; |
| 96 | |
| 97 | while (avc_num_caches >= avc_threshold - AVC_NUM_RECLAIM) |
| 98 | { |
| 99 | index = avc_lru_hint; |
| 100 | |
| 101 | foreach(cell, avc_slots[index]) |
| 102 | { |
| 103 | avc_cache *cache = lfirst(cell); |
| 104 | |
| 105 | if (!cache->hot_cache) |
| 106 | { |
| 107 | avc_slots[index] |
| 108 | = foreach_delete_current(avc_slots[index], cell); |
| 109 | |
| 110 | pfree(cache->scontext); |
| 111 | pfree(cache->tcontext); |
| 112 | if (cache->ncontext) |
| 113 | pfree(cache->ncontext); |
| 114 | pfree(cache); |
| 115 | |
| 116 | avc_num_caches--; |
| 117 | } |
| 118 | else |
| 119 | { |
| 120 | cache->hot_cache = false; |
| 121 | } |
| 122 | } |
| 123 | avc_lru_hint = (avc_lru_hint + 1) % AVC_NUM_SLOTS; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | /* ------------------------------------------------------------------------- |
| 128 | * |
no test coverage detected