libevent init multi threadings supporting

This commit is contained in:
caixiangyue 2019-10-30 10:28:02 +08:00
parent 4cdbc5b7b3
commit 09fd0cea7b
3 changed files with 12 additions and 1 deletions

View File

@ -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)

View File

@ -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@

View File

@ -20,6 +20,7 @@
#include <event2/event_struct.h>
#else
#include <event.h>
#include <event2/thread.h>
#endif
#include <glib.h>
@ -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;