summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpengxuanzheng <[email protected]>2021-10-22 21:10:38 +0800
committerpengxuanzheng <[email protected]>2021-10-22 21:14:43 +0800
commit31c56eda0ad70c44eaf7585e39863eae76bb7e73 (patch)
tree2f2f13aa154b5881a1ac1a1b83a0e102a7fe8fc7 /src
parent400c33e92eddfa0e54ed093ce9a23380789c34a9 (diff)
🐞 fix(TSG-8143): 修复hos启动异常,提前shutdown导致的段错误v3.0.2feature-tsg-8428
Diffstat (limited to 'src')
-rw-r--r--src/hos_client.cpp21
-rw-r--r--src/hos_common.h1
2 files changed, 16 insertions, 6 deletions
diff --git a/src/hos_client.cpp b/src/hos_client.cpp
index 3266fd53..33e15e50 100644
--- a/src/hos_client.cpp
+++ b/src/hos_client.cpp
@@ -199,8 +199,7 @@ static int hos_attempt_connection()
else
{
atomic_set(&g_hos_handle.count, 0);//立即shutdown
- hos_shutdown_instance();
- g_hos_instance.status = INSTANCE_UNINIT_STATE;
+ g_hos_instance.status = INSTANCE_DISABLE_STATE;
g_hos_instance.error_code = (size_t)outcome.GetError().GetErrorType() + 1;
snprintf(g_hos_instance.error_message, HOS_ERROR_MESSAGE_SIZE, outcome.GetError().GetMessage().c_str());
}
@@ -470,16 +469,21 @@ static void hos_client_create()
g_hos_handle.S3Client = new Aws::S3::S3ClientMock(g_credentials, *g_client_config, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, false);
#endif
+ g_hos_instance.hos_url_prefix = g_client_config->endpointOverride.c_str();
+ //hos 检测服务端是否可以连接上
+ int ret = hos_attempt_connection();
+ if (ret != HOS_CLIENT_OK && ret != NETWORK_CONNECTION)
+ {
+ return;
+ }
+
atomic_add(&g_hos_handle.count, 1);
g_hos_handle.task_num = (size_t *)calloc(hos_conf->thread_num, sizeof(size_t));
g_hos_handle.task_context = (size_t *)calloc(hos_conf->thread_num, sizeof(size_t));
- g_hos_instance.hos_url_prefix = g_client_config->endpointOverride.c_str();
MESA_HANDLE_RUNTIME_LOG(g_hos_handle.log, RLOG_LV_INFO, __FUNCTION__, "[%s] debug: hos s3client create success.",g_hos_instance.hos_url_prefix);
hos_expand_fs2();
- //hos 检测服务端是否可以连接上
- hos_attempt_connection();
if (g_hos_handle.hos_func.hos_client_retry_thread_id == 0)
{
@@ -712,8 +716,9 @@ hos_instance hos_init_instance(const char *conf_path, const char *module, size_t
hos_conf->thread_num = thread_num;
hos_client_create();
- if (atomic_read(&g_hos_instance.status) == INSTANCE_UNINIT_STATE)
+ if (atomic_read(&g_hos_instance.status) == INSTANCE_DISABLE_STATE)
{
+ hos_shutdown_instance();
return NULL;
}
return &g_hos_instance;
@@ -1165,6 +1170,10 @@ int hos_shutdown_instance()
while(1)
{
task_num = 0;
+ if (g_hos_handle.task_num == NULL)
+ {
+ break;
+ }
for (uint32_t i = 0; i < g_hos_handle.hos_config.thread_num; i++)
{
task_num += atomic_read(&g_hos_handle.task_num[i]);
diff --git a/src/hos_common.h b/src/hos_common.h
index 54842cf0..198774b5 100644
--- a/src/hos_common.h
+++ b/src/hos_common.h
@@ -31,6 +31,7 @@ typedef struct hos_instance_s{
#define INSTANCE_UNINIT_STATE 0
#define INSTANCE_ATTEMPT_STATE 1
#define INSTANCE_ENABLE_STATE 2
+#define INSTANCE_DISABLE_STATE 3
int status;
int error_code;
char error_message[1024];