summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author彭宣正 <[email protected]>2021-07-06 10:27:36 +0800
committer彭宣正 <[email protected]>2021-07-06 10:27:36 +0800
commit68f7b08a72b8879ae93bce38e9762c64e818be68 (patch)
tree1091081f378b23ef2362d193108007f99beb8e06
parent696fcecb7c2a4d0bb5f908e3c4fd8b77ba830b0d (diff)
🐞 fix(src): 修复append模式下,未开启fs2导致的段错误v2.0.1
-rw-r--r--conf/main.conf5
-rw-r--r--example/performance/HosClientPerformance.cpp17
-rw-r--r--example/performance/conf/default.conf5
-rwxr-xr-xexample/performance/test.sh4
-rw-r--r--src/hos_client.cpp50
5 files changed, 48 insertions, 33 deletions
diff --git a/conf/main.conf b/conf/main.conf
index a37ad407..becaebd8 100644
--- a/conf/main.conf
+++ b/conf/main.conf
@@ -9,8 +9,9 @@ hos_poolsize=0 #default
hos_thread_sum=32 #default
hos_cache_size=102400 #default
hos_cache_count=10 #default
-hos_fd_live_time_ms=1000 #default
hos_fs2_serverip=127.0.0.1
hos_fs2_serverport=10086
hos_fs2_path="./tsglog/hos/hos_fs2_log" #default
-hos_fs2_format=0 #default \ No newline at end of file
+hos_fs2_format=0 #default
+hos_request_num=100 #default
+hos_requect_context=10240000 #default \ No newline at end of file
diff --git a/example/performance/HosClientPerformance.cpp b/example/performance/HosClientPerformance.cpp
index 6eb3b774..35dfc4e1 100644
--- a/example/performance/HosClientPerformance.cpp
+++ b/example/performance/HosClientPerformance.cpp
@@ -132,7 +132,7 @@ static int upload_file(char *file, char *buff, int buff_len, thread_info_t *thre
fp = fopen(file, "w+");
if (fp == NULL)
{
- printf("error:fopen failed\n");
+ perror("error:fopen failed\n");
return -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;
- 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",
thread_info->thread_num, file_size, time_write, time_upload, average, sqrt(variance));
-
+
return 0;
}
diff --git a/example/performance/conf/default.conf b/example/performance/conf/default.conf
index 9f80e557..551a1ab5 100644
--- a/example/performance/conf/default.conf
+++ b/example/performance/conf/default.conf
@@ -9,8 +9,9 @@ hos_poolsize=100 #default
hos_thread_sum=32 #default
hos_cache_size=102400 #default
hos_cache_count=10 #default
-hos_fd_live_time_ms=1000 #default
hos_fs2_serverip=127.0.0.1
hos_fs2_serverport=10086
hos_fs2_path="./hos_fs2_log" #default
-hos_fs2_format=0 #default \ No newline at end of file
+hos_fs2_format=0 #default
+hos_request_num=0
+hos_request_context=0
diff --git a/example/performance/test.sh b/example/performance/test.sh
index 16948150..5a291676 100755
--- a/example/performance/test.sh
+++ b/example/performance/test.sh
@@ -21,7 +21,7 @@ do
#./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
#./HosClientPerformance -a 100 -A -f ./file/100k.data -S ${size[$num]} -t 32
- echo ./HosClientPerformance -P1 -t32
- ./HosClientPerformance -P1 -t32
+ echo ./HosClientPerformance -t ${num} -f ../file/100.data
+ ./HosClientPerformance -t ${num} -f ../file/100.data
let "num++"
done
diff --git a/src/hos_client.cpp b/src/hos_client.cpp
index 89871232..7157501d 100644
--- a/src/hos_client.cpp
+++ b/src/hos_client.cpp
@@ -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_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);
- 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);
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;
}
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();
}
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_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);
*a_fd_context->cache << buffer;
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)
{
//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设置
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 = NULL;
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);
}
- ((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;
@@ -1128,24 +1132,22 @@ int hos_shutdown_instance()
}
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)
- free(data_info->rx_pkts);
- if (data_info->rx_bytes)
- free(data_info->rx_bytes);
- if (data_info->tx_pkts)
- free(data_info->tx_pkts);
- if (data_info->tx_bytes)
- free(data_info->tx_bytes);
- if (data_info->tx_failed_bytes)
- free(data_info->tx_failed_bytes);
- if (data_info->tx_failed_pkts);
- free(data_info->tx_failed_pkts);
- if (data_info->cache)
- free(data_info->cache);
- }
+ data_info_t *data_info = (data_info_t *)hos_func->fs2_info.reserved;
+ if (data_info->rx_pkts)
+ free(data_info->rx_pkts);
+ if (data_info->rx_bytes)
+ free(data_info->rx_bytes);
+ if (data_info->tx_pkts)
+ free(data_info->tx_pkts);
+ if (data_info->tx_bytes)
+ free(data_info->tx_bytes);
+ if (data_info->tx_failed_bytes)
+ free(data_info->tx_failed_bytes);
+ if (data_info->tx_failed_pkts)
+ ;
+ free(data_info->tx_failed_pkts);
+ if (data_info->cache)
+ free(data_info->cache);
free(hos_func->fs2_info.reserved);
hos_func->fs2_info.reserved = NULL;
}