diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 17:36:47 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 17:36:47 +0000 |
commit | 0441d265f2bb9da249c7abf333f0f771fadb4ab5 (patch) | |
tree | 3f3789daa2f6db22da6e55e92bee0062a7d613fe /src/indexer | |
parent | Initial commit. (diff) | |
download | dovecot-0441d265f2bb9da249c7abf333f0f771fadb4ab5.tar.xz dovecot-0441d265f2bb9da249c7abf333f0f771fadb4ab5.zip |
Adding upstream version 1:2.3.21+dfsg1.upstream/1%2.3.21+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/indexer')
-rw-r--r-- | src/indexer/Makefile.am | 47 | ||||
-rw-r--r-- | src/indexer/Makefile.in | 869 | ||||
-rw-r--r-- | src/indexer/indexer-client.c | 223 | ||||
-rw-r--r-- | src/indexer/indexer-client.h | 13 | ||||
-rw-r--r-- | src/indexer/indexer-queue.c | 275 | ||||
-rw-r--r-- | src/indexer/indexer-queue.h | 72 | ||||
-rw-r--r-- | src/indexer/indexer-settings.c | 50 | ||||
-rw-r--r-- | src/indexer/indexer-worker-settings.c | 46 | ||||
-rw-r--r-- | src/indexer/indexer-worker.c | 82 | ||||
-rw-r--r-- | src/indexer/indexer.c | 137 | ||||
-rw-r--r-- | src/indexer/indexer.h | 12 | ||||
-rw-r--r-- | src/indexer/master-connection.c | 365 | ||||
-rw-r--r-- | src/indexer/master-connection.h | 8 | ||||
-rw-r--r-- | src/indexer/worker-connection.c | 196 | ||||
-rw-r--r-- | src/indexer/worker-connection.h | 36 | ||||
-rw-r--r-- | src/indexer/worker-pool.c | 98 | ||||
-rw-r--r-- | src/indexer/worker-pool.h | 23 |
17 files changed, 2552 insertions, 0 deletions
diff --git a/src/indexer/Makefile.am b/src/indexer/Makefile.am new file mode 100644 index 0000000..8bfc891 --- /dev/null +++ b/src/indexer/Makefile.am @@ -0,0 +1,47 @@ +pkglibexecdir = $(libexecdir)/dovecot + +pkglibexec_PROGRAMS = indexer indexer-worker + +AM_CPPFLAGS = \ + -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/lib-master \ + -I$(top_srcdir)/src/lib-settings \ + -I$(top_srcdir)/src/lib-mail \ + -I$(top_srcdir)/src/lib-index \ + -I$(top_srcdir)/src/lib-storage \ + -DPKG_RUNDIR=\""$(rundir)"\" \ + $(BINARY_CFLAGS) + +indexer_LDADD = $(LIBDOVECOT) \ + $(BINARY_LDFLAGS) + +indexer_DEPENDENCIES = $(LIBDOVECOT_DEPS) +indexer_SOURCES = \ + indexer.c \ + indexer-client.c \ + indexer-queue.c \ + indexer-settings.c \ + worker-connection.c \ + worker-pool.c + +indexer_worker_LDADD = \ + $(LIBDOVECOT_STORAGE) \ + $(LIBDOVECOT) \ + $(BINARY_LDFLAGS) + +indexer_worker_DEPENDENCIES = \ + $(LIBDOVECOT_STORAGE_DEPS) \ + $(LIBDOVECOT_DEPS) +indexer_worker_SOURCES = \ + indexer-worker.c \ + indexer-worker-settings.c \ + master-connection.c + +noinst_HEADERS = \ + indexer.h \ + indexer-client.h \ + indexer-queue.h \ + master-connection.h \ + worker-connection.h \ + worker-pool.h + diff --git a/src/indexer/Makefile.in b/src/indexer/Makefile.in new file mode 100644 index 0000000..0300523 --- /dev/null +++ b/src/indexer/Makefile.in @@ -0,0 +1,869 @@ +# Makefile.in generated by automake 1.16.3 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2020 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +pkglibexec_PROGRAMS = indexer$(EXEEXT) indexer-worker$(EXEEXT) +subdir = src/indexer +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ac_checktype2.m4 \ + $(top_srcdir)/m4/ac_typeof.m4 $(top_srcdir)/m4/arc4random.m4 \ + $(top_srcdir)/m4/blockdev.m4 $(top_srcdir)/m4/c99_vsnprintf.m4 \ + $(top_srcdir)/m4/clock_gettime.m4 $(top_srcdir)/m4/crypt.m4 \ + $(top_srcdir)/m4/crypt_xpg6.m4 $(top_srcdir)/m4/dbqlk.m4 \ + $(top_srcdir)/m4/dirent_dtype.m4 $(top_srcdir)/m4/dovecot.m4 \ + $(top_srcdir)/m4/fd_passing.m4 $(top_srcdir)/m4/fdatasync.m4 \ + $(top_srcdir)/m4/flexible_array_member.m4 \ + $(top_srcdir)/m4/glibc.m4 $(top_srcdir)/m4/gmtime_max.m4 \ + $(top_srcdir)/m4/gmtime_tm_gmtoff.m4 \ + $(top_srcdir)/m4/ioloop.m4 $(top_srcdir)/m4/iovec.m4 \ + $(top_srcdir)/m4/ipv6.m4 $(top_srcdir)/m4/libcap.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/libwrap.m4 \ + $(top_srcdir)/m4/linux_mremap.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/mmap_write.m4 \ + $(top_srcdir)/m4/mntctl.m4 $(top_srcdir)/m4/modules.m4 \ + $(top_srcdir)/m4/notify.m4 $(top_srcdir)/m4/nsl.m4 \ + $(top_srcdir)/m4/off_t_max.m4 $(top_srcdir)/m4/pkg.m4 \ + $(top_srcdir)/m4/pr_set_dumpable.m4 \ + $(top_srcdir)/m4/q_quotactl.m4 $(top_srcdir)/m4/quota.m4 \ + $(top_srcdir)/m4/random.m4 $(top_srcdir)/m4/rlimit.m4 \ + $(top_srcdir)/m4/sendfile.m4 $(top_srcdir)/m4/size_t_signed.m4 \ + $(top_srcdir)/m4/sockpeercred.m4 $(top_srcdir)/m4/sql.m4 \ + $(top_srcdir)/m4/ssl.m4 $(top_srcdir)/m4/st_tim.m4 \ + $(top_srcdir)/m4/static_array.m4 $(top_srcdir)/m4/test_with.m4 \ + $(top_srcdir)/m4/time_t.m4 $(top_srcdir)/m4/typeof.m4 \ + $(top_srcdir)/m4/typeof_dev_t.m4 \ + $(top_srcdir)/m4/uoff_t_max.m4 $(top_srcdir)/m4/vararg.m4 \ + $(top_srcdir)/m4/want_apparmor.m4 \ + $(top_srcdir)/m4/want_bsdauth.m4 \ + $(top_srcdir)/m4/want_bzlib.m4 \ + $(top_srcdir)/m4/want_cassandra.m4 \ + $(top_srcdir)/m4/want_cdb.m4 \ + $(top_srcdir)/m4/want_checkpassword.m4 \ + $(top_srcdir)/m4/want_clucene.m4 $(top_srcdir)/m4/want_db.m4 \ + $(top_srcdir)/m4/want_gssapi.m4 $(top_srcdir)/m4/want_icu.m4 \ + $(top_srcdir)/m4/want_ldap.m4 $(top_srcdir)/m4/want_lua.m4 \ + $(top_srcdir)/m4/want_lz4.m4 $(top_srcdir)/m4/want_lzma.m4 \ + $(top_srcdir)/m4/want_mysql.m4 $(top_srcdir)/m4/want_pam.m4 \ + $(top_srcdir)/m4/want_passwd.m4 $(top_srcdir)/m4/want_pgsql.m4 \ + $(top_srcdir)/m4/want_prefetch.m4 \ + $(top_srcdir)/m4/want_shadow.m4 \ + $(top_srcdir)/m4/want_sodium.m4 $(top_srcdir)/m4/want_solr.m4 \ + $(top_srcdir)/m4/want_sqlite.m4 \ + $(top_srcdir)/m4/want_stemmer.m4 \ + $(top_srcdir)/m4/want_systemd.m4 \ + $(top_srcdir)/m4/want_textcat.m4 \ + $(top_srcdir)/m4/want_unwind.m4 $(top_srcdir)/m4/want_zlib.m4 \ + $(top_srcdir)/m4/want_zstd.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \ + $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(pkglibexecdir)" +PROGRAMS = $(pkglibexec_PROGRAMS) +am_indexer_OBJECTS = indexer.$(OBJEXT) indexer-client.$(OBJEXT) \ + indexer-queue.$(OBJEXT) indexer-settings.$(OBJEXT) \ + worker-connection.$(OBJEXT) worker-pool.$(OBJEXT) +indexer_OBJECTS = $(am_indexer_OBJECTS) +am__DEPENDENCIES_1 = +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +am_indexer_worker_OBJECTS = indexer-worker.$(OBJEXT) \ + indexer-worker-settings.$(OBJEXT) master-connection.$(OBJEXT) +indexer_worker_OBJECTS = $(am_indexer_worker_OBJECTS) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/indexer-client.Po \ + ./$(DEPDIR)/indexer-queue.Po ./$(DEPDIR)/indexer-settings.Po \ + ./$(DEPDIR)/indexer-worker-settings.Po \ + ./$(DEPDIR)/indexer-worker.Po ./$(DEPDIR)/indexer.Po \ + ./$(DEPDIR)/master-connection.Po \ + ./$(DEPDIR)/worker-connection.Po ./$(DEPDIR)/worker-pool.Po +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(indexer_SOURCES) $(indexer_worker_SOURCES) +DIST_SOURCES = $(indexer_SOURCES) $(indexer_worker_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +HEADERS = $(noinst_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +pkglibexecdir = $(libexecdir)/dovecot +ACLOCAL = @ACLOCAL@ +ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +APPARMOR_LIBS = @APPARMOR_LIBS@ +AR = @AR@ +AUTH_CFLAGS = @AUTH_CFLAGS@ +AUTH_LIBS = @AUTH_LIBS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BINARY_CFLAGS = @BINARY_CFLAGS@ +BINARY_LDFLAGS = @BINARY_LDFLAGS@ +BISON = @BISON@ +CASSANDRA_CFLAGS = @CASSANDRA_CFLAGS@ +CASSANDRA_LIBS = @CASSANDRA_LIBS@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CDB_LIBS = @CDB_LIBS@ +CFLAGS = @CFLAGS@ +CLUCENE_CFLAGS = @CLUCENE_CFLAGS@ +CLUCENE_LIBS = @CLUCENE_LIBS@ +COMPRESS_LIBS = @COMPRESS_LIBS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CRYPT_LIBS = @CRYPT_LIBS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DICT_LIBS = @DICT_LIBS@ +DLLIB = @DLLIB@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FLEX = @FLEX@ +FUZZER_CPPFLAGS = @FUZZER_CPPFLAGS@ +FUZZER_LDFLAGS = @FUZZER_LDFLAGS@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KRB5CONFIG = @KRB5CONFIG@ +KRB5_CFLAGS = @KRB5_CFLAGS@ +KRB5_LIBS = @KRB5_LIBS@ +LD = @LD@ +LDAP_LIBS = @LDAP_LIBS@ +LDFLAGS = @LDFLAGS@ +LD_NO_WHOLE_ARCHIVE = @LD_NO_WHOLE_ARCHIVE@ +LD_WHOLE_ARCHIVE = @LD_WHOLE_ARCHIVE@ +LIBCAP = @LIBCAP@ +LIBDOVECOT = @LIBDOVECOT@ +LIBDOVECOT_COMPRESS = @LIBDOVECOT_COMPRESS@ +LIBDOVECOT_DEPS = @LIBDOVECOT_DEPS@ +LIBDOVECOT_DSYNC = @LIBDOVECOT_DSYNC@ +LIBDOVECOT_LA_LIBS = @LIBDOVECOT_LA_LIBS@ +LIBDOVECOT_LDA = @LIBDOVECOT_LDA@ +LIBDOVECOT_LDAP = @LIBDOVECOT_LDAP@ +LIBDOVECOT_LIBFTS = @LIBDOVECOT_LIBFTS@ +LIBDOVECOT_LIBFTS_DEPS = @LIBDOVECOT_LIBFTS_DEPS@ +LIBDOVECOT_LOGIN = @LIBDOVECOT_LOGIN@ +LIBDOVECOT_LUA = @LIBDOVECOT_LUA@ +LIBDOVECOT_LUA_DEPS = @LIBDOVECOT_LUA_DEPS@ +LIBDOVECOT_SQL = @LIBDOVECOT_SQL@ +LIBDOVECOT_STORAGE = @LIBDOVECOT_STORAGE@ +LIBDOVECOT_STORAGE_DEPS = @LIBDOVECOT_STORAGE_DEPS@ +LIBEXTTEXTCAT_CFLAGS = @LIBEXTTEXTCAT_CFLAGS@ +LIBEXTTEXTCAT_LIBS = @LIBEXTTEXTCAT_LIBS@ +LIBICONV = @LIBICONV@ +LIBICU_CFLAGS = @LIBICU_CFLAGS@ +LIBICU_LIBS = @LIBICU_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBSODIUM_CFLAGS = @LIBSODIUM_CFLAGS@ +LIBSODIUM_LIBS = @LIBSODIUM_LIBS@ +LIBTIRPC_CFLAGS = @LIBTIRPC_CFLAGS@ +LIBTIRPC_LIBS = @LIBTIRPC_LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUNWIND_CFLAGS = @LIBUNWIND_CFLAGS@ +LIBUNWIND_LIBS = @LIBUNWIND_LIBS@ +LIBWRAP_LIBS = @LIBWRAP_LIBS@ +LINKED_STORAGE_LDADD = @LINKED_STORAGE_LDADD@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +LUA_CFLAGS = @LUA_CFLAGS@ +LUA_LIBS = @LUA_LIBS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MODULE_LIBS = @MODULE_LIBS@ +MODULE_SUFFIX = @MODULE_SUFFIX@ +MYSQL_CFLAGS = @MYSQL_CFLAGS@ +MYSQL_CONFIG = @MYSQL_CONFIG@ +MYSQL_LIBS = @MYSQL_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NOPLUGIN_LDFLAGS = @NOPLUGIN_LDFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PANDOC = @PANDOC@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PGSQL_CFLAGS = @PGSQL_CFLAGS@ +PGSQL_LIBS = @PGSQL_LIBS@ +PG_CONFIG = @PG_CONFIG@ +PIE_CFLAGS = @PIE_CFLAGS@ +PIE_LDFLAGS = @PIE_LDFLAGS@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +QUOTA_LIBS = @QUOTA_LIBS@ +RANLIB = @RANLIB@ +RELRO_LDFLAGS = @RELRO_LDFLAGS@ +RPCGEN = @RPCGEN@ +RUN_TEST = @RUN_TEST@ +SED = @SED@ +SETTING_FILES = @SETTING_FILES@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SQLITE_CFLAGS = @SQLITE_CFLAGS@ +SQLITE_LIBS = @SQLITE_LIBS@ +SQL_CFLAGS = @SQL_CFLAGS@ +SQL_LIBS = @SQL_LIBS@ +SSL_CFLAGS = @SSL_CFLAGS@ +SSL_LIBS = @SSL_LIBS@ +STRIP = @STRIP@ +SYSTEMD_CFLAGS = @SYSTEMD_CFLAGS@ +SYSTEMD_LIBS = @SYSTEMD_LIBS@ +VALGRIND = @VALGRIND@ +VERSION = @VERSION@ +ZSTD_CFLAGS = @ZSTD_CFLAGS@ +ZSTD_LIBS = @ZSTD_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +dict_drivers = @dict_drivers@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +rundir = @rundir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sql_drivers = @sql_drivers@ +srcdir = @srcdir@ +ssldir = @ssldir@ +statedir = @statedir@ +sysconfdir = @sysconfdir@ +systemdservicetype = @systemdservicetype@ +systemdsystemunitdir = @systemdsystemunitdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CPPFLAGS = \ + -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/lib-master \ + -I$(top_srcdir)/src/lib-settings \ + -I$(top_srcdir)/src/lib-mail \ + -I$(top_srcdir)/src/lib-index \ + -I$(top_srcdir)/src/lib-storage \ + -DPKG_RUNDIR=\""$(rundir)"\" \ + $(BINARY_CFLAGS) + +indexer_LDADD = $(LIBDOVECOT) \ + $(BINARY_LDFLAGS) + +indexer_DEPENDENCIES = $(LIBDOVECOT_DEPS) +indexer_SOURCES = \ + indexer.c \ + indexer-client.c \ + indexer-queue.c \ + indexer-settings.c \ + worker-connection.c \ + worker-pool.c + +indexer_worker_LDADD = \ + $(LIBDOVECOT_STORAGE) \ + $(LIBDOVECOT) \ + $(BINARY_LDFLAGS) + +indexer_worker_DEPENDENCIES = \ + $(LIBDOVECOT_STORAGE_DEPS) \ + $(LIBDOVECOT_DEPS) + +indexer_worker_SOURCES = \ + indexer-worker.c \ + indexer-worker-settings.c \ + master-connection.c + +noinst_HEADERS = \ + indexer.h \ + indexer-client.h \ + indexer-queue.h \ + master-connection.h \ + worker-connection.h \ + worker-pool.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/indexer/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/indexer/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-pkglibexecPROGRAMS: $(pkglibexec_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(pkglibexec_PROGRAMS)'; test -n "$(pkglibexecdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkglibexecdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkglibexecdir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(pkglibexecdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(pkglibexecdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-pkglibexecPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(pkglibexec_PROGRAMS)'; test -n "$(pkglibexecdir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' \ + `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(pkglibexecdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(pkglibexecdir)" && rm -f $$files + +clean-pkglibexecPROGRAMS: + @list='$(pkglibexec_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +indexer$(EXEEXT): $(indexer_OBJECTS) $(indexer_DEPENDENCIES) $(EXTRA_indexer_DEPENDENCIES) + @rm -f indexer$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(indexer_OBJECTS) $(indexer_LDADD) $(LIBS) + +indexer-worker$(EXEEXT): $(indexer_worker_OBJECTS) $(indexer_worker_DEPENDENCIES) $(EXTRA_indexer_worker_DEPENDENCIES) + @rm -f indexer-worker$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(indexer_worker_OBJECTS) $(indexer_worker_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indexer-client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indexer-queue.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indexer-settings.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indexer-worker-settings.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indexer-worker.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indexer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/master-connection.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/worker-connection.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/worker-pool.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(pkglibexecdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-pkglibexecPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -f ./$(DEPDIR)/indexer-client.Po + -rm -f ./$(DEPDIR)/indexer-queue.Po + -rm -f ./$(DEPDIR)/indexer-settings.Po + -rm -f ./$(DEPDIR)/indexer-worker-settings.Po + -rm -f ./$(DEPDIR)/indexer-worker.Po + -rm -f ./$(DEPDIR)/indexer.Po + -rm -f ./$(DEPDIR)/master-connection.Po + -rm -f ./$(DEPDIR)/worker-connection.Po + -rm -f ./$(DEPDIR)/worker-pool.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-pkglibexecPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ./$(DEPDIR)/indexer-client.Po + -rm -f ./$(DEPDIR)/indexer-queue.Po + -rm -f ./$(DEPDIR)/indexer-settings.Po + -rm -f ./$(DEPDIR)/indexer-worker-settings.Po + -rm -f ./$(DEPDIR)/indexer-worker.Po + -rm -f ./$(DEPDIR)/indexer.Po + -rm -f ./$(DEPDIR)/master-connection.Po + -rm -f ./$(DEPDIR)/worker-connection.Po + -rm -f ./$(DEPDIR)/worker-pool.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-pkglibexecPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-libtool clean-pkglibexecPROGRAMS \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-pkglibexecPROGRAMS install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am uninstall-pkglibexecPROGRAMS + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/indexer/indexer-client.c b/src/indexer/indexer-client.c new file mode 100644 index 0000000..ea557c0 --- /dev/null +++ b/src/indexer/indexer-client.c @@ -0,0 +1,223 @@ +/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "connection.h" +#include "istream.h" +#include "ostream.h" +#include "strescape.h" +#include "master-service.h" +#include "indexer-queue.h" +#include "indexer-client.h" + +#include <unistd.h> + +#define MAX_INBUF_SIZE (1024*64) + +#define INDEXER_CLIENT_PROTOCOL_MAJOR_VERSION 1 +#define INDEXER_CLIENT_PROTOCOL_MINOR_VERSION 0 + +struct indexer_client { + struct connection conn; + + int refcount; + struct indexer_queue *queue; +}; + +struct indexer_client_request { + struct indexer_client *client; + unsigned int tag; +}; + +static void indexer_client_destroy(struct connection *conn); +static void indexer_client_ref(struct indexer_client *client); +static void indexer_client_unref(struct indexer_client *client); + +static int +indexer_client_request_queue(struct indexer_client *client, bool append, + const char *const *args, const char **error_r) +{ + struct indexer_client_request *ctx = NULL; + const char *session_id = NULL; + unsigned int tag, max_recent_msgs; + + /* <tag> <user> <mailbox> [<max_recent_msgs> [<session ID>]] */ + if (str_array_length(args) < 3) { + *error_r = "Wrong parameter count"; + return -1; + } + if (str_to_uint(args[0], &tag) < 0) { + *error_r = "Invalid tag"; + return -1; + } + if (args[3] == NULL) + max_recent_msgs = 0; + else if (str_to_uint(args[3], &max_recent_msgs) < 0) { + *error_r = "Invalid max_recent_msgs"; + return -1; + } else { + session_id = args[4]; + } + + if (tag != 0) { + ctx = i_new(struct indexer_client_request, 1); + ctx->client = client; + ctx->tag = tag; + indexer_client_ref(client); + } + + indexer_queue_append(client->queue, append, args[1], args[2], + session_id, max_recent_msgs, ctx); + o_stream_nsend_str(client->conn.output, t_strdup_printf("%u\tOK\n", tag)); + return 0; +} + +static int +indexer_client_request_optimize(struct indexer_client *client, + const char *const *args, const char **error_r) +{ + struct indexer_client_request *ctx = NULL; + unsigned int tag; + + /* <tag> <user> <mailbox> */ + if (str_array_length(args) != 3) { + *error_r = "Wrong parameter count"; + return -1; + } + if (str_to_uint(args[0], &tag) < 0) { + *error_r = "Invalid tag"; + return -1; + } + + if (tag != 0) { + ctx = i_new(struct indexer_client_request, 1); + ctx->client = client; + ctx->tag = tag; + indexer_client_ref(client); + } + + indexer_queue_append_optimize(client->queue, args[1], args[2], ctx); + o_stream_nsend_str(client->conn.output, t_strdup_printf("%u\tOK\n", tag)); + return 0; +} + +static int +indexer_client_request(struct indexer_client *client, + const char *const *args, const char **error_r) +{ + const char *cmd = args[0]; + + args++; + + if (strcmp(cmd, "APPEND") == 0) + return indexer_client_request_queue(client, TRUE, args, error_r); + else if (strcmp(cmd, "PREPEND") == 0) + return indexer_client_request_queue(client, FALSE, args, error_r); + else if (strcmp(cmd, "OPTIMIZE") == 0) + return indexer_client_request_optimize(client, args, error_r); + else { + *error_r = t_strconcat("Unknown command: ", cmd, NULL); + return -1; + } +} + +static int +indexer_client_input_args(struct connection *conn, const char *const *args) +{ + struct indexer_client *client = + container_of(conn, struct indexer_client, conn); + const char *error; + + if (indexer_client_request(client, args, &error) < 0) { + i_error("Client input error: %s", error); + return -1; + } + return 1; +} + +void indexer_client_status_callback(int percentage, void *context) +{ + struct indexer_client_request *ctx = context; + + if (ctx->client->conn.output != NULL) T_BEGIN { + o_stream_nsend_str(ctx->client->conn.output, + t_strdup_printf("%u\t%d\n", ctx->tag, percentage)); + } T_END; + if (percentage < 0 || percentage == 100) { + indexer_client_unref(ctx->client); + i_free(ctx); + } +} + +static struct connection_list *indexer_client_list = NULL; + +static const struct connection_vfuncs indexer_client_vfuncs = { + .destroy = indexer_client_destroy, + .input_args = indexer_client_input_args, +}; + +static const struct connection_settings indexer_client_set = { + .service_name_in = "indexer", + .service_name_out = "indexer", + .major_version = INDEXER_CLIENT_PROTOCOL_MAJOR_VERSION, + .minor_version = INDEXER_CLIENT_PROTOCOL_MINOR_VERSION, + .input_max_size = SIZE_MAX, + .output_max_size = IO_BLOCK_SIZE, +}; + + +void indexer_client_create(struct master_service_connection *conn, + struct indexer_queue *queue) +{ + struct indexer_client *client; + + if (indexer_client_list == NULL) { + indexer_client_list = + connection_list_init(&indexer_client_set, + &indexer_client_vfuncs); + } + + client = i_new(struct indexer_client, 1); + client->refcount = 1; + client->queue = queue; + connection_init_server(indexer_client_list, &client->conn, + conn->name, conn->fd, conn->fd); + indexer_refresh_proctitle(); +} + +static void indexer_client_destroy(struct connection *conn) +{ + struct indexer_client *client = + container_of(conn, struct indexer_client, conn); + connection_deinit(&client->conn); + master_service_client_connection_destroyed(master_service); + indexer_client_unref(client); + indexer_refresh_proctitle(); +} + +static void indexer_client_ref(struct indexer_client *client) +{ + i_assert(client->refcount > 0); + + client->refcount++; +} + +static void indexer_client_unref(struct indexer_client *client) +{ + i_assert(client->refcount > 0); + + if (--client->refcount > 0) + return; + i_free(client); +} + +unsigned int indexer_clients_get_count(void) +{ + if (indexer_client_list == NULL) + return 0; + return indexer_client_list->connections_count; +} + +void indexer_clients_destroy_all(void) +{ + connection_list_deinit(&indexer_client_list); +} diff --git a/src/indexer/indexer-client.h b/src/indexer/indexer-client.h new file mode 100644 index 0000000..609c678 --- /dev/null +++ b/src/indexer/indexer-client.h @@ -0,0 +1,13 @@ +#ifndef INDEXER_CLIENT_H +#define INDEXER_CLIENT_H + +struct indexer_queue; + +void indexer_client_create(struct master_service_connection *conn, + struct indexer_queue *queue); +void indexer_client_status_callback(int percentage, void *context); + +unsigned int indexer_clients_get_count(void); +void indexer_clients_destroy_all(void); + +#endif diff --git a/src/indexer/indexer-queue.c b/src/indexer/indexer-queue.c new file mode 100644 index 0000000..3532b8b --- /dev/null +++ b/src/indexer/indexer-queue.c @@ -0,0 +1,275 @@ +/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "array.h" +#include "llist.h" +#include "hash.h" +#include "indexer-queue.h" + +struct indexer_queue { + indexer_queue_callback_t *callback; + void (*listen_callback)(struct indexer_queue *); + + /* username+mailbox -> indexer_request */ + HASH_TABLE(struct indexer_request *, struct indexer_request *) requests; + struct indexer_request *head, *tail; +}; + +static unsigned int +indexer_request_hash(const struct indexer_request *request) +{ + return str_hash(request->username) ^ str_hash(request->mailbox); +} + +static int indexer_request_cmp(const struct indexer_request *r1, + const struct indexer_request *r2) +{ + return strcmp(r1->username, r2->username) == 0 && + strcmp(r1->mailbox, r2->mailbox) == 0 ? 0 : 1; +} + +struct indexer_queue * +indexer_queue_init(indexer_queue_callback_t *callback) +{ + struct indexer_queue *queue; + + queue = i_new(struct indexer_queue, 1); + queue->callback = callback; + hash_table_create(&queue->requests, default_pool, 0, + indexer_request_hash, indexer_request_cmp); + return queue; +} + +void indexer_queue_deinit(struct indexer_queue **_queue) +{ + struct indexer_queue *queue = *_queue; + + *_queue = NULL; + + i_assert(indexer_queue_is_empty(queue)); + + hash_table_destroy(&queue->requests); + i_free(queue); +} + +void indexer_queue_set_listen_callback(struct indexer_queue *queue, + void (*callback)(struct indexer_queue *)) +{ + queue->listen_callback = callback; +} + +static struct indexer_request * +indexer_queue_lookup(struct indexer_queue *queue, + const char *username, const char *mailbox) +{ + struct indexer_request lookup_request; + + lookup_request.username = (void *)username; + lookup_request.mailbox = (void *)mailbox; + return hash_table_lookup(queue->requests, &lookup_request); +} + +static void request_add_context(struct indexer_request *request, void *context) +{ + if (context == NULL) + return; + + if (!array_is_created(&request->contexts)) + i_array_init(&request->contexts, 2); + array_push_back(&request->contexts, &context); +} + +static struct indexer_request * +indexer_queue_append_request(struct indexer_queue *queue, bool append, + const char *username, const char *mailbox, + const char *session_id, + unsigned int max_recent_msgs, void *context) +{ + struct indexer_request *request; + + request = indexer_queue_lookup(queue, username, mailbox); + if (request == NULL) { + request = i_new(struct indexer_request, 1); + request->username = i_strdup(username); + request->mailbox = i_strdup(mailbox); + request->session_id = i_strdup(session_id); + request->max_recent_msgs = max_recent_msgs; + request_add_context(request, context); + hash_table_insert(queue->requests, request, request); + } else { + if (request->max_recent_msgs > max_recent_msgs) + request->max_recent_msgs = max_recent_msgs; + request_add_context(request, context); + if (request->working) { + /* we're already indexing this mailbox. */ + if (append) + request->reindex_tail = TRUE; + else + request->reindex_head = TRUE; + return request; + } + if (append) { + /* keep the request in its old position */ + return request; + } + /* move request to beginning of the queue */ + DLLIST2_REMOVE(&queue->head, &queue->tail, request); + } + + if (append) + DLLIST2_APPEND(&queue->head, &queue->tail, request); + else + DLLIST2_PREPEND(&queue->head, &queue->tail, request); + return request; +} + +static void indexer_queue_append_finish(struct indexer_queue *queue) +{ + if (queue->listen_callback != NULL) + queue->listen_callback(queue); + indexer_refresh_proctitle(); +} + +void indexer_queue_append(struct indexer_queue *queue, bool append, + const char *username, const char *mailbox, + const char *session_id, unsigned int max_recent_msgs, + void *context) +{ + struct indexer_request *request; + + request = indexer_queue_append_request(queue, append, username, mailbox, + session_id, max_recent_msgs, + context); + request->index = TRUE; + indexer_queue_append_finish(queue); +} + +void indexer_queue_append_optimize(struct indexer_queue *queue, + const char *username, const char *mailbox, + void *context) +{ + struct indexer_request *request; + + request = indexer_queue_append_request(queue, TRUE, username, mailbox, + NULL, 0, context); + request->optimize = TRUE; + indexer_queue_append_finish(queue); +} + +struct indexer_request *indexer_queue_request_peek(struct indexer_queue *queue) +{ + return queue->head; +} + +void indexer_queue_request_remove(struct indexer_queue *queue) +{ + struct indexer_request *request = queue->head; + + i_assert(request != NULL); + + DLLIST2_REMOVE(&queue->head, &queue->tail, request); +} + +static void indexer_queue_request_status_int(struct indexer_queue *queue, + struct indexer_request *request, + int percentage) +{ + void *context; + unsigned int i; + + for (i = 0; i < request->working_context_idx; i++) { + context = array_idx_elem(&request->contexts, i); + queue->callback(percentage, context); + } +} + +void indexer_queue_request_status(struct indexer_queue *queue, + struct indexer_request *request, + int percentage) +{ + i_assert(percentage >= 0 && percentage < 100); + + indexer_queue_request_status_int(queue, request, percentage); +} + +void indexer_queue_move_head_to_tail(struct indexer_queue *queue) +{ + struct indexer_request *request = queue->head; + + indexer_queue_request_remove(queue); + DLLIST2_APPEND(&queue->head, &queue->tail, request); +} + +void indexer_queue_request_work(struct indexer_request *request) +{ + request->working = TRUE; + request->working_context_idx = + !array_is_created(&request->contexts) ? 0 : + array_count(&request->contexts); +} + +void indexer_queue_request_finish(struct indexer_queue *queue, + struct indexer_request **_request, + bool success) +{ + struct indexer_request *request = *_request; + + *_request = NULL; + + indexer_queue_request_status_int(queue, request, success ? 100 : -1); + + if (request->reindex_head || request->reindex_tail) { + i_assert(request->working); + request->working = FALSE; + request->reindex_head = FALSE; + request->reindex_tail = FALSE; + if (request->working_context_idx > 0) { + array_delete(&request->contexts, 0, + request->working_context_idx); + } + if (request->reindex_head) + DLLIST2_PREPEND(&queue->head, &queue->tail, request); + else + DLLIST2_APPEND(&queue->head, &queue->tail, request); + return; + } + + hash_table_remove(queue->requests, request); + if (array_is_created(&request->contexts)) + array_free(&request->contexts); + i_free(request->username); + i_free(request->mailbox); + i_free(request->session_id); + i_free(request); + + indexer_refresh_proctitle(); +} + +void indexer_queue_cancel_all(struct indexer_queue *queue) +{ + struct indexer_request *request; + struct hash_iterate_context *iter; + + /* remove all reindex-markers so when the current requests finish + (or are cancelled) we don't try to retry them (especially during + deinit where it crashes) */ + iter = hash_table_iterate_init(queue->requests); + while (hash_table_iterate(iter, queue->requests, &request, &request)) + request->reindex_head = request->reindex_tail = FALSE; + hash_table_iterate_deinit(&iter); + + while ((request = indexer_queue_request_peek(queue)) != NULL) { + indexer_queue_request_remove(queue); + indexer_queue_request_finish(queue, &request, FALSE); + } +} + +bool indexer_queue_is_empty(struct indexer_queue *queue) +{ + return queue->head == NULL; +} + +unsigned int indexer_queue_count(struct indexer_queue *queue) +{ + return hash_table_count(queue->requests); +} diff --git a/src/indexer/indexer-queue.h b/src/indexer/indexer-queue.h new file mode 100644 index 0000000..a9d5b9d --- /dev/null +++ b/src/indexer/indexer-queue.h @@ -0,0 +1,72 @@ +#ifndef INDEXER_QUEUE_H +#define INDEXER_QUEUE_H + +#include "indexer.h" + +typedef void indexer_queue_callback_t(int status, void *context); + +struct indexer_request { + struct indexer_request *prev, *next; + + char *username; + char *mailbox; + char *session_id; + unsigned int max_recent_msgs; + + /* index messages in this mailbox */ + bool index:1; + /* optimize this mailbox */ + bool optimize:1; + /* currently indexing this mailbox */ + bool working:1; + /* after indexing is finished, add this request back to the queue and + reindex it (i.e. a new indexing request came while we were + working.) */ + bool reindex_head:1; + bool reindex_tail:1; + + /* when working finished, call this number of contexts and leave the + rest to the reindexing. */ + unsigned int working_context_idx; + + ARRAY(void *) contexts; +}; + +struct indexer_queue *indexer_queue_init(indexer_queue_callback_t *callback); +void indexer_queue_deinit(struct indexer_queue **queue); + +/* The callback is called whenever a new request is added to the queue. */ +void indexer_queue_set_listen_callback(struct indexer_queue *queue, + void (*callback)(struct indexer_queue *)); + +void indexer_queue_append(struct indexer_queue *queue, bool append, + const char *username, const char *mailbox, + const char *session_id, unsigned int max_recent_msgs, + void *context); +void indexer_queue_append_optimize(struct indexer_queue *queue, + const char *username, const char *mailbox, + void *context); +void indexer_queue_cancel_all(struct indexer_queue *queue); + +bool indexer_queue_is_empty(struct indexer_queue *queue); +unsigned int indexer_queue_count(struct indexer_queue *queue); + +/* Return the next request from the queue, without removing it. */ +struct indexer_request *indexer_queue_request_peek(struct indexer_queue *queue); +/* Remove the next request from the queue. You must call + indexer_queue_request_finish() to free its memory. */ +void indexer_queue_request_remove(struct indexer_queue *queue); +/* Give a status update about how far the indexing is going on. */ +void indexer_queue_request_status(struct indexer_queue *queue, + struct indexer_request *request, + int percentage); +/* Move the next request to the end of the queue. */ +void indexer_queue_move_head_to_tail(struct indexer_queue *queue); +/* Start working on a request */ +void indexer_queue_request_work(struct indexer_request *request); +/* Finish the request and free its memory. */ +void indexer_queue_request_finish(struct indexer_queue *queue, + struct indexer_request **request, + bool success); + +#endif diff --git a/src/indexer/indexer-settings.c b/src/indexer/indexer-settings.c new file mode 100644 index 0000000..8375829 --- /dev/null +++ b/src/indexer/indexer-settings.c @@ -0,0 +1,50 @@ +/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "buffer.h" +#include "settings-parser.h" +#include "service-settings.h" + +#include <stddef.h> + +extern const struct setting_parser_info service_setting_parser_info; + +/* <settings checks> */ +static struct file_listener_settings indexer_unix_listeners_array[] = { + { "indexer", 0666, "", "" } +}; +static struct file_listener_settings *indexer_unix_listeners[] = { + &indexer_unix_listeners_array[0] +}; +static buffer_t indexer_unix_listeners_buf = { + { { indexer_unix_listeners, sizeof(indexer_unix_listeners) } } +}; +/* </settings checks> */ + +struct service_settings indexer_service_settings = { + .name = "indexer", + .protocol = "", + .type = "", + .executable = "indexer", + .user = "$default_internal_user", + .group = "", + .privileged_group = "", + .extra_groups = "", + .chroot = "", + + .drop_priv_before_exec = FALSE, + + .process_min_avail = 0, + .process_limit = 1, + .client_limit = 0, + .service_count = 0, + .idle_kill = 0, + .vsz_limit = UOFF_T_MAX, + + .unix_listeners = { { &indexer_unix_listeners_buf, + sizeof(indexer_unix_listeners[0]) } }, + .fifo_listeners = ARRAY_INIT, + .inet_listeners = ARRAY_INIT, + + .process_limit_1 = TRUE +}; diff --git a/src/indexer/indexer-worker-settings.c b/src/indexer/indexer-worker-settings.c new file mode 100644 index 0000000..8627954 --- /dev/null +++ b/src/indexer/indexer-worker-settings.c @@ -0,0 +1,46 @@ +/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "buffer.h" +#include "settings-parser.h" +#include "service-settings.h" + +#include <stddef.h> + +/* <settings checks> */ +static struct file_listener_settings indexer_worker_unix_listeners_array[] = { + { "indexer-worker", 0600, "$default_internal_user", "" } +}; +static struct file_listener_settings *indexer_worker_unix_listeners[] = { + &indexer_worker_unix_listeners_array[0] +}; +static buffer_t indexer_worker_unix_listeners_buf = { + { { indexer_worker_unix_listeners, sizeof(indexer_worker_unix_listeners) } } +}; +/* </settings checks> */ + +struct service_settings indexer_worker_service_settings = { + .name = "indexer-worker", + .protocol = "", + .type = "worker", + .executable = "indexer-worker", + .user = "", + .group = "", + .privileged_group = "", + .extra_groups = "$default_internal_group", + .chroot = "", + + .drop_priv_before_exec = FALSE, + + .process_min_avail = 0, + .process_limit = 10, + .client_limit = 1, + .service_count = 0, + .idle_kill = 0, + .vsz_limit = UOFF_T_MAX, + + .unix_listeners = { { &indexer_worker_unix_listeners_buf, + sizeof(indexer_worker_unix_listeners[0]) } }, + .fifo_listeners = ARRAY_INIT, + .inet_listeners = ARRAY_INIT +}; diff --git a/src/indexer/indexer-worker.c b/src/indexer/indexer-worker.c new file mode 100644 index 0000000..ef39aeb --- /dev/null +++ b/src/indexer/indexer-worker.c @@ -0,0 +1,82 @@ +/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "restrict-access.h" +#include "mail-storage-service.h" +#include "mail-storage-settings.h" +#include "master-service.h" +#include "master-service-settings.h" +#include "master-connection.h" + +static struct mail_storage_service_ctx *storage_service; + +static void client_connected(struct master_service_connection *conn) +{ + master_service_client_connection_accept(conn); + + if (!master_connection_create(conn, storage_service)) { + i_error("indexer-worker must be configured with client_limit=1"); + i_close_fd(&conn->fd); + master_service_client_connection_destroyed(master_service); + } +} + +static void drop_privileges(void) +{ + struct restrict_access_settings set; + const char *error; + + /* by default we don't drop any privileges, but keep running as root. */ + restrict_access_get_env(&set); + if (set.uid != 0) { + /* open config connection before dropping privileges */ + struct master_service_settings_input input; + struct master_service_settings_output output; + + i_zero(&input); + input.module = "mail"; + input.service = "indexer-worker"; + (void)master_service_settings_read(master_service, + &input, &output, &error); + } + restrict_access_by_env(RESTRICT_ACCESS_FLAG_ALLOW_ROOT, NULL); +} + +int main(int argc, char *argv[]) +{ + enum master_service_flags service_flags = + MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN; + enum mail_storage_service_flags storage_service_flags = + MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP | + MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP | + MAIL_STORAGE_SERVICE_FLAG_NO_IDLE_TIMEOUT; + int c; + + master_service = master_service_init("indexer-worker", service_flags, + &argc, &argv, "D"); + while ((c = master_getopt(master_service)) > 0) { + switch (c) { + case 'D': + storage_service_flags |= + MAIL_STORAGE_SERVICE_FLAG_ENABLE_CORE_DUMPS; + break; + default: + return FATAL_DEFAULT; + } + } + + drop_privileges(); + master_service_init_log_with_pid(master_service); + + storage_service = mail_storage_service_init(master_service, NULL, + storage_service_flags); + restrict_access_allow_coredumps(TRUE); + master_service_init_finish(master_service); + + master_service_run(master_service, client_connected); + + master_connections_destroy(); + mail_storage_service_deinit(&storage_service); + master_service_deinit(&master_service); + return 0; +} diff --git a/src/indexer/indexer.c b/src/indexer/indexer.c new file mode 100644 index 0000000..6175b54 --- /dev/null +++ b/src/indexer/indexer.c @@ -0,0 +1,137 @@ +/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "ioloop.h" +#include "restrict-access.h" +#include "process-title.h" +#include "master-service.h" +#include "master-service-settings.h" +#include "indexer-client.h" +#include "indexer-queue.h" +#include "worker-pool.h" +#include "worker-connection.h" + +static const struct master_service_settings *set; +static struct indexer_queue *queue; +static struct worker_pool *worker_pool; + +void indexer_refresh_proctitle(void) +{ + if (!set->verbose_proctitle) + return; + + process_title_set(t_strdup_printf("[%u clients, %u requests]", + indexer_clients_get_count(), + indexer_queue_count(queue))); +} + +static bool idle_die(void) +{ + return indexer_queue_is_empty(queue) && + !worker_pool_have_connections(worker_pool); +} + +static void client_connected(struct master_service_connection *conn) +{ + master_service_client_connection_accept(conn); + indexer_client_create(conn, queue); +} + +static void worker_send_request(struct connection *conn, + struct indexer_request *request) +{ + indexer_queue_request_work(request); + worker_connection_request(conn, request); +} + +static void queue_try_send_more(struct indexer_queue *queue) +{ + struct connection *conn; + struct indexer_request *request, *first_moved_request = NULL; + + while ((request = indexer_queue_request_peek(queue)) != NULL) { + conn = worker_pool_find_username_connection(worker_pool, + request->username); + if (conn != NULL) { + /* There is already a connection handling a request + * for this user. Move the request to the back of the + * queue and handle requests from other users. + * Terminate if we went through all requests. */ + if (request == first_moved_request) { + /* all requests are waiting for existing users + to finish. */ + break; + } + if (first_moved_request == NULL) + first_moved_request = request; + indexer_queue_move_head_to_tail(queue); + continue; + } else { + /* create a new connection to a worker */ + if (!worker_pool_get_connection(worker_pool, &conn)) + break; + } + indexer_queue_request_remove(queue); + worker_send_request(conn, request); + } +} + +static void queue_listen_callback(struct indexer_queue *queue) +{ + queue_try_send_more(queue); +} + +static void +worker_status_callback(int percentage, struct indexer_request *request) +{ + if (percentage >= 0 && percentage < 100) { + indexer_queue_request_status(queue, request, + percentage); + return; + } + + indexer_queue_request_finish(queue, &request, + percentage == 100); +} + +static void worker_avail_callback(void) +{ + /* A new worker became available. Try to shrink the queue. */ + queue_try_send_more(queue); +} + +int main(int argc, char *argv[]) +{ + const char *error; + + master_service = master_service_init("indexer", 0, &argc, &argv, ""); + if (master_getopt(master_service) > 0) + return FATAL_DEFAULT; + + if (master_service_settings_read_simple(master_service, NULL, + &error) < 0) + i_fatal("Error reading configuration: %s", error); + set = master_service_settings_get(master_service); + + master_service_init_log(master_service); + restrict_access_by_env(RESTRICT_ACCESS_FLAG_ALLOW_ROOT, NULL); + restrict_access_allow_coredumps(TRUE); + master_service_set_idle_die_callback(master_service, idle_die); + + queue = indexer_queue_init(indexer_client_status_callback); + indexer_queue_set_listen_callback(queue, queue_listen_callback); + worker_pool = worker_pool_init("indexer-worker", + worker_status_callback, + worker_avail_callback); + master_service_init_finish(master_service); + + master_service_run(master_service, client_connected); + + indexer_queue_cancel_all(queue); + indexer_clients_destroy_all(); + worker_pool_deinit(&worker_pool); + indexer_queue_deinit(&queue); + + master_service_deinit(&master_service); + return 0; +} diff --git a/src/indexer/indexer.h b/src/indexer/indexer.h new file mode 100644 index 0000000..2234f2d --- /dev/null +++ b/src/indexer/indexer.h @@ -0,0 +1,12 @@ +#ifndef INDEXER_H +#define INDEXER_H + +struct indexer_request; + +/* percentage: -1 = failed, 0..99 = indexing in progress, 100 = done */ +typedef void +indexer_status_callback_t(int percentage, struct indexer_request *request); + +void indexer_refresh_proctitle(void); + +#endif diff --git a/src/indexer/master-connection.c b/src/indexer/master-connection.c new file mode 100644 index 0000000..14f3c7d --- /dev/null +++ b/src/indexer/master-connection.c @@ -0,0 +1,365 @@ +/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "connection.h" +#include "ioloop.h" +#include "istream.h" +#include "ostream.h" +#include "strescape.h" +#include "process-title.h" +#include "master-service.h" +#include "master-service-settings.h" +#include "mail-namespace.h" +#include "mail-storage-private.h" +#include "mail-storage-service.h" +#include "mail-search-build.h" +#include "master-connection.h" + +#include <unistd.h> + +#define INDEXER_PROTOCOL_MAJOR_VERSION 1 +#define INDEXER_PROTOCOL_MINOR_VERSION 0 + +#define INDEXER_MASTER_NAME "indexer-master-worker" +#define INDEXER_WORKER_NAME "indexer-worker-master" + +static struct event_category event_category_indexer_worker = { + .name = "indexer-worker", +}; + +struct master_connection { + struct connection conn; + struct mail_storage_service_ctx *storage_service; + + bool version_received:1; +}; + +static void ATTR_NULL(1, 2) +indexer_worker_refresh_proctitle(const char *username, const char *mailbox, + uint32_t seq1, uint32_t seq2) +{ + if (!master_service_settings_get(master_service)->verbose_proctitle) + return; + + if (username == NULL) + process_title_set("[idling]"); + else if (seq1 == 0) + process_title_set(t_strdup_printf("[%s %s]", username, mailbox)); + else { + process_title_set(t_strdup_printf("[%s %s - %u/%u]", + username, mailbox, seq1, seq2)); + } +} + +static const char * +get_attempt_error(unsigned int counter, uint32_t first_uid, uint32_t last_uid) +{ + if (counter == 0) + return " (no mails indexed)"; + return t_strdup_printf( + " (attempted to index %u messages between UIDs %u..%u)", + counter, first_uid, last_uid); +} + +static int +index_mailbox_precache(struct master_connection *conn, struct mailbox *box) +{ + struct mail_storage *storage = mailbox_get_storage(box); + const char *username = mail_storage_get_user(storage)->username; + const char *box_vname = mailbox_get_vname(box); + const char *errstr; + enum mail_error error; + struct mailbox_status status; + struct mailbox_transaction_context *trans; + struct mail_search_args *search_args; + struct mail_search_context *ctx; + struct mail *mail; + struct mailbox_metadata metadata; + uint32_t seq, first_uid = 0, last_uid = 0; + char percentage_str[2+1+1]; + unsigned int counter = 0, max, percentage, percentage_sent = 0; + int ret = 0; + struct event *index_event = event_create(box->event); + event_add_category(index_event, &event_category_indexer_worker); + + if (mailbox_get_metadata(box, MAILBOX_METADATA_PRECACHE_FIELDS, + &metadata) < 0) { + e_error(index_event, "Precache-fields lookup failed: %s", + mailbox_get_last_internal_error(box, NULL)); + event_unref(&index_event); + return -1; + } + if (mailbox_get_status(box, STATUS_MESSAGES | STATUS_LAST_CACHED_SEQ, + &status) < 0) { + e_error(index_event, "Status lookup failed: %s", + mailbox_get_last_internal_error(box, NULL)); + event_unref(&index_event); + return -1; + } + seq = status.last_cached_seq + 1; + + trans = mailbox_transaction_begin(box, MAILBOX_TRANSACTION_FLAG_NO_CACHE_DEC, + "indexing"); + search_args = mail_search_build_init(); + mail_search_build_add_seqset(search_args, seq, status.messages); + + event_enable_user_cpu_usecs(index_event); + + ctx = mailbox_search_init(trans, search_args, NULL, + metadata.precache_fields, NULL); + mail_search_args_unref(&search_args); + + max = status.messages + 1 - seq; + while (mailbox_search_next(ctx, &mail)) { + if (first_uid == 0) + first_uid = mail->uid; + last_uid = mail->uid; + e_debug(index_event, "Indexing UID=%u", mail->uid); + + if (mail_precache(mail) < 0) { + e_error(index_event, "Precache for UID=%u failed: %s%s", + mail->uid, + mailbox_get_last_internal_error(box, NULL), + get_attempt_error(counter, first_uid, last_uid)); + ret = -1; + break; + } + if (++counter % 100 == 0) { + percentage = counter*100 / max; + if (percentage != percentage_sent && percentage < 100) { + percentage_sent = percentage; + if (i_snprintf(percentage_str, + sizeof(percentage_str), "%u\n", + percentage) < 0) + i_unreached(); + o_stream_nsend_str(conn->conn.output, + percentage_str); + } + indexer_worker_refresh_proctitle(username, box_vname, + counter, max); + } + } + if (mailbox_search_deinit(&ctx) < 0) { + e_error(index_event, "Mail search failed: %s%s", + mailbox_get_last_internal_error(box, NULL), + get_attempt_error(counter, first_uid, last_uid)); + ret = -1; + } + const char *uids = first_uid == 0 ? "" : + t_strdup_printf(" (UIDs %u..%u)", first_uid, last_uid); + event_add_int(index_event, "message_count", counter); + event_add_int(index_event, "first_uid", first_uid); + event_add_int(index_event, "last_uid", last_uid); + +#define FINISHED_EVENT_NAME "indexer_worker_indexing_finished" + if (mailbox_transaction_commit(&trans) < 0) { + struct event_passthrough *e = event_create_passthrough(index_event)-> + set_name(FINISHED_EVENT_NAME); + errstr = t_strdup_printf("Transaction commit failed: %s", + mailbox_get_last_internal_error(box, &error)); + e->add_str("error", errstr); + const char *log_error = t_strdup_printf("%s (attempted to index %u messages%s)", + errstr, counter, uids); + if (error != MAIL_ERROR_NOTFOUND) + e_error(e->event(), "%s", log_error); + else + e_debug(e->event(), "%s", log_error); + ret = -1; + } else { + struct event_passthrough *e = event_create_passthrough(index_event)-> + set_name(FINISHED_EVENT_NAME); + e_debug(e->event(), "Indexed %u messages%s", counter, uids); + } + event_unref(&index_event); + return ret; +} + +static int +index_mailbox(struct master_connection *conn, struct mail_user *user, + const char *mailbox, unsigned int max_recent_msgs, + const char *what) +{ + struct mail_namespace *ns; + struct mailbox *box; + struct mailbox_status status; + const char *path, *errstr; + enum mail_error error; + enum mailbox_sync_flags sync_flags = MAILBOX_SYNC_FLAG_FULL_READ; + int ret; + + ns = mail_namespace_find(user->namespaces, mailbox); + box = mailbox_alloc(ns->list, mailbox, 0); + ret = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX, &path); + if (ret < 0) { + errstr = mailbox_get_last_internal_error(box, &error); + if (error != MAIL_ERROR_NOTFOUND) + e_error(box->event, "Getting path failed: %s", errstr); + mailbox_free(&box); + return -1; + } + if (ret == 0) { + e_info(box->event, "Indexes disabled, skipping"); + mailbox_free(&box); + return 0; + } + ret = 0; + + if (max_recent_msgs != 0) { + /* index only if there aren't too many recent messages. + don't bother syncing the mailbox, that alone can take a + while with large maildirs. */ + if (mailbox_open(box) < 0) { + errstr = mailbox_get_last_internal_error(box, &error); + if (error != MAIL_ERROR_NOTFOUND) + e_error(box->event, "Opening failed: %s", + errstr); + ret = -1; + } else { + mailbox_get_open_status(box, STATUS_RECENT, &status); + } + if (ret < 0 || status.recent > max_recent_msgs) { + mailbox_free(&box); + return ret; + } + } + + if (strchr(what, 'o') != NULL) + sync_flags |= MAILBOX_SYNC_FLAG_OPTIMIZE; + + if (mailbox_sync(box, sync_flags) < 0) { + errstr = mailbox_get_last_internal_error(box, &error); + if (error != MAIL_ERROR_NOTFOUND) { + e_error(box->event, "Syncing failed: %s", errstr); + } else { + e_debug(box->event, "Syncing failed: %s", errstr); + } + ret = -1; + } else if (strchr(what, 'i') != NULL) { + if (index_mailbox_precache(conn, box) < 0) + ret = -1; + } + mailbox_free(&box); + return ret; +} + +static int +master_connection_input_args(struct connection *_conn, const char *const *args) +{ + struct master_connection *conn = + container_of(_conn, struct master_connection, conn); + struct mail_storage_service_input input; + struct mail_storage_service_user *service_user; + struct mail_user *user; + const char *str, *error; + unsigned int max_recent_msgs; + int ret; + + /* <username> <mailbox> <session ID> <max_recent_msgs> [i][o] */ + if (str_array_length(args) != 5 || + str_to_uint(args[3], &max_recent_msgs) < 0 || args[4][0] == '\0') { + e_error(conn->conn.event, "Invalid input from master: %s", + t_strarray_join(args, "\t")); + return -1; + } + + i_zero(&input); + input.module = "mail"; + input.service = "indexer-worker"; + input.username = args[0]; + /* if session-id is given, use it as a prefix to a unique session ID. + we can't use the session-id directly or stats process will complain + about duplicates. (especially LMTP would use the same session-id for + multiple users' indexing at the same time.) */ + if (args[2][0] != '\0') + input.session_id_prefix = args[2]; + + if (mail_storage_service_lookup_next(conn->storage_service, &input, + &service_user, &user, &error) <= 0) { + e_error(conn->conn.event, "User %s lookup failed: %s", args[0], error); + ret = -1; + } else { + indexer_worker_refresh_proctitle(user->username, args[1], 0, 0); + struct event_reason *reason = + event_reason_begin("indexer:index_mailbox"); + ret = index_mailbox(conn, user, args[1], + max_recent_msgs, args[4]); + event_reason_end(&reason); + /* refresh proctitle before a potentially long-running + user unref */ + indexer_worker_refresh_proctitle(user->username, "(deinit)", 0, 0); + mail_user_deinit(&user); + mail_storage_service_user_unref(&service_user); + indexer_worker_refresh_proctitle(NULL, NULL, 0, 0); + } + + str = ret < 0 ? "-1\n" : "100\n"; + o_stream_nsend_str(conn->conn.output, str); + return ret; +} + +static void master_connection_destroy(struct connection *connection) +{ + connection_deinit(connection); + i_free(connection); + master_service_client_connection_destroyed(master_service); +} + +static int master_connection_handshake_args(struct connection *connection, + const char *const *args) +{ + int ret; + if ((ret = connection_handshake_args_default(connection, args)) < 1) + return ret; + const char *limit = t_strdup_printf("%u\n", + master_service_get_process_limit(master_service)); + o_stream_nsend_str(connection->output, limit); + return 1; +} + +static struct connection_list *master_connection_list = NULL; + +static const struct connection_vfuncs master_connection_vfuncs = { + .destroy = master_connection_destroy, + .input_args = master_connection_input_args, + .handshake_args = master_connection_handshake_args, +}; + +static const struct connection_settings master_connection_set = { + .service_name_in = INDEXER_MASTER_NAME, + .service_name_out = INDEXER_WORKER_NAME, + .major_version = INDEXER_PROTOCOL_MAJOR_VERSION, + .minor_version = INDEXER_PROTOCOL_MINOR_VERSION, + .input_max_size = SIZE_MAX, + .output_max_size = SIZE_MAX, +}; + +bool +master_connection_create(struct master_service_connection *master, + struct mail_storage_service_ctx *storage_service) +{ + struct master_connection *conn; + + if (master_connection_list == NULL) { + master_connection_list = + connection_list_init(&master_connection_set, + &master_connection_vfuncs); + } else if (master_connection_list->connections_count > 0) { + return FALSE; + } + + conn = i_new(struct master_connection, 1); + conn->storage_service = storage_service; + conn->conn.event_parent = event_create(NULL); + event_add_category(conn->conn.event_parent, &event_category_indexer_worker); + connection_init_server(master_connection_list, &conn->conn, + master->name, master->fd, master->fd); + + event_unref(&conn->conn.event_parent); + return TRUE; +} + +void master_connections_destroy(void) +{ + if (master_connection_list != NULL) + connection_list_deinit(&master_connection_list); +} diff --git a/src/indexer/master-connection.h b/src/indexer/master-connection.h new file mode 100644 index 0000000..7dcb70e --- /dev/null +++ b/src/indexer/master-connection.h @@ -0,0 +1,8 @@ +#ifndef MASTER_CONNECTION_H +#define MASTER_CONNECTION_H + +bool master_connection_create(struct master_service_connection *conn, + struct mail_storage_service_ctx *storage_service); +void master_connections_destroy(void); + +#endif diff --git a/src/indexer/worker-connection.c b/src/indexer/worker-connection.c new file mode 100644 index 0000000..19e2a41 --- /dev/null +++ b/src/indexer/worker-connection.c @@ -0,0 +1,196 @@ +/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "array.h" +#include "aqueue.h" +#include "connection.h" +#include "ioloop.h" +#include "istream.h" +#include "llist.h" +#include "ostream.h" +#include "str.h" +#include "strescape.h" +#include "master-service.h" +#include "indexer-queue.h" +#include "worker-connection.h" + +#include <unistd.h> + +#define INDEXER_PROTOCOL_MAJOR_VERSION 1 +#define INDEXER_PROTOCOL_MINOR_VERSION 0 + +#define INDEXER_MASTER_NAME "indexer-master-worker" +#define INDEXER_WORKER_NAME "indexer-worker-master" + +struct worker_connection { + struct connection conn; + + indexer_status_callback_t *callback; + worker_available_callback_t *avail_callback; + + char *request_username; + struct indexer_request *request; +}; + +static unsigned int worker_last_process_limit = 0; + +static void worker_connection_call_callback(struct worker_connection *worker, + int percentage) +{ + if (worker->request != NULL) + worker->callback(percentage, worker->request); + if (percentage < 0 || percentage == 100) + worker->request = NULL; +} + +void worker_connection_destroy(struct connection *conn) +{ + struct worker_connection *worker = + container_of(conn, struct worker_connection, conn); + + worker_connection_call_callback(worker, -1); + i_free_and_null(worker->request_username); + connection_deinit(conn); + + worker->avail_callback(); + i_free(conn); +} + +static int +worker_connection_handshake_args(struct connection *conn, const char *const *args) +{ + unsigned int process_limit; + int ret; + if (!conn->version_received) { + if ((ret = connection_handshake_args_default(conn, args)) < 1) + return ret; + /* we are not done yet */ + return 0; + } + if (str_to_uint(args[0], &process_limit) < 0 || + process_limit == 0) { + e_error(conn->event, "Worker sent invalid process limit '%s'", + args[0]); + return -1; + } + worker_last_process_limit = process_limit; + return 1; +} + +static int +worker_connection_input_args(struct connection *conn, const char *const *args) +{ + struct worker_connection *worker = + container_of(conn, struct worker_connection, conn); + int percentage; + int ret = 1; + + if (str_to_int(args[0], &percentage) < 0 || + percentage < -1 || percentage > 100) { + e_error(conn->event, "Worker sent invalid progress '%s'", args[0]); + return -1; + } + + if (percentage < 0) + ret = -1; + + worker_connection_call_callback(worker, percentage); + if (worker->request == NULL) { + /* disconnect after each request */ + ret = -1; + } + + return ret; +} + +bool worker_connection_is_connected(struct connection *conn) +{ + return !conn->disconnected; +} + +unsigned int worker_connections_get_process_limit(void) +{ + return worker_last_process_limit; +} + +void worker_connection_request(struct connection *conn, + struct indexer_request *request) +{ + struct worker_connection *worker = + container_of(conn, struct worker_connection, conn); + + i_assert(worker_connection_is_connected(conn)); + i_assert(request->index || request->optimize); + + if (worker->request_username == NULL) + worker->request_username = i_strdup(request->username); + else { + i_assert(strcmp(worker->request_username, + request->username) == 0); + } + + worker->request = request; + + T_BEGIN { + string_t *str = t_str_new(128); + + str_append_tabescaped(str, request->username); + str_append_c(str, '\t'); + str_append_tabescaped(str, request->mailbox); + str_append_c(str, '\t'); + if (request->session_id != NULL) + str_append_tabescaped(str, request->session_id); + str_printfa(str, "\t%u\t", request->max_recent_msgs); + if (request->index) + str_append_c(str, 'i'); + if (request->optimize) + str_append_c(str, 'o'); + str_append_c(str, '\n'); + o_stream_nsend(conn->output, str_data(str), str_len(str)); + } T_END; +} + +const char *worker_connection_get_username(struct connection *conn) +{ + struct worker_connection *worker = + container_of(conn, struct worker_connection, conn); + return worker->request_username; +} + +static const struct connection_vfuncs worker_connection_vfuncs = { + .destroy = worker_connection_destroy, + .input_args = worker_connection_input_args, + .handshake_args = worker_connection_handshake_args, +}; + +static const struct connection_settings worker_connection_set = { + .service_name_in = INDEXER_WORKER_NAME, + .service_name_out = INDEXER_MASTER_NAME, + .major_version = INDEXER_PROTOCOL_MAJOR_VERSION, + .minor_version = INDEXER_PROTOCOL_MINOR_VERSION, + .input_max_size = SIZE_MAX, + .output_max_size = SIZE_MAX, + .client = TRUE, +}; + +struct connection_list *worker_connection_list_create(void) +{ + return connection_list_init(&worker_connection_set, + &worker_connection_vfuncs); +} + +struct connection * +worker_connection_create(const char *socket_path, + indexer_status_callback_t *callback, + worker_available_callback_t *avail_callback, + struct connection_list *list) +{ + struct worker_connection *conn; + + conn = i_new(struct worker_connection, 1); + conn->callback = callback; + conn->avail_callback = avail_callback; + connection_init_client_unix(list, &conn->conn, socket_path); + + return &conn->conn; +} diff --git a/src/indexer/worker-connection.h b/src/indexer/worker-connection.h new file mode 100644 index 0000000..e664c7e --- /dev/null +++ b/src/indexer/worker-connection.h @@ -0,0 +1,36 @@ +#ifndef WORKER_CONNECTION_H +#define WORKER_CONNECTION_H + +#include "indexer.h" + +struct indexer_request; +struct connection_list; + +typedef void worker_available_callback_t(void); + +struct connection * +worker_connection_create(const char *socket_path, + indexer_status_callback_t *callback, + worker_available_callback_t *avail_callback, + struct connection_list *list); +void worker_connection_destroy(struct connection *conn); + +struct connection_list *worker_connection_list_create(void); + +/* Returns TRUE if worker is connected to (not necessarily handshaked yet) */ +bool worker_connection_is_connected(struct connection *conn); + +/* Returns the last process_limit returned by a worker connection handshake. + If no handshakes have been received yet, returns 0. */ +unsigned int worker_connections_get_process_limit(void); + +/* Send a new indexing request for username+mailbox. The status callback is + called as necessary. Requests can be queued, but only for the same + username. */ +void worker_connection_request(struct connection *conn, + struct indexer_request *request); +/* Returns username of the currently pending requests, + or NULL if there are none. */ +const char *worker_connection_get_username(struct connection *conn); + +#endif diff --git a/src/indexer/worker-pool.c b/src/indexer/worker-pool.c new file mode 100644 index 0000000..e0de136 --- /dev/null +++ b/src/indexer/worker-pool.c @@ -0,0 +1,98 @@ +/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "ioloop.h" +#include "llist.h" +#include "connection.h" +#include "master-service.h" +#include "worker-connection.h" +#include "worker-pool.h" + +#define MAX_WORKER_IDLE_SECS (60*5) + +struct worker_pool { + char *socket_path; + indexer_status_callback_t *callback; + worker_available_callback_t *avail_callback; + + struct connection_list *connection_list; +}; + +struct worker_pool * +worker_pool_init(const char *socket_path, indexer_status_callback_t *callback, + worker_available_callback_t *avail_callback) +{ + struct worker_pool *pool; + + pool = i_new(struct worker_pool, 1); + pool->socket_path = i_strdup(socket_path); + pool->callback = callback; + pool->avail_callback = avail_callback; + pool->connection_list = worker_connection_list_create(); + return pool; +} + +void worker_pool_deinit(struct worker_pool **_pool) +{ + struct worker_pool *pool = *_pool; + + *_pool = NULL; + + if (pool->connection_list != NULL) + connection_list_deinit(&pool->connection_list); + + i_free(pool->connection_list); + i_free(pool->socket_path); + i_free(pool); +} + +bool worker_pool_have_connections(struct worker_pool *pool) +{ + return pool->connection_list->connections != NULL; +} + +static int worker_pool_add_connection(struct worker_pool *pool, + struct connection **conn_r) +{ + struct connection *conn; + + conn = worker_connection_create(pool->socket_path, pool->callback, + pool->avail_callback, + pool->connection_list); + if (connection_client_connect(conn) < 0) { + worker_connection_destroy(conn); + return -1; + } + + *conn_r = conn; + return 0; +} + +bool worker_pool_get_connection(struct worker_pool *pool, + struct connection **conn_r) +{ + unsigned int max_connections; + + max_connections = I_MAX(1, worker_connections_get_process_limit()); + if (pool->connection_list->connections_count >= max_connections) + return FALSE; + if (worker_pool_add_connection(pool, conn_r) < 0) + return FALSE; + + return TRUE; +} + +struct connection * +worker_pool_find_username_connection(struct worker_pool *pool, + const char *username) +{ + struct connection *list; + const char *worker_user; + + for (list = pool->connection_list->connections; list != NULL; list = list->next) { + worker_user = worker_connection_get_username(list); + if (worker_user != NULL && strcmp(worker_user, username) == 0) + return list; + } + return NULL; +} diff --git a/src/indexer/worker-pool.h b/src/indexer/worker-pool.h new file mode 100644 index 0000000..bf739bb --- /dev/null +++ b/src/indexer/worker-pool.h @@ -0,0 +1,23 @@ +#ifndef WORKER_POOL_H +#define WORKER_POOL_H + +#include "indexer.h" +#include "worker-connection.h" + +struct connection; + +struct worker_pool * +worker_pool_init(const char *socket_path, indexer_status_callback_t *callback, + worker_available_callback_t *avail_callback); +void worker_pool_deinit(struct worker_pool **pool); + +bool worker_pool_have_connections(struct worker_pool *pool); + +bool worker_pool_get_connection(struct worker_pool *pool, + struct connection **conn_r); + +struct connection * +worker_pool_find_username_connection(struct worker_pool *pool, + const char *username); + +#endif |