diff options
Diffstat (limited to 'src/libsink')
| -rw-r--r-- | src/libsink/sink.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libsink/sink.c b/src/libsink/sink.c index 899023d..ee2b216 100644 --- a/src/libsink/sink.c +++ b/src/libsink/sink.c @@ -708,7 +708,6 @@ static s32 lru_compare(const void *a, const void *b) static void maybe_cleanup_old_entries(struct camu_sink *sink) { - al_array_sort(sink->entries, struct camu_sink_entry *, lru_compare); // We check size <= MAX_AGE in the loop because sink->lru // is not indicative of the amount of entries we have loaded. // There are various reasons for this but the most obvious is @@ -720,21 +719,22 @@ static void maybe_cleanup_old_entries(struct camu_sink *sink) // 0 1 2 65534 65535 // 0 1 2 3 65535 // 0 1 2 3 4 + al_array_sort(sink->entries, struct camu_sink_entry *, lru_compare); struct camu_sink_entry *entry; al_array_foreach_rev(sink->entries, i, entry) { - if (sink->entries.size <= ENTRY_MAX_AGE) return; if (entry->lru > sink->lru && (UINT16_MAX - (entry->lru - 1)) + sink->lru >= ENTRY_MAX_AGE) { al_array_remove_at(sink->entries, i); lia_client_disconnect(&entry->client); } + if (sink->entries.size <= ENTRY_MAX_AGE) return; } if (sink->lru >= ENTRY_MAX_AGE) { al_array_foreach_rev(sink->entries, i, entry) { - if (sink->entries.size <= ENTRY_MAX_AGE) return; if (sink->lru - entry->lru >= ENTRY_MAX_AGE) { al_array_remove_at(sink->entries, i); lia_client_disconnect(&entry->client); } + if (sink->entries.size <= ENTRY_MAX_AGE) return; } } } |