From a8edbd86224cce435499eb4c58e851e9403fc31f Mon Sep 17 00:00:00 2001 From: LiuBingrun Date: Sun, 2 Jul 2023 09:56:59 +0800 Subject: [PATCH] fix streamuplod not working (#2204) fuse_main will do fork to daemonize. if ThreadPool is created before this, worker thread will not be placed in child process. Move ThreadPool Init to s3fs_init and destory to s3fs_destory. Signed-off-by: liubingrun --- src/s3fs.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/s3fs.cpp b/src/s3fs.cpp index aea667d..8b0c785 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -4241,6 +4241,11 @@ static void* s3fs_init(struct fuse_conn_info* conn) conn->want |= FUSE_CAP_BIG_WRITES; } + if(!ThreadPoolMan::Initialize(max_thread_count)){ + S3FS_PRN_CRIT("Could not create thread pool(%d)", max_thread_count); + s3fs_exit_fuseloop(EXIT_FAILURE); + } + // Signal object if(!S3fsSignals::Initialize()){ S3FS_PRN_ERR("Failed to initialize signal object, but continue..."); @@ -4258,6 +4263,8 @@ static void s3fs_destroy(void*) S3FS_PRN_WARN("Failed to clean up signal object."); } + ThreadPoolMan::Destroy(); + // cache(remove at last) if(is_remove_cache && (!CacheFileStat::DeleteCacheFileStatDirectory() || !FdManager::DeleteCacheDirectory())){ S3FS_PRN_WARN("Could not remove cache directory."); @@ -5664,15 +5671,6 @@ int main(int argc, char* argv[]) max_dirty_data = -1; } - if(!ThreadPoolMan::Initialize(max_thread_count)){ - S3FS_PRN_EXIT("Could not create thread pool(%d)", max_thread_count); - S3fsCurl::DestroyS3fsCurl(); - s3fs_destroy_global_ssl(); - destroy_parser_xml_lock(); - destroy_basename_lock(); - exit(EXIT_FAILURE); - } - // check free disk space if(!FdManager::IsSafeDiskSpace(NULL, S3fsCurl::GetMultipartSize() * S3fsCurl::GetMaxParallelCount())){ S3FS_PRN_EXIT("There is no enough disk space for used as cache(or temporary) directory by s3fs."); @@ -5736,9 +5734,6 @@ int main(int argc, char* argv[]) } fuse_opt_free_args(&custom_args); - // Destroy thread pool - ThreadPoolMan::Destroy(); - // Destroy curl if(!S3fsCurl::DestroyS3fsCurl()){ S3FS_PRN_WARN("Could not release curl library.");