correct macro function sf_service_init

rw_perf_optimization
YuQing 2022-09-03 10:03:09 +08:00
parent a0f16319e0
commit 5ee8ce8fe7
3 changed files with 15 additions and 10 deletions

View File

@ -104,7 +104,7 @@ static int load_network_parameters(IniFullContext *ini_ctx,
g_sf_global_vars.max_buff_size = g_sf_global_vars.max_pkg_size; g_sf_global_vars.max_buff_size = g_sf_global_vars.max_pkg_size;
} else { } else {
g_sf_global_vars.min_buff_size = iniGetByteCorrectValueEx(ini_ctx, g_sf_global_vars.min_buff_size = iniGetByteCorrectValueEx(ini_ctx,
"min_buff_size", SF_DEF_MIN_BUFF_SIZE, 1, 8192, "min_buff_size", SF_DEF_MIN_BUFF_SIZE, 1, 4096,
SF_MAX_NETWORK_BUFF_SIZE, true); SF_MAX_NETWORK_BUFF_SIZE, true);
g_sf_global_vars.max_buff_size = iniGetByteCorrectValueEx(ini_ctx, g_sf_global_vars.max_buff_size = iniGetByteCorrectValueEx(ini_ctx,
"max_buff_size", SF_DEF_MAX_BUFF_SIZE, 1, 8192, "max_buff_size", SF_DEF_MAX_BUFF_SIZE, 1, 8192,

View File

@ -50,17 +50,17 @@ int sf_service_init_ex2(SFContext *sf_context, const char *name,
thread_loop_callback, accept_done_callback, set_body_length_func, \ thread_loop_callback, accept_done_callback, set_body_length_func, \
deal_func, task_cleanup_func, timeout_callback, net_timeout_ms, \ deal_func, task_cleanup_func, timeout_callback, net_timeout_ms, \
proto_header_size, task_arg_size) \ proto_header_size, task_arg_size) \
sf_service_init_ex2(sf_context, name, alloc_thread_extra_data_callback, \ sf_service_init_ex2(sf_context, name, alloc_thread_extra_data_callback, \
thread_loop_callback, accept_done_callback, set_body_length_func, \ thread_loop_callback, accept_done_callback, set_body_length_func, \
deal_func, task_cleanup_func, timeout_callback, net_timeout_ms, \ NULL, deal_func, task_cleanup_func, timeout_callback, net_timeout_ms, \
proto_header_size, task_arg_size, NULL, NULL) proto_header_size, task_arg_size, NULL, NULL)
#define sf_service_init(name, alloc_thread_extra_data_callback, \ #define sf_service_init(name, alloc_thread_extra_data_callback, \
thread_loop_callback, accept_done_callback, set_body_length_func, \ thread_loop_callback, accept_done_callback, set_body_length_func, \
deal_func, task_cleanup_func, timeout_callback, net_timeout_ms, \ deal_func, task_cleanup_func, timeout_callback, net_timeout_ms, \
proto_header_size, task_arg_size) \ proto_header_size, task_arg_size) \
sf_service_init_ex2(&g_sf_context, name, alloc_thread_extra_data_callback, \ sf_service_init_ex2(&g_sf_context, name, alloc_thread_extra_data_callback, \
thread_loop_callback, accept_done_callback, set_body_length_func, \ thread_loop_callback, accept_done_callback, set_body_length_func, NULL, \
deal_func, task_cleanup_func, timeout_callback, net_timeout_ms, \ deal_func, task_cleanup_func, timeout_callback, net_timeout_ms, \
proto_header_size, task_arg_size, NULL, NULL) proto_header_size, task_arg_size, NULL, NULL)

View File

@ -70,13 +70,16 @@ static inline SFSharedMBuffer *sf_shared_mbuffer_alloc_ex(
fc_sleep_ms(sleep_ms); fc_sleep_ms(sleep_ms);
} }
logInfo("file: "__FILE__", line: %d, "
"alloc shared buffer: %p, buff: %p",
__LINE__, buffer, buffer->buff);
if (init_reffer_count > 0) { if (init_reffer_count > 0) {
__sync_add_and_fetch(&buffer->reffer_count, init_reffer_count); __sync_add_and_fetch(&buffer->reffer_count, init_reffer_count);
} }
/*
logInfo("file: "__FILE__", line: %d, "
"alloc shared buffer: %p, buff: %p, reffer_count: %d",
__LINE__, buffer, buffer->buff, __sync_add_and_fetch(&buffer->reffer_count, 0));
*/
return buffer; return buffer;
} }
@ -88,8 +91,10 @@ static inline void sf_shared_mbuffer_hold(SFSharedMBuffer *buffer)
static inline void sf_shared_mbuffer_release(SFSharedMBuffer *buffer) static inline void sf_shared_mbuffer_release(SFSharedMBuffer *buffer)
{ {
if (__sync_sub_and_fetch(&buffer->reffer_count, 1) == 0) { if (__sync_sub_and_fetch(&buffer->reffer_count, 1) == 0) {
/*
logInfo("file: "__FILE__", line: %d, " logInfo("file: "__FILE__", line: %d, "
"free shared buffer: %p", __LINE__, buffer); "free shared buffer: %p", __LINE__, buffer);
*/
fast_allocator_free(&buffer->ctx->allocator, buffer); fast_allocator_free(&buffer->ctx->allocator, buffer);
} }
} }