🐞 fix(src): 修复append模式下,未开启fs2导致的段错误
This commit is contained in:
@@ -9,8 +9,9 @@ hos_poolsize=0 #default
|
|||||||
hos_thread_sum=32 #default
|
hos_thread_sum=32 #default
|
||||||
hos_cache_size=102400 #default
|
hos_cache_size=102400 #default
|
||||||
hos_cache_count=10 #default
|
hos_cache_count=10 #default
|
||||||
hos_fd_live_time_ms=1000 #default
|
|
||||||
hos_fs2_serverip=127.0.0.1
|
hos_fs2_serverip=127.0.0.1
|
||||||
hos_fs2_serverport=10086
|
hos_fs2_serverport=10086
|
||||||
hos_fs2_path="./tsglog/hos/hos_fs2_log" #default
|
hos_fs2_path="./tsglog/hos/hos_fs2_log" #default
|
||||||
hos_fs2_format=0 #default
|
hos_fs2_format=0 #default
|
||||||
|
hos_request_num=100 #default
|
||||||
|
hos_requect_context=10240000 #default
|
||||||
@@ -132,7 +132,7 @@ static int upload_file(char *file, char *buff, int buff_len, thread_info_t *thre
|
|||||||
fp = fopen(file, "w+");
|
fp = fopen(file, "w+");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
{
|
{
|
||||||
printf("error:fopen failed\n");
|
perror("error:fopen failed\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (fwrite(buff, buff_len, 1, fp) != 1)
|
if (fwrite(buff, buff_len, 1, fp) != 1)
|
||||||
@@ -177,10 +177,21 @@ static int upload_file(char *file, char *buff, int buff_len, thread_info_t *thre
|
|||||||
}
|
}
|
||||||
variance /= g_test_count;
|
variance /= g_test_count;
|
||||||
|
|
||||||
sprintf(file_size, "%dk", buff_len / 1024);
|
if (buff_len > 1024 * 1024)
|
||||||
|
{
|
||||||
|
sprintf(file_size, "%gM", (double)buff_len / 1024 / 1024);
|
||||||
|
}
|
||||||
|
else if (buff_len > 1024)
|
||||||
|
{
|
||||||
|
sprintf(file_size, "%gK", (double)buff_len / 1024);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf(file_size, "%dB", buff_len);
|
||||||
|
}
|
||||||
sprintf(&performance_info[len], "%-20lu%-20s%-20ld%-20ld%-20lf%-20lf\n",
|
sprintf(&performance_info[len], "%-20lu%-20s%-20ld%-20ld%-20lf%-20lf\n",
|
||||||
thread_info->thread_num, file_size, time_write, time_upload, average, sqrt(variance));
|
thread_info->thread_num, file_size, time_write, time_upload, average, sqrt(variance));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ hos_poolsize=100 #default
|
|||||||
hos_thread_sum=32 #default
|
hos_thread_sum=32 #default
|
||||||
hos_cache_size=102400 #default
|
hos_cache_size=102400 #default
|
||||||
hos_cache_count=10 #default
|
hos_cache_count=10 #default
|
||||||
hos_fd_live_time_ms=1000 #default
|
|
||||||
hos_fs2_serverip=127.0.0.1
|
hos_fs2_serverip=127.0.0.1
|
||||||
hos_fs2_serverport=10086
|
hos_fs2_serverport=10086
|
||||||
hos_fs2_path="./hos_fs2_log" #default
|
hos_fs2_path="./hos_fs2_log" #default
|
||||||
hos_fs2_format=0 #default
|
hos_fs2_format=0 #default
|
||||||
|
hos_request_num=0
|
||||||
|
hos_request_context=0
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ do
|
|||||||
#./HosClientPerformance -a 100 -A -f ./file/100k.data -t ${size[$num]} -S 1024
|
#./HosClientPerformance -a 100 -A -f ./file/100k.data -t ${size[$num]} -S 1024
|
||||||
#echo ./HosClientPerformance -a 100 -A -f ./file/100k.data -S ${size[$num]} -t 32
|
#echo ./HosClientPerformance -a 100 -A -f ./file/100k.data -S ${size[$num]} -t 32
|
||||||
#./HosClientPerformance -a 100 -A -f ./file/100k.data -S ${size[$num]} -t 32
|
#./HosClientPerformance -a 100 -A -f ./file/100k.data -S ${size[$num]} -t 32
|
||||||
echo ./HosClientPerformance -P1 -t32
|
echo ./HosClientPerformance -t ${num} -f ../file/100.data
|
||||||
./HosClientPerformance -P1 -t32
|
./HosClientPerformance -t ${num} -f ../file/100.data
|
||||||
let "num++"
|
let "num++"
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -605,7 +605,7 @@ hos_instance hos_init_instance(const char *conf_path, const char *module, size_t
|
|||||||
MESA_load_profile_uint_def(conf_path, module, "hos_fs2_format", &hos_conf->fs2_fmt, 0);
|
MESA_load_profile_uint_def(conf_path, module, "hos_fs2_format", &hos_conf->fs2_fmt, 0);
|
||||||
MESA_load_profile_uint_def(conf_path, module, "hos_request_num", &hos_conf->max_request_num, 100);
|
MESA_load_profile_uint_def(conf_path, module, "hos_request_num", &hos_conf->max_request_num, 100);
|
||||||
MESA_load_profile_uint_def(conf_path, module, "hos_request_context", &hos_conf->max_request_context, 10240000);
|
MESA_load_profile_uint_def(conf_path, module, "hos_request_context", &hos_conf->max_request_context, 10240000);
|
||||||
if (hos_conf->ip && hos_conf->port && strlen(hos_conf->accesskeyid) && strlen(hos_conf->secretkey))
|
if (strlen(hos_conf->ip) && hos_conf->port && strlen(hos_conf->accesskeyid) && strlen(hos_conf->secretkey))
|
||||||
{
|
{
|
||||||
g_hos_handle.log = MESA_create_runtime_log_handle(hos_conf->log_path, hos_conf->log_level);
|
g_hos_handle.log = MESA_create_runtime_log_handle(hos_conf->log_path, hos_conf->log_level);
|
||||||
if (g_hos_handle.log == NULL)
|
if (g_hos_handle.log == NULL)
|
||||||
@@ -631,13 +631,13 @@ hos_instance hos_init_instance(const char *conf_path, const char *module, size_t
|
|||||||
return &g_hos_instance;
|
return &g_hos_instance;
|
||||||
}
|
}
|
||||||
MESA_HANDLE_RUNTIME_LOG(g_hos_handle.log, RLOG_LV_DEBUG, __FUNCTION__, "debug:%s","Instance init completed");
|
MESA_HANDLE_RUNTIME_LOG(g_hos_handle.log, RLOG_LV_DEBUG, __FUNCTION__, "debug:%s","Instance init completed");
|
||||||
if (hos_conf->fs2_ip && hos_conf->fs2_port)
|
if (strlen(hos_conf->fs2_ip) && hos_conf->fs2_port)
|
||||||
{
|
{
|
||||||
hos_expand_fs2();
|
hos_expand_fs2();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MESA_HANDLE_RUNTIME_LOG(g_hos_handle.log, RLOG_LV_FATAL, __FUNCTION__,"error: hos fs2 function not starup");
|
MESA_HANDLE_RUNTIME_LOG(g_hos_handle.log, RLOG_LV_DEBUG, __FUNCTION__,"error: hos fs2 function not starup");
|
||||||
}
|
}
|
||||||
g_hos_instance.error_code = 0;
|
g_hos_instance.error_code = 0;
|
||||||
g_hos_instance.error_message[0]='\0';
|
g_hos_instance.error_message[0]='\0';
|
||||||
@@ -903,7 +903,8 @@ int hos_write(size_t fd, const char *stream, size_t stream_len, size_t thread_id
|
|||||||
Aws::String buffer(stream, stream_len);
|
Aws::String buffer(stream, stream_len);
|
||||||
*a_fd_context->cache << buffer;
|
*a_fd_context->cache << buffer;
|
||||||
a_fd_context->cache_rest -= stream_len;
|
a_fd_context->cache_rest -= stream_len;
|
||||||
data_info->cache[thread_id] += stream_len;
|
if (data_info != NULL)
|
||||||
|
data_info->cache[thread_id] += stream_len;
|
||||||
if (a_fd_context->cache_count == 0 || --a_fd_context->cache_count)
|
if (a_fd_context->cache_count == 0 || --a_fd_context->cache_count)
|
||||||
{
|
{
|
||||||
//cache_count == 0,不设置cache_count的情况
|
//cache_count == 0,不设置cache_count的情况
|
||||||
@@ -977,7 +978,8 @@ int hos_write(size_t fd, const char *stream, size_t stream_len, size_t thread_id
|
|||||||
//恢复fd 的cache设置
|
//恢复fd 的cache设置
|
||||||
if (a_fd_context->mode & APPEND_MODE)
|
if (a_fd_context->mode & APPEND_MODE)
|
||||||
{
|
{
|
||||||
data_info->cache[thread_id] -= upload_len;
|
if (data_info)
|
||||||
|
data_info->cache[thread_id] -= upload_len;
|
||||||
a_fd_context->cache.reset();
|
a_fd_context->cache.reset();
|
||||||
a_fd_context->cache = NULL;
|
a_fd_context->cache = NULL;
|
||||||
a_fd_context->cache_rest = hos_conf->cache_size;
|
a_fd_context->cache_rest = hos_conf->cache_size;
|
||||||
@@ -1045,7 +1047,9 @@ int hos_close_fd(size_t fd, size_t thread_id)
|
|||||||
{
|
{
|
||||||
hos_putobject_sync(request, upload_len, thread_id, fd, a_fd_context->bucket, a_fd_context->object);
|
hos_putobject_sync(request, upload_len, thread_id, fd, a_fd_context->bucket, a_fd_context->object);
|
||||||
}
|
}
|
||||||
((data_info_t *)(g_hos_handle.hos_func.fs2_info.reserved))->cache[thread_id] = 0;
|
data_info_t *data_info = (data_info_t *)(g_hos_handle.hos_func.fs2_info.reserved);
|
||||||
|
if (data_info)
|
||||||
|
data_info->cache[thread_id] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a_fd_context->fd_status = HOS_FD_INJECT;
|
a_fd_context->fd_status = HOS_FD_INJECT;
|
||||||
@@ -1128,24 +1132,22 @@ int hos_shutdown_instance()
|
|||||||
}
|
}
|
||||||
if (hos_func->fs2_info.reserved)
|
if (hos_func->fs2_info.reserved)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
data_info_t *data_info = (data_info_t *)hos_func->fs2_info.reserved;
|
||||||
{
|
if (data_info->rx_pkts)
|
||||||
data_info_t * data_info = (data_info_t *)hos_func->fs2_info.reserved;
|
free(data_info->rx_pkts);
|
||||||
if (data_info->rx_pkts)
|
if (data_info->rx_bytes)
|
||||||
free(data_info->rx_pkts);
|
free(data_info->rx_bytes);
|
||||||
if (data_info->rx_bytes)
|
if (data_info->tx_pkts)
|
||||||
free(data_info->rx_bytes);
|
free(data_info->tx_pkts);
|
||||||
if (data_info->tx_pkts)
|
if (data_info->tx_bytes)
|
||||||
free(data_info->tx_pkts);
|
free(data_info->tx_bytes);
|
||||||
if (data_info->tx_bytes)
|
if (data_info->tx_failed_bytes)
|
||||||
free(data_info->tx_bytes);
|
free(data_info->tx_failed_bytes);
|
||||||
if (data_info->tx_failed_bytes)
|
if (data_info->tx_failed_pkts)
|
||||||
free(data_info->tx_failed_bytes);
|
;
|
||||||
if (data_info->tx_failed_pkts);
|
free(data_info->tx_failed_pkts);
|
||||||
free(data_info->tx_failed_pkts);
|
if (data_info->cache)
|
||||||
if (data_info->cache)
|
free(data_info->cache);
|
||||||
free(data_info->cache);
|
|
||||||
}
|
|
||||||
free(hos_func->fs2_info.reserved);
|
free(hos_func->fs2_info.reserved);
|
||||||
hos_func->fs2_info.reserved = NULL;
|
hos_func->fs2_info.reserved = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user