summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author彭宣正 <[email protected]>2021-04-07 17:53:15 +0800
committer彭宣正 <[email protected]>2021-04-07 17:56:27 +0800
commit73c2ddb4767e501c3e05108a8fee1f24fb8e4cb3 (patch)
tree9effdbaa27b26ebac9a5554716f623d39c2f7974 /src
parente4360cf6334563054f6090d009cb947c31f6769b (diff)
✨feat(hos_client_create和hos_client_destory): 添加只能锁,保证create和destory不被打断v1.0.20
Diffstat (limited to 'src')
-rw-r--r--src/hos_client.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/hos_client.cpp b/src/hos_client.cpp
index 47224f54..b98bbd8a 100644
--- a/src/hos_client.cpp
+++ b/src/hos_client.cpp
@@ -79,6 +79,7 @@ typedef struct hos_client_handle_s
#define HOS_FS2_STOP 2
}hos_client_handle_t;
+std::mutex m_client_lock; /* create和destroy操作时使用的锁 */
hos_client_handle g_hos_handle;//一个进程只允许有一个g_hos_handle
//hos_info_t *hash_hos_info[MAX_HOS_CLIENT_THREAD_NUM];
hos_info_t **hash_hos_info;
@@ -231,6 +232,7 @@ void hos_set_thread_sum(hos_client_handle client, size_t thread_sum)
hos_client_handle hos_client_create(const char *serverip, size_t port, const char *accesskeyid, const char *secretkey, size_t pool_size)
{
+ std::lock_guard<std::mutex> locker(m_client_lock);
if (!serverip || !accesskeyid || !secretkey)
{
g_hos_error_num = HOS_PARAMETER_ERROR;
@@ -990,6 +992,7 @@ int hos_close_fd(size_t fd, size_t thread_id)
int hos_client_destory(hos_client_handle handle)
{
+ std::lock_guard<std::mutex> locker(m_client_lock);
size_t i = 0;
if (handle == NULL)
{