summaryrefslogtreecommitdiff
path: root/src/hos_client.cpp
diff options
context:
space:
mode:
author彭宣正 <[email protected]>2020-12-14 17:24:58 +0800
committer彭宣正 <[email protected]>2021-01-31 17:13:17 +0800
commit10b370e4869dae87c293aa58bcbbed7001a5d1c1 (patch)
tree299749f555b798f58f87da7c893bfa8004841da1 /src/hos_client.cpp
parent505d529c3284951f69b0d40a519aae1c5b3ee5ea (diff)
✨feat(hos_client_create, hos_client_destory): 多次调用destory不会导致重复释放
Diffstat (limited to 'src/hos_client.cpp')
-rw-r--r--src/hos_client.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/hos_client.cpp b/src/hos_client.cpp
index 18207471..39ac257b 100644
--- a/src/hos_client.cpp
+++ b/src/hos_client.cpp
@@ -61,6 +61,7 @@ typedef struct hos_client_handle_s
Aws::Vector<Aws::S3::Model::Bucket> buckets;
pthread_t fd_thread;
int fd_thread_status;
+ int count; /* 记录了有多少个对象在使用hos */
/* options */
size_t cache_size;
size_t cache_count;
@@ -190,6 +191,7 @@ hos_client_handle hos_client_create(const char *serverip, size_t port, const cha
if (hos_handle)
{
+ hos_handle->count++;
return hos_handle;
}
@@ -222,6 +224,7 @@ hos_client_handle hos_client_create(const char *serverip, size_t port, const cha
hos_handle->cache_count = 0;
hos_handle->thread_sum = 1;
hos_handle->timeout = 1000;
+ hos_handle->count++;
fd_info[0][0] = 65533;
fd_info[0][1] = 0;
@@ -328,6 +331,8 @@ void hos_expand_fs2(hos_client_handle handle, const char * path, int format, cha
char buff[128];
int i = 0;
+ if (handle->fs2_info[0].fs2_handle)
+ return;
//fs2 init
for (i = 0; i < 3; i++)
{
@@ -890,6 +895,11 @@ int hos_client_destory(hos_client_handle handle)
return HOS_PARAMETER_ERROR;
}
+ if (--handle->count)
+ {
+ return HOS_CLIENT_OK;
+ }
+
delete handle->S3Client;
Aws::Vector<Aws::S3::Model::Bucket>().swap(handle->buckets);