From dc6c3e08fb7afaf11d11d2d49b6e0e4e7ccb8c84 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 30 Aug 2019 03:10:21 -0700 Subject: [PATCH] examples/sock: make hello_sock leverage net subsystem hello_sock was taking responsibility for initializing the net framework by calling spdk_net_framework_init directly. But since this application is already using the spdk app framework, it's much easier to just link in the event_net and net libraries which will activate the "net" subsystem automatically. Signed-off-by: Jim Harris Change-Id: I08af9d088980106cbb5fb22878be59da77b0520c Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466953 Reviewed-by: Changpeng Liu Reviewed-by: Paul Luse Reviewed-by: Shuhei Matsumoto Reviewed-by: Broadcom SPDK FC-NVMe CI Tested-by: SPDK CI Jenkins --- examples/sock/hello_world/Makefile | 2 +- examples/sock/hello_world/hello_sock.c | 26 ++++---------------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/examples/sock/hello_world/Makefile b/examples/sock/hello_world/Makefile index 43ce98e0e..e326bf26b 100644 --- a/examples/sock/hello_world/Makefile +++ b/examples/sock/hello_world/Makefile @@ -38,6 +38,6 @@ APP = hello_sock C_SRCS := hello_sock.c SPDK_LIB_LIST = $(SOCK_MODULES_LIST) -SPDK_LIB_LIST += event thread util conf trace log jsonrpc json rpc sock notify +SPDK_LIB_LIST += event_net net event thread util conf trace log jsonrpc json rpc sock notify include $(SPDK_ROOT_DIR)/mk/spdk.app.mk diff --git a/examples/sock/hello_world/hello_sock.c b/examples/sock/hello_world/hello_sock.c index 1002e3ee9..fcacabbf5 100644 --- a/examples/sock/hello_world/hello_sock.c +++ b/examples/sock/hello_world/hello_sock.c @@ -116,13 +116,6 @@ static int hello_sock_parse_arg(int ch, char *arg) return 0; } -static void -hello_sock_net_fini_cb(void *cb_arg) -{ - struct hello_context_t *ctx = cb_arg; - spdk_app_stop(ctx->rc); -} - static int hello_sock_close_timeout_poll(void *arg) { @@ -134,7 +127,7 @@ hello_sock_close_timeout_poll(void *arg) spdk_sock_close(&ctx->sock); spdk_sock_group_close(&ctx->group); - spdk_net_framework_fini(hello_sock_net_fini_cb, arg); + spdk_app_stop(ctx->rc); return 0; } @@ -382,15 +375,10 @@ hello_sock_shutdown_cb(void) * Our initial event that kicks off everything from main(). */ static void -hello_start(void *arg1, int rc) +hello_start(void *arg1) { struct hello_context_t *ctx = arg1; - - if (rc) { - SPDK_ERRLOG("ERROR starting application\n"); - spdk_app_stop(-1); - return; - } + int rc; SPDK_NOTICELOG("Successfully started the application\n"); @@ -406,12 +394,6 @@ hello_start(void *arg1, int rc) } } -static void -start_net_framework(void *arg1) -{ - spdk_net_framework_start(hello_start, arg1); -} - int main(int argc, char **argv) { @@ -433,7 +415,7 @@ main(int argc, char **argv) hello_context.port = g_port; hello_context.verbose = g_verbose; - rc = spdk_app_start(&opts, start_net_framework, &hello_context); + rc = spdk_app_start(&opts, hello_start, &hello_context); if (rc) { SPDK_ERRLOG("ERROR starting application\n"); }