From f1830f5576474ee7b6aa4ef4a7d19e6a2c26b2f7 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 10 Jul 2006 19:15:50 +0000 Subject: [PATCH] revert TcpTable iteration to get LISTEN states first --- src/os/win32/win32_sigar.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index dbca0adc..cc3903c2 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -2069,8 +2069,8 @@ static int net_conn_get_tcp(sigar_net_connection_walker_t *walker) { sigar_t *sigar = walker->sigar; int flags = walker->flags; - int status; - DWORD rc, size=0, i; + int status, i; + DWORD rc, size=0; PMIB_TCPTABLE tcp; DLLMOD_INIT(iphlpapi, FALSE); @@ -2090,7 +2090,8 @@ static int net_conn_get_tcp(sigar_net_connection_walker_t *walker) return GetLastError(); } - for (i = 0; i < tcp->dwNumEntries; i++) { + /* go in reverse to get LISTEN states first */ + for (i = (tcp->dwNumEntries-1); i >= 0; i--) { sigar_net_connection_t conn; DWORD state = tcp->table[i].dwState;