From fe32aec9d8a99db5d70440226ca4b61a78aac224 Mon Sep 17 00:00:00 2001 From: "Chas Williams (CONTRACTOR)" Date: Mon, 1 Oct 2012 10:08:36 -0400 Subject: [PATCH] bos: convert struct bnode_type to use opr Convert struct bnode_type to use the common linked list code from opr. Change-Id: I21329aff81a91a79a1fcf525f4fdd3a22b33ec92 Reviewed-on: http://gerrit.openafs.org/8166 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/bozo/bnode.c | 22 ++++++++++++++-------- src/bozo/bnode_internal.h | 2 +- src/bozo/cronbnodeops.c | 1 + src/bozo/ezbnodeops.c | 2 ++ src/bozo/fsbnodeops.c | 1 + 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/bozo/bnode.c b/src/bozo/bnode.c index 9b0f40f87..9faa9926e 100644 --- a/src/bozo/bnode.c +++ b/src/bozo/bnode.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "bnode.h" #include "bnode_internal.h" @@ -36,7 +37,7 @@ int bnode_waiting = 0; static PROCESS bproc_pid; /* pid of waker-upper */ static struct bnode *allBnodes = 0; /* list of all bnodes */ static struct bnode_proc *allProcs = 0; /* list of all processes for which we're waiting */ -static struct bnode_type *allTypes = 0; /* list of registered type handlers */ +static struct opr_queue allTypes; /**< List of all registered type handlers */ static struct bnode_stats { int weirdPids; @@ -320,28 +321,32 @@ bnode_FindInstance(char *aname) static struct bnode_type * FindType(char *aname) { - struct bnode_type *tt; + struct opr_queue *cursor; + + for (opr_queue_Scan(&allTypes, cursor)) { + struct bnode_type *tt = opr_queue_Entry(cursor, struct bnode_type, q); - for (tt = allTypes; tt; tt = tt->next) { if (!strcmp(tt->name, aname)) return tt; } - return (struct bnode_type *)0; + return NULL; } int bnode_Register(char *atype, struct bnode_ops *aprocs, int anparms) { - struct bnode_type *tt; + struct opr_queue *cursor; + struct bnode_type *tt = NULL; - for (tt = allTypes; tt; tt = tt->next) { + for (opr_queue_Scan(&allTypes, cursor), tt = NULL) { + tt = opr_queue_Entry(cursor, struct bnode_type, q); if (!strcmp(tt->name, atype)) break; } if (!tt) { tt = calloc(1, sizeof(struct bnode_type)); - tt->next = allTypes; - allTypes = tt; + opr_queue_Init(&tt->q); + opr_queue_Prepend(&allTypes, &tt->q); tt->name = atype; } tt->ops = aprocs; @@ -849,6 +854,7 @@ bnode_Init(void) if (initDone) return 0; initDone = 1; + opr_queue_Init(&allTypes); memset(&bnode_stats, 0, sizeof(bnode_stats)); LWP_InitializeProcessSupport(1, &junk); /* just in case */ IOMGR_Initialize(); diff --git a/src/bozo/bnode_internal.h b/src/bozo/bnode_internal.h index d397826a3..9b4119238 100644 --- a/src/bozo/bnode_internal.h +++ b/src/bozo/bnode_internal.h @@ -36,7 +36,7 @@ struct bnode_ops { }; struct bnode_type { - struct bnode_type *next; + struct opr_queue q; char *name; struct bnode_ops *ops; }; diff --git a/src/bozo/cronbnodeops.c b/src/bozo/cronbnodeops.c index afb337e75..c46bf8c8c 100644 --- a/src/bozo/cronbnodeops.c +++ b/src/bozo/cronbnodeops.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "bnode.h" #include "bnode_internal.h" diff --git a/src/bozo/ezbnodeops.c b/src/bozo/ezbnodeops.c index d640d4edd..586b177f5 100644 --- a/src/bozo/ezbnodeops.c +++ b/src/bozo/ezbnodeops.c @@ -17,6 +17,8 @@ #include #include +#include + #include "bnode.h" #include "bnode_internal.h" #include "bosprototypes.h" diff --git a/src/bozo/fsbnodeops.c b/src/bozo/fsbnodeops.c index 270811842..c8ec5328f 100644 --- a/src/bozo/fsbnodeops.c +++ b/src/bozo/fsbnodeops.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "bnode.h" #include "bnode_internal.h" -- 2.39.5