From 09fd0cea7b5e693a04d4169191416c224555b3a4 Mon Sep 17 00:00:00 2001 From: caixiangyue Date: Wed, 30 Oct 2019 10:28:02 +0800 Subject: [PATCH] libevent init multi threadings supporting --- configure.ac | 5 +++++ daemon/Makefile.am | 2 +- daemon/seafile-session.c | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 7feb9aae..ecad85c3 100644 --- a/configure.ac +++ b/configure.ac @@ -152,6 +152,7 @@ AC_SUBST(LIB_ICONV) LIBEVENT_REQUIRED=2.0 +LIBEVENT_PTHREADS_REQUIRED=2.0 GLIB_REQUIRED=2.16.0 SEARPC_REQUIRED=1.0 JANSSON_REQUIRED=2.2.1 @@ -179,6 +180,10 @@ PKG_CHECK_MODULES(LIBEVENT, [libevent >= $LIBEVENT_REQUIRED]) AC_SUBST(LIBEVENT_CFLAGS) AC_SUBST(LIBEVENT_LIBS) +PKG_CHECK_MODULES(LIBEVENT_PTHREADS, [libevent_pthreads >= $LIBEVENT_PTHREADS_REQUIRED]) +AC_SUBST(LIBEVENT_PTHREADS_CFLAGS) +AC_SUBST(LIBEVENT_PTHREADS_LIBS) + PKG_CHECK_MODULES(ZLIB, [zlib >= $ZLIB_REQUIRED]) AC_SUBST(ZLIB_CFLAGS) AC_SUBST(ZLIB_LIBS) diff --git a/daemon/Makefile.am b/daemon/Makefile.am index c945f3e5..70c5fdf2 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -77,7 +77,7 @@ seaf_daemon_SOURCES = seaf-daemon.c $(common_src) seaf_daemon_LDADD = $(top_builddir)/lib/libseafile_common.la \ @GLIB2_LIBS@ @GOBJECT_LIBS@ @SSL_LIBS@ @GNUTLS_LIBS@ @NETTLE_LIBS@ \ - @LIB_RT@ @LIB_UUID@ -lsqlite3 @LIBEVENT_LIBS@ \ + @LIB_RT@ @LIB_UUID@ -lsqlite3 @LIBEVENT_LIBS@ @LIBEVENT_PTHREADS_LIBS@\ $(top_builddir)/common/cdc/libcdc.la \ $(top_builddir)/common/index/libindex.la @LIB_WS32@ @LIB_CRYPT32@ \ @SEARPC_LIBS@ @JANSSON_LIBS@ @LIB_MAC@ @ZLIB_LIBS@ @CURL_LIBS@ @BPWRAPPER_LIBS@ diff --git a/daemon/seafile-session.c b/daemon/seafile-session.c index f9ebbbbb..fc0411b6 100644 --- a/daemon/seafile-session.c +++ b/daemon/seafile-session.c @@ -20,6 +20,7 @@ #include #else #include +#include #endif #include @@ -185,6 +186,11 @@ seafile_session_new(const char *seafile_dir, session = g_object_new (SEAFILE_TYPE_SESSION, NULL); session->ev_base = event_base_new (); +#ifdef WIN32 + evthread_use_windows_threads(); +#else + evthread_use_pthreads(); +#endif session->seaf_dir = abs_seafile_dir; session->tmp_file_dir = tmp_file_dir; session->worktree_dir = abs_worktree_dir;