test/app_stub: Replace next pointer by TAILQ
This will make the object relationship cleaner and the asynchronous detach operation easier to implement. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I4640d15015437bdb54ceeb0d1d0269c7ec3ceeb7 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4433 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
db28850a93
commit
da08be0f65
@ -43,22 +43,20 @@ static struct spdk_poller *g_poller;
|
|||||||
|
|
||||||
struct ctrlr_entry {
|
struct ctrlr_entry {
|
||||||
struct spdk_nvme_ctrlr *ctrlr;
|
struct spdk_nvme_ctrlr *ctrlr;
|
||||||
struct ctrlr_entry *next;
|
TAILQ_ENTRY(ctrlr_entry) link;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct ctrlr_entry *g_controllers = NULL;
|
static TAILQ_HEAD(, ctrlr_entry) g_controllers = TAILQ_HEAD_INITIALIZER(g_controllers);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cleanup(void)
|
cleanup(void)
|
||||||
{
|
{
|
||||||
struct ctrlr_entry *ctrlr_entry = g_controllers;
|
struct ctrlr_entry *ctrlr_entry, *tmp;
|
||||||
|
|
||||||
while (ctrlr_entry) {
|
|
||||||
struct ctrlr_entry *next = ctrlr_entry->next;
|
|
||||||
|
|
||||||
|
TAILQ_FOREACH_SAFE(ctrlr_entry, &g_controllers, link, tmp) {
|
||||||
|
TAILQ_REMOVE(&g_controllers, ctrlr_entry, link);
|
||||||
spdk_nvme_detach(ctrlr_entry->ctrlr);
|
spdk_nvme_detach(ctrlr_entry->ctrlr);
|
||||||
free(ctrlr_entry);
|
free(ctrlr_entry);
|
||||||
ctrlr_entry = next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,8 +98,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
entry->ctrlr = ctrlr;
|
entry->ctrlr = ctrlr;
|
||||||
entry->next = g_controllers;
|
TAILQ_INSERT_TAIL(&g_controllers, entry, link);
|
||||||
g_controllers = entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user