[hamradio-commits] [dump1090] 273/389: antirez
Matthew Ernisse
mernisse-guest at moszumanska.debian.org
Wed Nov 5 00:20:04 UTC 2014
This is an automated email from the git hooks/post-receive script.
mernisse-guest pushed a commit to branch master
in repository dump1090.
commit b9a1a3e650a5a6a081994586c54069c29569543a
Author: Malcolm Robb <Support at ATTAvionics.com>
Date: Sat Feb 22 22:28:20 2014 +0000
antirez
modesFreeClient() optimized to find new maxfd faster
---
net_io.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/net_io.c b/net_io.c
index a0a9838..1ff16b1 100644
--- a/net_io.c
+++ b/net_io.c
@@ -146,14 +146,18 @@ void modesFreeClient(int fd) {
if (Modes.debug & MODES_DEBUG_NET)
printf("Closing client %d\n", fd);
- // If this was our maxfd, rescan the full clients array to check what's
- // the new max.
+ // If this was our maxfd, scan the clients array to find the new max.
+ // Note that we are sure there is no active fd greater than the closed
+ // fd, so we scan from fd-1 to 0.
if (Modes.maxfd == fd) {
int j;
Modes.maxfd = -1;
- for (j = 0; j < MODES_NET_MAX_FD; j++) {
- if (Modes.clients[j]) Modes.maxfd = j;
+ for (j = fd-1; j >= 0; j--) {
+ if (Modes.clients[j]) {
+ Modes.maxfd = j;
+ break;
+ }
}
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/dump1090.git
More information about the pkg-hamradio-commits
mailing list