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 <james.r.harris@intel.com>
Change-Id: I08af9d088980106cbb5fb22878be59da77b0520c

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466953
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Jim Harris 2019-08-30 03:10:21 -07:00
parent e8ecfe1711
commit dc6c3e08fb
2 changed files with 5 additions and 23 deletions

View File

@ -38,6 +38,6 @@ APP = hello_sock
C_SRCS := hello_sock.c C_SRCS := hello_sock.c
SPDK_LIB_LIST = $(SOCK_MODULES_LIST) 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 include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -116,13 +116,6 @@ static int hello_sock_parse_arg(int ch, char *arg)
return 0; 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 static int
hello_sock_close_timeout_poll(void *arg) 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_close(&ctx->sock);
spdk_sock_group_close(&ctx->group); spdk_sock_group_close(&ctx->group);
spdk_net_framework_fini(hello_sock_net_fini_cb, arg); spdk_app_stop(ctx->rc);
return 0; return 0;
} }
@ -382,15 +375,10 @@ hello_sock_shutdown_cb(void)
* Our initial event that kicks off everything from main(). * Our initial event that kicks off everything from main().
*/ */
static void static void
hello_start(void *arg1, int rc) hello_start(void *arg1)
{ {
struct hello_context_t *ctx = arg1; struct hello_context_t *ctx = arg1;
int rc;
if (rc) {
SPDK_ERRLOG("ERROR starting application\n");
spdk_app_stop(-1);
return;
}
SPDK_NOTICELOG("Successfully started the application\n"); 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 int
main(int argc, char **argv) main(int argc, char **argv)
{ {
@ -433,7 +415,7 @@ main(int argc, char **argv)
hello_context.port = g_port; hello_context.port = g_port;
hello_context.verbose = g_verbose; 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) { if (rc) {
SPDK_ERRLOG("ERROR starting application\n"); SPDK_ERRLOG("ERROR starting application\n");
} }