traverse circular queue in a way that actually terminates; ok maintainer

This commit is contained in:
naddy 2004-08-13 00:18:24 +00:00
parent 719e68a3d9
commit b49a901036

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-src_sysdeps_bsd-net-open_c,v 1.3 2004/02/19 17:27:56 sturm Exp $
--- src/sysdeps/bsd-net-open.c.orig 2004-02-19 18:10:32.000000000 +0100
+++ src/sysdeps/bsd-net-open.c 2004-02-19 18:10:58.000000000 +0100
$OpenBSD: patch-src_sysdeps_bsd-net-open_c,v 1.4 2004/08/13 00:18:24 naddy Exp $
--- src/sysdeps/bsd-net-open.c.orig Sat May 1 19:46:38 2004
+++ src/sysdeps/bsd-net-open.c Thu Aug 12 23:06:35 2004
@@ -85,7 +85,7 @@ gkrellm_sys_disk_read_data(void)
/* Separate read/write stats were implemented in NetBSD 1.6K.
*/
@ -10,3 +10,25 @@ $OpenBSD: patch-src_sysdeps_bsd-net-open_c,v 1.3 2004/02/19 17:27:56 sturm Exp $
rbytes = d.dk_rbytes;
wbytes = d.dk_wbytes;
#else
@@ -154,7 +154,7 @@ gkrellm_sys_inet_read_tcp_data(void)
ActiveTCP tcp;
gint tcp_status;
struct inpcbtable table;
- struct inpcb inpcb, *next;
+ struct inpcb inpcb, *head, *next;
struct tcpcb tcpcb;
static struct nlist nl[] = {
#define X_TCBTABLE 0
@@ -171,8 +171,11 @@ gkrellm_sys_inet_read_tcp_data(void)
sizeof(struct inpcbtable)) != sizeof(struct inpcbtable))
return;
+ head = (struct inpcb *)
+ &((struct inpcbtable *)nl[X_TCBTABLE].n_value)->inpt_queue.cqh_first;
next = (struct inpcb *)table.inpt_queue.cqh_first;
- while(next != NULL) {
+
+ while(next != head) {
if (kvm_read(kvmd, (u_long)next,
(char *)&inpcb, sizeof(inpcb)) == sizeof(inpcb) &&