Skip to content

Commit

Permalink
Merge pull request #255 from haiwen/add_named_pipe_server_thread_pool
Browse files Browse the repository at this point in the history
Add named pipe server thread pool.
  • Loading branch information
killing committed Sep 11, 2019
2 parents f097af5 + 14d8628 commit a33525c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 40 deletions.
5 changes: 4 additions & 1 deletion server/seaf-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ static void usage ()

#define SEAFILE_RPC_PIPE_NAME "seafile.sock"

#define NAMED_PIPE_SERVER_THREAD_POOL_SIZE 50

static void start_rpc_service (const char *seafile_dir)
{
SearpcNamedPipeServer *rpc_server = NULL;
Expand Down Expand Up @@ -756,7 +758,8 @@ static void start_rpc_service (const char *seafile_dir)
searpc_signature_int__string_string_int());

pipe_path = g_build_path ("/", seafile_dir, SEAFILE_RPC_PIPE_NAME, NULL);
rpc_server = searpc_create_named_pipe_server(pipe_path);
rpc_server = searpc_create_named_pipe_server(pipe_path, NAMED_PIPE_SERVER_THREAD_POOL_SIZE);

g_free(pipe_path);
if (!rpc_server) {
seaf_warning ("Failed to create rpc server.\n");
Expand Down
37 changes: 1 addition & 36 deletions server/seafile-session.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
#define CONNECT_INTERVAL_MSEC 10 * 1000

#define DEFAULT_THREAD_POOL_SIZE 500
#define DEFAULT_RPC_THREAD_POOL_SIZE 10

static int
load_thread_pool_config (SeafileSession *session);

SeafileSession *
seafile_session_new(const char *central_config_dir,
Expand Down Expand Up @@ -99,12 +95,6 @@ seafile_session_new(const char *central_config_dir,
session->cfg_mgr = seaf_cfg_manager_new (session);
if (!session->cfg_mgr)
goto onerror;

if (load_thread_pool_config (session) < 0) {
seaf_warning ("Failed to load thread pool config.\n");
goto onerror;
}

session->fs_mgr = seaf_fs_manager_new (session, abs_seafile_dir);
if (!session->fs_mgr)
goto onerror;
Expand Down Expand Up @@ -141,7 +131,7 @@ seafile_session_new(const char *central_config_dir,
if (!session->copy_mgr)
goto onerror;

session->job_mgr = ccnet_job_manager_new (session->sync_thread_pool_size);
session->job_mgr = ccnet_job_manager_new (DEFAULT_THREAD_POOL_SIZE);

session->size_sched = size_scheduler_new (session);

Expand Down Expand Up @@ -239,31 +229,6 @@ seafile_session_start (SeafileSession *session)
return 0;
}

static int
load_thread_pool_config (SeafileSession *session)
{
int rpc_tp_size, sync_tp_size;

rpc_tp_size = g_key_file_get_integer (session->config,
"thread pool size", "rpc",
NULL);
sync_tp_size = g_key_file_get_integer (session->config,
"thread pool size", "sync",
NULL);

if (rpc_tp_size > 0)
session->rpc_thread_pool_size = rpc_tp_size;
else
session->rpc_thread_pool_size = DEFAULT_RPC_THREAD_POOL_SIZE;

if (sync_tp_size > 0)
session->sync_thread_pool_size = sync_tp_size;
else
session->sync_thread_pool_size = DEFAULT_THREAD_POOL_SIZE;

return 0;
}

char *
get_system_default_repo_id (SeafileSession *session)
{
Expand Down
3 changes: 0 additions & 3 deletions server/seafile-session.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ struct _SeafileSession {

int cloud_mode;

int rpc_thread_pool_size;
int sync_thread_pool_size;

HttpServerStruct *http_server;
ZipDownloadMgr *zip_download_mgr;
IndexBlksMgr *index_blocks_mgr;
Expand Down

0 comments on commit a33525c

Please sign in to comment.