#define DBOX_READ_BLOCK_SIZE 4096
+/* prefer flock(). fcntl() locking currently breaks if trying to access the
+ same file from multiple mail_storages within same process. */
+#ifdef HAVE_FLOCK
+# define DBOX_FILE_LOCK_METHOD FILE_LOCK_METHOD_FLOCK
+#else
+# define DBOX_FILE_LOCK_METHOD FILE_LOCK_METHOD_FCNTL
+#endif
+
const char *dbox_generate_tmp_filename(void)
{
static unsigned int create_count = 0;
i_assert(file->fd != -1);
ret = file_try_lock(file->fd, file->cur_path, F_WRLCK,
- FILE_LOCK_METHOD_FCNTL, &file->lock);
+ DBOX_FILE_LOCK_METHOD, &file->lock);
if (ret < 0) {
mail_storage_set_critical(&file->storage->storage,
"file_try_lock(%s) failed: %m", file->cur_path);
AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib \
-I$(top_srcdir)/src/lib-settings \
+ -I$(top_srcdir)/src/lib-master \
-I$(top_srcdir)/src/lib-mail \
-I$(top_srcdir)/src/lib-imap \
-I$(top_srcdir)/src/lib-index \
#include "array.h"
#include "ioloop.h"
#include "mkdir-parents.h"
+#include "master-service.h"
#include "mail-index-modseq.h"
#include "mail-index-alloc-cache.h"
#include "mailbox-log.h"
return -1;
}
+#ifndef HAVE_FLOCK
+ if (master_service_get_client_limit(master_service) > 1) {
+ *error_r = "mdbox requires client_limit=1 for service "
+ "since your OS doesn't support flock()";
+ return -1;
+ }
+#endif
+
_storage->unique_root_dir =
p_strdup(_storage->pool, ns->list->set.root_dir);
AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib \
-I$(top_srcdir)/src/lib-settings \
+ -I$(top_srcdir)/src/lib-master \
-I$(top_srcdir)/src/lib-mail \
-I$(top_srcdir)/src/lib-imap \
-I$(top_srcdir)/src/lib-index \
/* Copyright (c) 2007-2010 Dovecot authors, see the included COPYING file */
#include "lib.h"
+#include "master-service.h"
#include "mail-index-modseq.h"
#include "dbox-mail.h"
#include "dbox-save.h"
return &storage->storage.storage;
}
+static int
+sdbox_storage_create(struct mail_storage *storage ATTR_UNUSED,
+ struct mail_namespace *ns ATTR_UNUSED,
+ const char **error_r ATTR_UNUSED)
+{
+#ifndef HAVE_FLOCK
+ if (master_service_get_client_limit(master_service) > 1) {
+ *error_r = "dbox requires client_limit=1 for service "
+ "since your OS doesn't support flock()";
+ return -1;
+ }
+#endif
+ return 0;
+}
+
static struct mailbox *
sdbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
const char *name, enum mailbox_flags flags)
.v = {
NULL,
sdbox_storage_alloc,
- NULL,
+ sdbox_storage_create,
NULL,
NULL,
dbox_storage_get_list_settings,