Commit da08be0f authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

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: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I4640d15015437bdb54ceeb0d1d0269c7ec3ceeb7
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4433


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent db28850a
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -43,22 +43,20 @@ static struct spdk_poller *g_poller;

struct ctrlr_entry {
	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
cleanup(void)
{
	struct ctrlr_entry *ctrlr_entry = g_controllers;

	while (ctrlr_entry) {
		struct ctrlr_entry *next = ctrlr_entry->next;
	struct ctrlr_entry *ctrlr_entry, *tmp;

	TAILQ_FOREACH_SAFE(ctrlr_entry, &g_controllers, link, tmp) {
		TAILQ_REMOVE(&g_controllers, ctrlr_entry, link);
		spdk_nvme_detach(ctrlr_entry->ctrlr);
		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->next = g_controllers;
	g_controllers = entry;
	TAILQ_INSERT_TAIL(&g_controllers, entry, link);
}

static int