From 923ffea2e6d01ce88612773ac6e04f42f76b276e Mon Sep 17 00:00:00 2001 From: Andreas Economides Date: Thu, 2 Sep 2021 17:11:33 +0000 Subject: [PATCH] event: add disable_signal_handlers to the spdk_app_opts struct Currently, there is no way to prevent spdk_app_start() from calling app_setup_signal_handlers() and setting SPDK's signal handlers. We'd like to use our own set of signal handlers, therefore this patch adds a flag to the spdk_app_opts struct that disables this behaviour. Signed-off-by: Andreas Economides Change-Id: I61d7cd66527d819fd5f687d5cc8a03be4fe10a6a Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9380 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk Reviewed-by: Tomasz Zawadzki Reviewed-by: Ziye Yang Tested-by: SPDK CI Jenkins --- CHANGELOG.md | 4 ++++ include/spdk/event.h | 10 ++++++++++ lib/event/Makefile | 4 ++-- lib/event/app.c | 6 ++++-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c65d2e4ec..2fe156840 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,10 @@ SoC may be running SPDK on the SoC. That SoC has its own local memory, but SPDK devices that can also access the host system memory. This library provides infrastructure to enumerate the memory domains and request hardware perform DMA transfers between them. +### event + +Added the `disable_signal_handlers` flag to the `spdk_app_opts` struct. + ### log Added API `spdk_log_to_syslog_level` to return syslog level based on SPDK's diff --git a/include/spdk/event.h b/include/spdk/event.h index 74c946728..50978a587 100644 --- a/include/spdk/event.h +++ b/include/spdk/event.h @@ -137,6 +137,16 @@ struct spdk_app_opts { * After that, new added fields should be put after opts_size. */ size_t opts_size; + + /** + * Disable default signal handlers. + * If set to `true`, the shutdown process is not started implicitly by + * process signals, hence the application is responsible for calling + * spdk_app_start_shutdown(). + * + * Default is `false`. + */ + bool disable_signal_handlers; }; /** diff --git a/lib/event/Makefile b/lib/event/Makefile index 02b9664bc..6cbdab07b 100644 --- a/lib/event/Makefile +++ b/lib/event/Makefile @@ -34,8 +34,8 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..) include $(SPDK_ROOT_DIR)/mk/spdk.common.mk -SO_VER := 9 -SO_MINOR := 1 +SO_VER := 10 +SO_MINOR := 0 CFLAGS += $(ENV_CFLAGS) diff --git a/lib/event/app.c b/lib/event/app.c index cfdefd781..2a6d6b0e0 100644 --- a/lib/event/app.c +++ b/lib/event/app.c @@ -224,6 +224,7 @@ spdk_app_opts_init(struct spdk_app_opts *opts, size_t opts_size) SET_FIELD(rpc_addr, SPDK_DEFAULT_RPC_ADDR); SET_FIELD(num_entries, SPDK_APP_DEFAULT_NUM_TRACE_ENTRIES); SET_FIELD(delay_subsystem_init, false); + SET_FIELD(disable_signal_handlers, false); #undef SET_FIELD } @@ -460,10 +461,11 @@ app_copy_opts(struct spdk_app_opts *opts, struct spdk_app_opts *opts_user, size_ SET_FIELD(env_context); SET_FIELD(log); SET_FIELD(base_virtaddr); + SET_FIELD(disable_signal_handlers); /* You should not remove this statement, but need to update the assert statement * if you add a new field, and also add a corresponding SET_FIELD statement */ - SPDK_STATIC_ASSERT(sizeof(struct spdk_app_opts) == 184, "Incorrect size"); + SPDK_STATIC_ASSERT(sizeof(struct spdk_app_opts) == 192, "Incorrect size"); #undef SET_FIELD } @@ -569,7 +571,7 @@ spdk_app_start(struct spdk_app_opts *opts_user, spdk_msg_fn start_fn, return 1; } - if (app_setup_signal_handlers(opts) != 0) { + if (!opts->disable_signal_handlers && app_setup_signal_handlers(opts) != 0) { return 1; }