From bb6bc4089147a1f85910bac384ce4514dc74137c Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 4 Mar 2020 12:16:08 -0800 Subject: [PATCH] ircd::server: Tweak the link selection algorithm; comments. --- ircd/server.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ircd/server.cc b/ircd/server.cc index ed1b58102..6fc04bcc7 100644 --- a/ircd/server.cc +++ b/ircd/server.cc @@ -836,20 +836,22 @@ ircd::server::peer::link_get(const request &request) return best; } + // When we've reached the max number of links we return the best. if(links_maxed) return best; - // best might not be good enough, we could try another connection. If best - // has a backlog or is working on a large download or slow request. + // If no best was found or was nulled, we have room for another link. if(!best) { best = &link_add(); return best; } - if(best->tag_uncommitted() < best->tag_commit_max()) + // If the best has room in its pipe we give it a shot. + if(best->tag_committed() < best->tag_commit_max()) return best; + // Otherwise create a new link. best = &link_add(); return best; }