From 73c2ddb4767e501c3e05108a8fee1f24fb8e4cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E5=AE=A3=E6=AD=A3?= Date: Wed, 7 Apr 2021 17:53:15 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8feat(hos=5Fclient=5Fcreate=E5=92=8Chos?= =?UTF-8?q?=5Fclient=5Fdestory):=20=E6=B7=BB=E5=8A=A0=E5=8F=AA=E8=83=BD?= =?UTF-8?q?=E9=94=81=EF=BC=8C=E4=BF=9D=E8=AF=81create=E5=92=8Cdestory?= =?UTF-8?q?=E4=B8=8D=E8=A2=AB=E6=89=93=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hos_client.cpp | 3 +++ 1 file changed, 3 insertions(+) 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 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 locker(m_client_lock); size_t i = 0; if (handle == NULL) {