dovecot-2.0-sslstream: Added "size" setting type, which supports...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Feb 13 02:56:11 EET 2010
details: http://hg.dovecot.org/dovecot-2.0-sslstream/rev/4b663b9e63af
changeset: 10282:4b663b9e63af
user: Timo Sirainen <tss at iki.fi>
date: Mon Nov 09 18:22:37 2009 -0500
description:
Added "size" setting type, which supports B/k/M/G/T suffixes.
diffstat:
23 files changed, 124 insertions(+), 41 deletions(-)
doc/example-config/conf.d/auth.conf | 5 -
doc/example-config/conf.d/imap.conf | 6 -
doc/example-config/conf.d/mail.conf | 13 +--
doc/example-config/conf.d/master.conf | 6 -
src/auth/auth-settings.c | 2
src/auth/auth-settings.h | 2
src/auth/passdb-cache.c | 2
src/config/config-request.c | 8 ++
src/imap/imap-settings.c | 4 -
src/imap/imap-settings.h | 2
src/lib-master/service-settings.h | 2
src/lib-settings/settings-parser.c | 70 +++++++++++++++++++++
src/lib-settings/settings-parser.h | 7 ++
src/lib-storage/index/dbox-multi/mdbox-settings.c | 6 -
src/lib-storage/index/dbox-multi/mdbox-settings.h | 4 -
src/lib-storage/index/mbox/mbox-settings.c | 2
src/lib-storage/index/mbox/mbox-settings.h | 2
src/lib-storage/index/mbox/mbox-storage.c | 2
src/master/master-settings.c | 8 +-
src/master/master-settings.h | 2
src/master/service-process.c | 6 -
src/master/service.c | 2
src/master/service.h | 2
diffs (truncated from 513 to 300 lines):
diff -r cd1ce06a0ee5 -r 4b663b9e63af doc/example-config/conf.d/auth.conf
--- a/doc/example-config/conf.d/auth.conf Mon Nov 09 15:12:01 2009 -0500
+++ b/doc/example-config/conf.d/auth.conf Mon Nov 09 18:22:37 2009 -0500
@@ -2,9 +2,8 @@
## Authentication processes
##
-# Authentication cache size in kilobytes. 0 means it's disabled.
-# Note that bsdauth, PAM and vpopmail require cache_key to be set for caching
-# to be used.
+# Authentication cache size (e.g. 10M). 0 means it's disabled. Note that
+# bsdauth, PAM and vpopmail require cache_key to be set for caching to be used.
#auth_cache_size = 0
# Time to live in seconds for cached data. After this many seconds the cached
# record is no longer used, *except* if the main database lookup returns
diff -r cd1ce06a0ee5 -r 4b663b9e63af doc/example-config/conf.d/imap.conf
--- a/doc/example-config/conf.d/imap.conf Mon Nov 09 15:12:01 2009 -0500
+++ b/doc/example-config/conf.d/imap.conf Mon Nov 09 18:22:37 2009 -0500
@@ -3,10 +3,10 @@
##
protocol imap {
- # Maximum IMAP command line length in bytes. Some clients generate very long
- # command lines with huge mailboxes, so you may need to raise this if you get
+ # Maximum IMAP command line length. Some clients generate very long command
+ # lines with huge mailboxes, so you may need to raise this if you get
# "Too long argument" or "IMAP command line too large" errors often.
- #imap_max_line_length = 65536
+ #imap_max_line_length = 64k
# Maximum number of IMAP connections allowed for a user from each IP address.
# NOTE: The username is compared case-sensitively.
diff -r cd1ce06a0ee5 -r 4b663b9e63af doc/example-config/conf.d/mail.conf
--- a/doc/example-config/conf.d/mail.conf Mon Nov 09 15:12:01 2009 -0500
+++ b/doc/example-config/conf.d/mail.conf Mon Nov 09 18:22:37 2009 -0500
@@ -295,7 +295,7 @@
# aren't immediately visible to other MUAs.
#mbox_lazy_writes = yes
-# If mbox size is smaller than this (in kilobytes), don't write index files.
+# If mbox size is smaller than this (e.g. 100k), don't write index files.
# If an index file already exists it's still read, just not updated.
#mbox_min_index_size = 0
@@ -303,12 +303,11 @@
## mdbox-specific settings
##
-# Maximum dbox file size in kilobytes until it's rotated.
-#mdbox_rotate_size = 2048
-
-# Minimum dbox file size in kilobytes before it's rotated
-# (overrides mdbox_rotate_days)
-#mdbox_rotate_min_size = 16
+# Maximum dbox file size until it's rotated.
+#mdbox_rotate_size = 2M
+
+# Minimum dbox file size before it's rotated (overrides mdbox_rotate_days)
+#mdbox_rotate_min_size = 16k
# Maximum dbox file age in days until it's rotated. Day always begins from
# midnight, so 1 = today, 2 = yesterday, etc. 0 = check disabled.
diff -r cd1ce06a0ee5 -r 4b663b9e63af doc/example-config/conf.d/master.conf
--- a/doc/example-config/conf.d/master.conf Mon Nov 09 15:12:01 2009 -0500
+++ b/doc/example-config/conf.d/master.conf Mon Nov 09 18:22:37 2009 -0500
@@ -1,6 +1,6 @@
#default_process_limit = 100
#default_client_limit = 1000
-#default_vsz_limit = 256
+#default_vsz_limit = 256M
service imap-login {
inet_listener {
@@ -17,7 +17,7 @@ service imap-login {
#service_count = 1
# If you set service_count=0, you probably need to grow this.
- #vsz_limit = 64
+ #vsz_limit = 64M
}
service pop3-login {
@@ -39,7 +39,7 @@ service imap {
service imap {
# Most of the memory goes to mmap()ing files. You may need to increase this
# limit if you have huge mailboxes.
- #vsz_limit = 256
+ #vsz_limit = 256M
}
service auth {
diff -r cd1ce06a0ee5 -r 4b663b9e63af src/auth/auth-settings.c
--- a/src/auth/auth-settings.c Mon Nov 09 15:12:01 2009 -0500
+++ b/src/auth/auth-settings.c Mon Nov 09 18:22:37 2009 -0500
@@ -151,7 +151,7 @@ static const struct setting_define auth_
DEF(SET_STR, mechanisms),
DEF(SET_STR, realms),
DEF(SET_STR, default_realm),
- DEF(SET_UINT, cache_size),
+ DEF(SET_SIZE, cache_size),
DEF(SET_UINT, cache_ttl),
DEF(SET_UINT, cache_negative_ttl),
DEF(SET_STR, username_chars),
diff -r cd1ce06a0ee5 -r 4b663b9e63af src/auth/auth-settings.h
--- a/src/auth/auth-settings.h Mon Nov 09 15:12:01 2009 -0500
+++ b/src/auth/auth-settings.h Mon Nov 09 18:22:37 2009 -0500
@@ -20,7 +20,7 @@ struct auth_settings {
const char *mechanisms;
const char *realms;
const char *default_realm;
- unsigned int cache_size;
+ uoff_t cache_size;
unsigned int cache_ttl;
unsigned int cache_negative_ttl;
const char *username_chars;
diff -r cd1ce06a0ee5 -r 4b663b9e63af src/auth/passdb-cache.c
--- a/src/auth/passdb-cache.c Mon Nov 09 15:12:01 2009 -0500
+++ b/src/auth/passdb-cache.c Mon Nov 09 18:22:37 2009 -0500
@@ -127,7 +127,7 @@ void passdb_cache_init(const struct auth
if (set->cache_size == 0 || set->cache_ttl == 0)
return;
- passdb_cache = auth_cache_new(set->cache_size * 1024UL, set->cache_ttl,
+ passdb_cache = auth_cache_new(set->cache_size, set->cache_ttl,
set->cache_negative_ttl);
}
diff -r cd1ce06a0ee5 -r 4b663b9e63af src/config/config-request.c
--- a/src/config/config-request.c Mon Nov 09 15:12:01 2009 -0500
+++ b/src/config/config-request.c Mon Nov 09 18:22:37 2009 -0500
@@ -128,6 +128,14 @@ settings_export(struct settings_export_c
}
break;
}
+ case SET_SIZE: {
+ const uoff_t *val = value, *dval = default_value;
+ if (dump_default || dval == NULL || *val != *dval) {
+ str_printfa(ctx->value, "%llu",
+ (unsigned long long)*val);
+ }
+ break;
+ }
case SET_UINT: {
const unsigned int *val = value, *dval = default_value;
if (dump_default || dval == NULL || *val != *dval)
diff -r cd1ce06a0ee5 -r 4b663b9e63af src/imap/imap-settings.c
--- a/src/imap/imap-settings.c Mon Nov 09 15:12:01 2009 -0500
+++ b/src/imap/imap-settings.c Mon Nov 09 18:22:37 2009 -0500
@@ -62,7 +62,7 @@ static const struct setting_define imap_
DEF(SET_BOOL, mail_debug),
DEF(SET_BOOL, verbose_proctitle),
- DEF(SET_UINT, imap_max_line_length),
+ DEF(SET_SIZE, imap_max_line_length),
DEF(SET_UINT, imap_idle_notify_interval),
DEF(SET_STR, imap_capability),
DEF(SET_STR, imap_client_workarounds),
@@ -80,7 +80,7 @@ static const struct imap_settings imap_d
/* RFC-2683 recommends at least 8000 bytes. Some clients however don't
break large message sets to multiple commands, so we're pretty
liberal by default. */
- MEMBER(imap_max_line_length) 65536,
+ MEMBER(imap_max_line_length) 64*1024,
MEMBER(imap_idle_notify_interval) 120,
MEMBER(imap_capability) "",
MEMBER(imap_client_workarounds) "outlook-idle",
diff -r cd1ce06a0ee5 -r 4b663b9e63af src/imap/imap-settings.h
--- a/src/imap/imap-settings.h Mon Nov 09 15:12:01 2009 -0500
+++ b/src/imap/imap-settings.h Mon Nov 09 18:22:37 2009 -0500
@@ -16,7 +16,7 @@ struct imap_settings {
bool verbose_proctitle;
/* imap: */
- unsigned int imap_max_line_length;
+ uoff_t imap_max_line_length;
unsigned int imap_idle_notify_interval;
const char *imap_capability;
const char *imap_client_workarounds;
diff -r cd1ce06a0ee5 -r 4b663b9e63af src/lib-master/service-settings.h
--- a/src/lib-master/service-settings.h Mon Nov 09 15:12:01 2009 -0500
+++ b/src/lib-master/service-settings.h Mon Nov 09 18:22:37 2009 -0500
@@ -42,7 +42,7 @@ struct service_settings {
unsigned int process_limit;
unsigned int client_limit;
unsigned int service_count;
- unsigned int vsz_limit;
+ uoff_t vsz_limit;
ARRAY_TYPE(file_listener_settings) unix_listeners;
ARRAY_TYPE(file_listener_settings) fifo_listeners;
diff -r cd1ce06a0ee5 -r 4b663b9e63af src/lib-settings/settings-parser.c
--- a/src/lib-settings/settings-parser.c Mon Nov 09 15:12:01 2009 -0500
+++ b/src/lib-settings/settings-parser.c Mon Nov 09 18:22:37 2009 -0500
@@ -13,6 +13,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <ctype.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -308,6 +309,61 @@ get_uint(struct setting_parser_context *
return 0;
}
+static int
+get_size(struct setting_parser_context *ctx, const char *value,
+ uoff_t *result_r)
+{
+ unsigned long long num, multiply;
+ char *p;
+
+ num = strtoull(value, &p, 10);
+ switch (i_toupper(*p)) {
+ case '\0':
+ multiply = 1;
+ break;
+ case 'B':
+ multiply = 1;
+ p += 1;
+ break;
+ case 'K':
+ multiply = 1024;
+ p += 1;
+ break;
+ case 'M':
+ multiply = 1024*1024;
+ p += 1;
+ break;
+ case 'G':
+ multiply = 1024*1024*1024;
+ p += 1;
+ break;
+ case 'T':
+ multiply = 1024ULL*1024*1024*1024;
+ p += 1;
+ break;
+ }
+
+ if (multiply > 1) {
+ /* Allow: k, ki, kiB */
+ if (i_toupper(*p) == 'I')
+ p++;
+ if (i_toupper(*p) == 'B')
+ p++;
+ }
+ if (*p != '\0') {
+ ctx->error = p_strconcat(ctx->parser_pool, "Invalid size: ",
+ value, NULL);
+ return -1;
+ }
+ if (num > -1ULL / multiply) {
+ ctx->error = p_strconcat(ctx->parser_pool,
+ "Size is too large: ", value, NULL);
+ return -1;
+ }
+ *result_r = num * multiply;
+ return 0;
+}
+
static int get_enum(struct setting_parser_context *ctx, const char *value,
char **result_r, const char *allowed_values)
{
@@ -446,6 +502,10 @@ settings_parse(struct setting_parser_con
break;
case SET_UINT:
if (get_uint(ctx, value, (unsigned int *)ptr) < 0)
+ return -1;
+ break;
+ case SET_SIZE:
+ if (get_size(ctx, value, (uoff_t *)ptr) < 0)
return -1;
break;
case SET_STR:
@@ -902,6 +962,7 @@ settings_var_expand_info(const struct se
switch (def->type) {
case SET_BOOL:
case SET_UINT:
+ case SET_SIZE:
case SET_STR:
case SET_ENUM:
case SET_STRLIST:
@@ -971,6 +1032,7 @@ bool settings_vars_have_key(const struct
switch (def->type) {
case SET_BOOL:
case SET_UINT:
+ case SET_SIZE:
case SET_STR:
case SET_ENUM:
case SET_STRLIST:
@@ -1045,6 +1107,13 @@ setting_copy(enum setting_type type, con
*dest_uint = *src_uint;
break;
}
+ case SET_SIZE: {
+ const uoff_t *src_size = src;
+ uoff_t *dest_size = dest;
+
+ *dest_size = *src_size;
+ break;
More information about the dovecot-cvs
mailing list