dovecot-2.2: Build imapc and pop3c always as plugins.

dovecot at dovecot.org dovecot at dovecot.org
Fri Oct 12 03:18:12 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/269104a0821b
changeset: 15208:269104a0821b
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Oct 12 03:17:56 2012 +0300
description:
Build imapc and pop3c always as plugins.
This avoids having to link openssl library to all binaries that use
lib-storage. It appears that simply by linking with openssl causes each
such process to use 100-200 kB of more memory. With 10k imap processes this
is 1-2 GB of wasted memory.

The imapc and pop3c are still registered as stubs, and their plugins are
automatically loaded when needed.

diffstat:

 configure.in                                        |  25 +++++---------------
 src/lib-storage/index/imapc/Makefile.am             |  17 +++++++++++++-
 src/lib-storage/index/imapc/imapc-list.c            |   2 -
 src/lib-storage/index/imapc/imapc-list.h            |   2 +
 src/lib-storage/index/imapc/imapc-plugin.c          |  21 +++++++++++++++++
 src/lib-storage/index/imapc/imapc-plugin.h          |   7 +++++
 src/lib-storage/index/imapc/imapc-setting-storage.c |  22 ++++++++++++++++++
 src/lib-storage/index/imapc/imapc-settings.h        |   2 +
 src/lib-storage/index/imapc/imapc-storage.c         |   3 --
 src/lib-storage/index/imapc/imapc-storage.h         |   3 ++
 src/lib-storage/index/pop3c/Makefile.am             |  16 ++++++++++++-
 src/lib-storage/index/pop3c/pop3c-plugin.c          |  19 +++++++++++++++
 src/lib-storage/index/pop3c/pop3c-plugin.h          |   7 +++++
 src/lib-storage/index/pop3c/pop3c-setting-storage.c |  22 ++++++++++++++++++
 src/lib-storage/index/pop3c/pop3c-settings.h        |   2 +
 src/lib-storage/index/pop3c/pop3c-storage.c         |   3 --
 src/lib-storage/index/pop3c/pop3c-storage.h         |   2 +
 17 files changed, 146 insertions(+), 29 deletions(-)

diffs (truncated from 370 to 300 lines):

diff -r 985ebfb17f35 -r 269104a0821b configure.in
--- a/configure.in	Fri Oct 12 03:12:19 2012 +0300
+++ b/configure.in	Fri Oct 12 03:17:56 2012 +0300
@@ -243,14 +243,14 @@
   want_gc=no)
 
 AC_ARG_WITH(storages,
-AS_HELP_STRING([--with-storages], [Build with specified mail storage formats (mdbox sdbox maildir mbox cydir imapc pop3c)]), [
+AS_HELP_STRING([--with-storages], [Build with specified mail storage formats (mdbox sdbox maildir mbox cydir)]), [
 	if test "$withval" = "yes" || test "$withval" = "no"; then
 		AC_MSG_ERROR([--with-storages needs storage list as parameter])
 	fi
 	mail_storages="shared `echo "$withval"|sed 's/,/ /g'`" ],
-	mail_storages="shared mdbox sdbox maildir mbox cydir imapc pop3c")
+	mail_storages="shared mdbox sdbox maildir mbox cydir")
 AC_SUBST(mail_storages)
-mail_storages="$mail_storages raw"
+mail_storages="$mail_storages imapc_stub pop3c_stub raw"
 # drop duplicates
 duplicates=`(for i in $mail_storages; do echo $i; done)|sort|uniq -d|xargs echo`
 if test "$duplicates" != ""; then
@@ -2454,8 +2454,8 @@
 sdbox_libs='$(top_builddir)/src/lib-storage/index/dbox-single/libstorage_dbox_single.la'
 mdbox_libs='$(top_builddir)/src/lib-storage/index/dbox-multi/libstorage_dbox_multi.la'
 cydir_libs='$(top_builddir)/src/lib-storage/index/cydir/libstorage_cydir.la'
-imapc_libs='$(top_builddir)/src/lib-storage/index/imapc/libstorage_imapc.la $(top_builddir)/src/lib-imap-client/libimap_client.la'
-pop3c_libs='$(top_builddir)/src/lib-storage/index/pop3c/libstorage_pop3c.la'
+imapc_stub_libs='$(top_builddir)/src/lib-storage/index/imapc/libstorage_imapc.la'
+pop3c_stub_libs='$(top_builddir)/src/lib-storage/index/pop3c/libstorage_pop3c.la'
 raw_libs='$(top_builddir)/src/lib-storage/index/raw/libstorage_raw.la'
 shared_libs='$(top_builddir)/src/lib-storage/index/shared/libstorage_shared.la'
 
@@ -2475,21 +2475,8 @@
     LINKED_STORAGE_LIBS="$LINKED_STORAGE_LIBS $dbox_common_libs"
     dbox_common_libs=""
   fi
-  if test $storage = imapc; then
-    mailbox_list_drivers="$mailbox_list_drivers imapc"
-    want_ssl_libs=yes
-  fi
-  if test $storage = pop3c; then
-    want_ssl_libs=yes
-  fi
 done
-LINKED_STORAGE_LDADD=
-if test "$want_ssl_libs" = yes; then
-  LINKED_STORAGE_LIBS="$LINKED_STORAGE_LIBS \$(top_builddir)/src/lib-ssl-iostream/libssl_iostream.la"
-  LINKED_STORAGE_LDADD="$SSL_LIBS"
-fi
 AC_SUBST(LINKED_STORAGE_LIBS)
-AC_SUBST(LINKED_STORAGE_LDADD)
 AC_SUBST(mailbox_list_drivers)
 AC_DEFINE_UNQUOTED(MAIL_STORAGES, "$mail_storages", List of compiled in mail storages)
 
@@ -2521,7 +2508,7 @@
   LIBDOVECOT_COMPRESS='$(top_builddir)/src/lib-compression/libcompression.la'
   LIBDOVECOT_LDA='$(top_builddir)/src/lib-lda/liblda.la'
 fi
-LIBDOVECOT_STORAGE="$LIBDOVECOT_STORAGE_DEPS $LINKED_STORAGE_LDADD"
+LIBDOVECOT_STORAGE="$LIBDOVECOT_STORAGE_DEPS"
 LIBDOVECOT_SQL='$(top_builddir)/src/lib-sql/libsql.la'
 AC_SUBST(LIBDOVECOT)
 AC_SUBST(LIBDOVECOT_DEPS)
diff -r 985ebfb17f35 -r 269104a0821b src/lib-storage/index/imapc/Makefile.am
--- a/src/lib-storage/index/imapc/Makefile.am	Fri Oct 12 03:12:19 2012 +0300
+++ b/src/lib-storage/index/imapc/Makefile.am	Fri Oct 12 03:17:56 2012 +0300
@@ -1,4 +1,5 @@
 noinst_LTLIBRARIES = libstorage_imapc.la
+module_LTLIBRARIES = lib20_imapc_plugin.la
 
 AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/lib \
@@ -12,16 +13,27 @@
 	-I$(top_srcdir)/src/lib-storage/list \
 	-I$(top_srcdir)/src/lib-storage/index
 
+NOPLUGIN_LDFLAGS =
+lib20_imapc_plugin_la_LDFLAGS = -module -avoid-version
+
 libstorage_imapc_la_SOURCES = \
+	imapc-settings.c \
+	imapc-setting-storage.c
+
+lib20_imapc_plugin_la_SOURCES = \
 	imapc-list.c \
 	imapc-mail.c \
 	imapc-mail-fetch.c \
 	imapc-mailbox.c \
+	imapc-plugin.c \
 	imapc-save.c \
-	imapc-settings.c \
 	imapc-sync.c \
 	imapc-storage.c
 
+lib20_imapc_plugin_la_LIBADD = \
+	../../../lib-imap-client/libimap_client.la \
+	../../../lib-ssl-iostream/libssl_iostream.la
+
 headers = \
 	imapc-list.h \
 	imapc-mail.h \
@@ -31,3 +43,6 @@
 
 pkginc_libdir=$(pkgincludedir)
 pkginc_lib_HEADERS = $(headers)
+
+noinst_HEADERS = \
+	imapc-plugin.h
diff -r 985ebfb17f35 -r 269104a0821b src/lib-storage/index/imapc/imapc-list.c
--- a/src/lib-storage/index/imapc/imapc-list.c	Fri Oct 12 03:12:19 2012 +0300
+++ b/src/lib-storage/index/imapc/imapc-list.c	Fri Oct 12 03:17:56 2012 +0300
@@ -20,8 +20,6 @@
 	struct mailbox_info info;
 };
 
-extern struct mailbox_list imapc_mailbox_list;
-
 static struct mailbox_list *imapc_list_alloc(void)
 {
 	struct imapc_mailbox_list *list;
diff -r 985ebfb17f35 -r 269104a0821b src/lib-storage/index/imapc/imapc-list.h
--- a/src/lib-storage/index/imapc/imapc-list.h	Fri Oct 12 03:12:19 2012 +0300
+++ b/src/lib-storage/index/imapc/imapc-list.h	Fri Oct 12 03:17:56 2012 +0300
@@ -22,6 +22,8 @@
 	unsigned int index_list_failed:1;
 };
 
+extern struct mailbox_list imapc_mailbox_list;
+
 int imapc_list_get_mailbox_flags(struct mailbox_list *list, const char *name,
 				 enum mailbox_info_flags *flags_r);
 
diff -r 985ebfb17f35 -r 269104a0821b src/lib-storage/index/imapc/imapc-plugin.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib-storage/index/imapc/imapc-plugin.c	Fri Oct 12 03:17:56 2012 +0300
@@ -0,0 +1,21 @@
+/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "imapc-list.h"
+#include "imapc-storage.h"
+#include "imapc-plugin.h"
+
+const char *imapc_plugin_version = DOVECOT_ABI_VERSION;
+
+void imapc_plugin_init(struct module *module ATTR_UNUSED)
+{
+	mail_storage_class_unregister(&imapc_stub_storage);
+	mail_storage_class_register(&imapc_storage);
+	mailbox_list_register(&imapc_mailbox_list);
+}
+
+void imapc_plugin_deinit(void)
+{
+	mail_storage_class_unregister(&imapc_storage);
+	mailbox_list_unregister(&imapc_mailbox_list);
+}
diff -r 985ebfb17f35 -r 269104a0821b src/lib-storage/index/imapc/imapc-plugin.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib-storage/index/imapc/imapc-plugin.h	Fri Oct 12 03:17:56 2012 +0300
@@ -0,0 +1,7 @@
+#ifndef IMAPC_PLUGIN_H
+#define IMAPC_PLUGIN_H
+
+void imapc_plugin_init(struct module *module);
+void imapc_plugin_deinit(void);
+
+#endif
diff -r 985ebfb17f35 -r 269104a0821b src/lib-storage/index/imapc/imapc-setting-storage.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib-storage/index/imapc/imapc-setting-storage.c	Fri Oct 12 03:17:56 2012 +0300
@@ -0,0 +1,22 @@
+/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "imapc-storage.h"
+#include "imapc-settings.h"
+
+struct mail_storage imapc_stub_storage = {
+	.name = IMAPC_STORAGE_NAME,
+	.class_flags = MAIL_STORAGE_CLASS_FLAG_NO_ROOT,
+
+	.v = {
+		imapc_get_setting_parser_info,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL
+	}
+};
diff -r 985ebfb17f35 -r 269104a0821b src/lib-storage/index/imapc/imapc-settings.h
--- a/src/lib-storage/index/imapc/imapc-settings.h	Fri Oct 12 03:12:19 2012 +0300
+++ b/src/lib-storage/index/imapc/imapc-settings.h	Fri Oct 12 03:17:56 2012 +0300
@@ -30,6 +30,8 @@
 	enum imapc_features parsed_features;
 };
 
+extern struct mail_storage imapc_stub_storage;
+
 const struct setting_parser_info *imapc_get_setting_parser_info(void);
 
 #endif
diff -r 985ebfb17f35 -r 269104a0821b src/lib-storage/index/imapc/imapc-storage.c
--- a/src/lib-storage/index/imapc/imapc-storage.c	Fri Oct 12 03:12:19 2012 +0300
+++ b/src/lib-storage/index/imapc/imapc-storage.c	Fri Oct 12 03:17:56 2012 +0300
@@ -27,9 +27,6 @@
 	enum mail_error error;
 };
 
-extern struct mail_storage imapc_storage;
-extern struct mailbox imapc_mailbox;
-
 static struct imapc_resp_code_map imapc_resp_code_map[] = {
 	{ IMAP_RESP_CODE_UNAVAILABLE, MAIL_ERROR_TEMP },
 	{ IMAP_RESP_CODE_AUTHFAILED, MAIL_ERROR_PERM },
diff -r 985ebfb17f35 -r 269104a0821b src/lib-storage/index/imapc/imapc-storage.h
--- a/src/lib-storage/index/imapc/imapc-storage.h	Fri Oct 12 03:12:19 2012 +0300
+++ b/src/lib-storage/index/imapc/imapc-storage.h	Fri Oct 12 03:17:56 2012 +0300
@@ -110,6 +110,9 @@
 	int ret;
 };
 
+extern struct mail_storage imapc_storage;
+extern struct mailbox imapc_mailbox;
+
 struct mail_save_context *
 imapc_save_alloc(struct mailbox_transaction_context *_t);
 int imapc_save_begin(struct mail_save_context *ctx, struct istream *input);
diff -r 985ebfb17f35 -r 269104a0821b src/lib-storage/index/pop3c/Makefile.am
--- a/src/lib-storage/index/pop3c/Makefile.am	Fri Oct 12 03:12:19 2012 +0300
+++ b/src/lib-storage/index/pop3c/Makefile.am	Fri Oct 12 03:17:56 2012 +0300
@@ -1,4 +1,5 @@
 noinst_LTLIBRARIES = libstorage_pop3c.la
+module_LTLIBRARIES = lib20_pop3c_plugin.la
 
 AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/lib \
@@ -11,13 +12,23 @@
 	-I$(top_srcdir)/src/lib-storage \
 	-I$(top_srcdir)/src/lib-storage/index
 
+NOPLUGIN_LDFLAGS =
+lib20_pop3c_plugin_la_LDFLAGS = -module -avoid-version
+
 libstorage_pop3c_la_SOURCES = \
+	pop3c-settings.c \
+	pop3c-setting-storage.c
+
+lib20_pop3c_plugin_la_SOURCES = \
 	pop3c-client.c \
 	pop3c-mail.c \
-	pop3c-settings.c \
+	pop3c-plugin.c \
 	pop3c-storage.c \
 	pop3c-sync.c
 
+lib20_pop3c_plugin_la_LIBADD = \
+	../../../lib-ssl-iostream/libssl_iostream.la
+
 headers = \
 	pop3c-client.h \
 	pop3c-settings.h \
@@ -26,3 +37,6 @@
 
 pkginc_libdir=$(pkgincludedir)
 pkginc_lib_HEADERS = $(headers)
+
+noinst_HEADERS = \
+	pop3c-plugin.h
diff -r 985ebfb17f35 -r 269104a0821b src/lib-storage/index/pop3c/pop3c-plugin.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib-storage/index/pop3c/pop3c-plugin.c	Fri Oct 12 03:17:56 2012 +0300
@@ -0,0 +1,19 @@
+/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "pop3c-storage.h"
+#include "pop3c-settings.h"
+#include "pop3c-plugin.h"
+
+const char *pop3c_plugin_version = DOVECOT_ABI_VERSION;
+
+void pop3c_plugin_init(struct module *module ATTR_UNUSED)
+{
+	mail_storage_class_unregister(&pop3c_stub_storage);
+	mail_storage_class_register(&pop3c_storage);
+}
+
+void pop3c_plugin_deinit(void)
+{
+	mail_storage_class_unregister(&pop3c_storage);
+}
diff -r 985ebfb17f35 -r 269104a0821b src/lib-storage/index/pop3c/pop3c-plugin.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib-storage/index/pop3c/pop3c-plugin.h	Fri Oct 12 03:17:56 2012 +0300
@@ -0,0 +1,7 @@


More information about the dovecot-cvs mailing list