summaryrefslogtreecommitdiff
path: root/src/hos_client.cpp
diff options
context:
space:
mode:
author彭宣正 <[email protected]>2021-06-02 15:49:24 +0800
committer彭宣正 <[email protected]>2021-06-02 15:51:06 +0800
commitda3bc1db06ef3ecd2aa76ffe58e5b14e5828f3c7 (patch)
tree070e78d0fdd69538271996e0a4c70741b86c6270 /src/hos_client.cpp
parent20e6f942cd8a45bd8846e90e6d2934f26b3a5303 (diff)
修复add_hos_info导致的segment faultv1.0.25
Diffstat (limited to 'src/hos_client.cpp')
-rw-r--r--src/hos_client.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/hos_client.cpp b/src/hos_client.cpp
index df298982..49d73c77 100644
--- a/src/hos_client.cpp
+++ b/src/hos_client.cpp
@@ -221,6 +221,7 @@ void hos_set_thread_sum(hos_client_handle client, size_t thread_sum)
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]));
+ memset(&fd_info[client->thread_sum], 0, (thread_sum - client->thread_sum) * sizeof(size_t [MAX_HOS_CLIENT_FD_NUM + 1]));
}else
{
fd_info = (size_t (*) [MAX_HOS_CLIENT_FD_NUM + 1])calloc(thread_sum, sizeof(size_t [MAX_HOS_CLIENT_FD_NUM + 1]));
@@ -743,7 +744,7 @@ static void *hos_fd_manage(void *ptr)
int hos_open_fd(hos_client_handle handle, const char *bucket, const char *object, put_finished_callback callback, void *userdata, size_t thread_id, int mode)
{
- if ((handle == NULL) || (bucket == NULL) || (object == NULL) || (thread_id > handle->thread_sum))
+ if ((handle == NULL) || (bucket == NULL) || (object == NULL) || (thread_id > handle->thread_sum) || strlen(bucket) == 0 || strlen(object) == 0)
{
return HOS_PARAMETER_ERROR;
}
@@ -760,6 +761,7 @@ int hos_open_fd(hos_client_handle handle, const char *bucket, const char *object
#if 1
if (handle->fd_thread == 0)
{
+ std::lock_guard<std::mutex> locker(m_client_lock);
handle->fd_thread_status = 0;
pthread_create(&handle->fd_thread, NULL, hos_fd_manage, handle);
}