From 20e6f942cd8a45bd8846e90e6d2934f26b3a5303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E5=AE=A3=E6=AD=A3?= Date: Fri, 16 Apr 2021 17:07:15 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9Efix(hos=5Fset=5Fthread=5Fsum):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dfd=5Finfo=E5=BC=95=E8=B5=B7=E7=9A=84=E5=86=85?= =?UTF-8?q?=E5=AD=98=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hos_client.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/hos_client.cpp b/src/hos_client.cpp index 9e56bf2e..df298982 100644 --- a/src/hos_client.cpp +++ b/src/hos_client.cpp @@ -204,10 +204,6 @@ void hos_set_thread_sum(hos_client_handle client, size_t thread_sum) return; } - for (size_t i = 0; i < thread_sum; i++) - { - fd_info[i][0] = 65533; - } if (hos_cache) { hos_cache = (size_t *)realloc(hos_cache, thread_sum * sizeof(size_t)); @@ -221,6 +217,7 @@ void hos_set_thread_sum(hos_client_handle client, size_t thread_sum) { hash_hos_info = (hos_info_t **)calloc(thread_sum, sizeof(hos_info_t*)); } + if (fd_info) { fd_info = (size_t (*) [MAX_HOS_CLIENT_FD_NUM + 1])realloc(fd_info, thread_sum * sizeof(size_t [MAX_HOS_CLIENT_FD_NUM + 1])); @@ -228,6 +225,12 @@ void hos_set_thread_sum(hos_client_handle client, size_t thread_sum) { fd_info = (size_t (*) [MAX_HOS_CLIENT_FD_NUM + 1])calloc(thread_sum, sizeof(size_t [MAX_HOS_CLIENT_FD_NUM + 1])); } + + for (size_t i = 0; i < thread_sum; i++) + { + fd_info[i][0] = 65533; + } + client->thread_sum = thread_sum; return ; }