Commit 2b9a09e8 authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

thread: add iobuf_unregister function



Some users of the iobuf can be dynamically constructed and later
destroyed, so add a function to unregister a module.

Change-Id: I78783dce9f0d29764ffc53963472ff40529ce6c4
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16285


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Community-CI: Mellanox Build Bot
parent 01466caf
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1049,6 +1049,15 @@ void spdk_iobuf_get_opts(struct spdk_iobuf_opts *opts);
 */
int spdk_iobuf_register_module(const char *name);

/**
 * Unregister an iobuf pool user from a module.
 *
 * \name Name of the module.
 *
 * \return 0 on success, negative errno otherwise.
 */
int spdk_iobuf_unregister_module(const char *name);

/**
 * Initialize an iobuf channel.
 *
+17 −0
Original line number Diff line number Diff line
@@ -364,6 +364,23 @@ spdk_iobuf_register_module(const char *name)
	return 0;
}

int
spdk_iobuf_unregister_module(const char *name)
{
	struct iobuf_module *module;

	TAILQ_FOREACH(module, &g_iobuf.modules, tailq) {
		if (strcmp(name, module->name) == 0) {
			TAILQ_REMOVE(&g_iobuf.modules, module, tailq);
			free(module->name);
			free(module);
			return 0;
		}
	}

	return -ENOENT;
}

int
spdk_iobuf_for_each_entry(struct spdk_iobuf_channel *ch, struct spdk_iobuf_pool *pool,
			  spdk_iobuf_for_each_entry_fn cb_fn, void *cb_ctx)
+1 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@
	spdk_iobuf_channel_init;
	spdk_iobuf_channel_fini;
	spdk_iobuf_register_module;
	spdk_iobuf_unregister_module;
	spdk_iobuf_for_each_entry;
	spdk_iobuf_entry_abort;
	spdk_iobuf_get;