Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Jun 2015 20:01:55 +0000 (UTC)
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r284352 - head/usr.bin/sockstat
Message-ID:  <201506132001.t5DK1tYf059937@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tuexen
Date: Sat Jun 13 20:01:54 2015
New Revision: 284352
URL: https://svnweb.freebsd.org/changeset/base/284352

Log:
  Allow more than one socket entry for a file descriptor. This is needed
  for supporting 1-to-many style SCTP sockets. For other sochets, there
  is no functional change.
  
  MFC after: 3 days

Modified:
  head/usr.bin/sockstat/sockstat.c

Modified: head/usr.bin/sockstat/sockstat.c
==============================================================================
--- head/usr.bin/sockstat/sockstat.c	Sat Jun 13 19:56:04 2015	(r284351)
+++ head/usr.bin/sockstat/sockstat.c	Sat Jun 13 20:01:54 2015	(r284352)
@@ -669,29 +669,28 @@ display(void)
 		if (opt_j >= 0 && opt_j != getprocjid(xf->xf_pid))
 			continue;
 		hash = (int)((uintptr_t)xf->xf_data % HASHSIZE);
-		for (s = sockhash[hash]; s != NULL; s = s->next)
-			if ((void *)s->socket == xf->xf_data)
-				break;
-		if (s == NULL)
-			continue;
-		if (!check_ports(s))
-			continue;
-		s->shown = 1;
-		pos = 0;
-		if ((pwd = getpwuid(xf->xf_uid)) == NULL)
-			pos += xprintf("%lu ", (u_long)xf->xf_uid);
-		else
-			pos += xprintf("%s ", pwd->pw_name);
-		while (pos < 9)
-			pos += xprintf(" ");
-		pos += xprintf("%.10s", getprocname(xf->xf_pid));
-		while (pos < 20)
-			pos += xprintf(" ");
-		pos += xprintf("%lu ", (u_long)xf->xf_pid);
-		while (pos < 26)
-			pos += xprintf(" ");
-		pos += xprintf("%d ", xf->xf_fd);
-		displaysock(s, pos);
+		for (s = sockhash[hash]; s != NULL; s = s->next) {
+			if ((void *)s->socket != xf->xf_data)
+				continue;
+			if (!check_ports(s))
+				continue;
+			s->shown = 1;
+			pos = 0;
+			if ((pwd = getpwuid(xf->xf_uid)) == NULL)
+				pos += xprintf("%lu ", (u_long)xf->xf_uid);
+			else
+				pos += xprintf("%s ", pwd->pw_name);
+			while (pos < 9)
+				pos += xprintf(" ");
+			pos += xprintf("%.10s", getprocname(xf->xf_pid));
+			while (pos < 20)
+				pos += xprintf(" ");
+			pos += xprintf("%lu ", (u_long)xf->xf_pid);
+			while (pos < 26)
+				pos += xprintf(" ");
+			pos += xprintf("%d ", xf->xf_fd);
+			displaysock(s, pos);
+		}
 	}
 	if (opt_j >= 0)
 		return;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201506132001.t5DK1tYf059937>