[core] Fix connection garbage collector

personal/stbuehler/wip
Thomas Porzelt 13 years ago
parent 5ca4cd5eeb
commit 53096333f1
  1. 3
      src/main/worker.c

@ -673,12 +673,13 @@ void li_worker_con_put(liConnection *con) {
/* realloc wrk->connections if it makes sense (too many allocated, only every 60sec) */
/* if (active < allocated*0.70) { allocated *= 0.85 } */
threshold = (wrk->connections->len * 7) / 10;
if (wrk->connections_active < threshold && (now - wrk->connections_gc_ts) < 60.0 && wrk->connections->len > 10) {
if (wrk->connections_active < threshold && (now - wrk->connections_gc_ts) > 60.0 && wrk->connections->len > 10) {
/* realloc */
guint i;
threshold = (wrk->connections->len * 85) / 100;
for (i = wrk->connections->len; i > threshold; i--) {
li_connection_free(g_array_index(wrk->connections, liConnection*, i-1));
g_array_index(wrk->connections, liConnection*, i-1) = NULL;
}
wrk->connections->len = threshold;
wrk->connections_gc_ts = now;

Loading…
Cancel
Save