declare use_io_uring correctly

master
YuQing 2025-11-04 15:55:33 +08:00
parent fa32972052
commit c4af33a497
2 changed files with 9 additions and 3 deletions

View File

@ -47,9 +47,9 @@ SFGlobalVariables g_sf_global_vars = {
{0, 0}, NULL, {NULL, 0} {0, 0}, NULL, {NULL, 0}
}; };
SFContext g_sf_context = {{'\0'}, NULL, 0, false, SFContext g_sf_context = {{'\0'}, NULL, 0, false, false,
#if IOEVENT_USE_URING #if IOEVENT_USE_URING
false, false, false,
#endif #endif
sf_address_family_auto, {{AF_UNSPEC, {{true, fc_comm_type_sock}, sf_address_family_auto, {{AF_UNSPEC, {{true, fc_comm_type_sock},
{false, fc_comm_type_rdma}}}, {false, fc_comm_type_rdma}}},
@ -673,8 +673,10 @@ int sf_load_context_from_config_ex(SFContext *sf_context,
int inner_port; int inner_port;
int outer_port; int outer_port;
int port; int port;
#if IOEVENT_USE_URING
bool global_use_send_zc; bool global_use_send_zc;
bool use_send_zc; bool use_send_zc;
#endif
int i; int i;
int result; int result;
@ -711,6 +713,7 @@ int sf_load_context_from_config_ex(SFContext *sf_context,
outer_port = config->default_outer_port; outer_port = config->default_outer_port;
} }
#if IOEVENT_USE_URING
global_use_send_zc = iniGetBoolValue(NULL, "use_send_zc", global_use_send_zc = iniGetBoolValue(NULL, "use_send_zc",
config->ini_ctx.context, true); config->ini_ctx.context, true);
if (config->ini_ctx.section_name == NULL) { if (config->ini_ctx.section_name == NULL) {
@ -719,6 +722,7 @@ int sf_load_context_from_config_ex(SFContext *sf_context,
use_send_zc = iniGetBoolValue(config->ini_ctx.section_name, use_send_zc = iniGetBoolValue(config->ini_ctx.section_name,
"use_send_zc", config->ini_ctx.context, global_use_send_zc); "use_send_zc", config->ini_ctx.context, global_use_send_zc);
} }
#endif
for (i=0; i<SF_ADDRESS_FAMILY_COUNT; i++) { for (i=0; i<SF_ADDRESS_FAMILY_COUNT; i++) {
fh = sf_context->handlers + i; fh = sf_context->handlers + i;
@ -767,6 +771,8 @@ int sf_load_context_from_config_ex(SFContext *sf_context,
#if IOEVENT_USE_URING #if IOEVENT_USE_URING
sf_context->use_io_uring = (config->comm_type == fc_comm_type_sock); sf_context->use_io_uring = (config->comm_type == fc_comm_type_sock);
sf_context->use_send_zc = use_send_zc; sf_context->use_send_zc = use_send_zc;
#else
sf_context->use_io_uring = false;
#endif #endif
sf_context->accept_threads = iniGetIntValue( sf_context->accept_threads = iniGetIntValue(

View File

@ -181,8 +181,8 @@ typedef struct sf_context {
volatile int thread_count; volatile int thread_count;
bool is_client; //since v1.2.5 bool is_client; //since v1.2.5
#if IOEVENT_USE_URING
bool use_io_uring; //since v1.2.9 bool use_io_uring; //since v1.2.9
#if IOEVENT_USE_URING
bool use_send_zc; //since v1.2.9 bool use_send_zc; //since v1.2.9
#endif #endif
SFAddressFamily address_family; SFAddressFamily address_family;