dovecot-2.2: Simplified hash table union now that it again works...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Aug 20 10:54:20 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/9c69df65af7b
changeset: 14926:9c69df65af7b
user: Timo Sirainen <tss at iki.fi>
date: Mon Aug 20 10:54:04 2012 +0300
description:
Simplified hash table union now that it again works only with pointers.
diffstat:
TODO | 15 +++++++++++----
src/doveadm/dsync/dsync-mailbox-export.c | 2 +-
src/doveadm/dsync/dsync-mailbox-import.c | 2 +-
src/doveadm/dsync/dsync-transaction-log-scan.c | 6 +++---
src/doveadm/dsync/dsync-transaction-log-scan.h | 4 ++--
src/lib/hash-decl.h | 3 ---
src/lib/hash.h | 19 ++++++++++---------
7 files changed, 28 insertions(+), 23 deletions(-)
diffs (164 lines):
diff -r 44013be2e3d8 -r 9c69df65af7b TODO
--- a/TODO Mon Aug 20 10:19:57 2012 +0300
+++ b/TODO Mon Aug 20 10:54:04 2012 +0300
@@ -1,4 +1,13 @@
- - Unfinished extensions: MOVE, NOTIFY
+ - crashes: rm -rf ~/abox;printf "1 select inbox\n2 fetch 1 body[]\n"|./imap -o plugin/archive_customer_id=1
+ - connection api: connected(conn, bool success) + errno
+ - mailbox list indexes + imaptest test=tests fails
+ - NOTIFY: implement SubscriptionChange
+ - libssl-iostream read all of file input stream, no buffer limits in ssl
+ - finish dsync rewrite
+ - catenate: {1234} and {1234+} error handling is wrong for both
+
+ - doveadm: if running via doveadm-server and it fails, say something about
+ error being in the log
- indexer-worker and maybe others (doveadm?) could support dropping privileges
permanently when service_count=1. Note that LMTP can't with multiple RCPT
TOs.
@@ -6,12 +15,10 @@
- if indexpvt is enabled, mailbox_list_indexes should go there? at least
private flags are otherwise problematic.. possibly only for shared/public
mailboxes?..
- - catenate: {1234} and {1234+} error handling is wrong for both
- index_mail_parse_headers() etc. message_parsers don't check for stream errors
- FIFOs maybe should be counted as connections, but unlisten should
unlink+reopen it in master?
- - mailbox list indexes + imaptest test=tests fails
- - change proxy TTL so it stops at 1?
+ - change proxy TTL so it stops at 1? (instead of 0)
- lmtp client/proxy: Handle multiline replies better
- recreate mailbox -> existing sessions log "indexid changed" error
- add message/mime limits
diff -r 44013be2e3d8 -r 9c69df65af7b src/doveadm/dsync/dsync-mailbox-export.c
--- a/src/doveadm/dsync/dsync-mailbox-export.c Mon Aug 20 10:19:57 2012 +0300
+++ b/src/doveadm/dsync/dsync-mailbox-export.c Mon Aug 20 10:54:04 2012 +0300
@@ -382,7 +382,7 @@
void *key;
struct dsync_mail_change *change, *dup_change;
- dsync_transaction_log_scan_get_hash(log_scan, &log_changes);
+ log_changes = dsync_transaction_log_scan_get_hash(log_scan);
if (dsync_transaction_log_scan_has_all_changes(log_scan))
exporter->return_all_mails = TRUE;
diff -r 44013be2e3d8 -r 9c69df65af7b src/doveadm/dsync/dsync-mailbox-import.c
--- a/src/doveadm/dsync/dsync-mailbox-import.c Mon Aug 20 10:19:57 2012 +0300
+++ b/src/doveadm/dsync/dsync-mailbox-import.c Mon Aug 20 10:54:04 2012 +0300
@@ -166,7 +166,7 @@
importer->local_initial_highestmodseq = status.highest_modseq;
dsync_mailbox_import_search_init(importer);
- dsync_transaction_log_scan_get_hash(log_scan, &importer->local_changes);
+ importer->local_changes = dsync_transaction_log_scan_get_hash(log_scan);
return importer;
}
diff -r 44013be2e3d8 -r 9c69df65af7b src/doveadm/dsync/dsync-transaction-log-scan.c
--- a/src/doveadm/dsync/dsync-transaction-log-scan.c Mon Aug 20 10:19:57 2012 +0300
+++ b/src/doveadm/dsync/dsync-transaction-log-scan.c Mon Aug 20 10:54:04 2012 +0300
@@ -406,10 +406,10 @@
return 0;
}
-void dsync_transaction_log_scan_get_hash(struct dsync_transaction_log_scan *scan,
- HASH_TABLE_TYPE(dsync_uid_mail_change) *hash_r)
+HASH_TABLE_TYPE(dsync_uid_mail_change)
+dsync_transaction_log_scan_get_hash(struct dsync_transaction_log_scan *scan)
{
- hash_r->_table = scan->changes._table;
+ return scan->changes;
}
bool
diff -r 44013be2e3d8 -r 9c69df65af7b src/doveadm/dsync/dsync-transaction-log-scan.h
--- a/src/doveadm/dsync/dsync-transaction-log-scan.h Mon Aug 20 10:19:57 2012 +0300
+++ b/src/doveadm/dsync/dsync-transaction-log-scan.h Mon Aug 20 10:54:04 2012 +0300
@@ -11,8 +11,8 @@
uint32_t highest_wanted_uid,
uint64_t modseq,
struct dsync_transaction_log_scan **scan_r);
-void dsync_transaction_log_scan_get_hash(struct dsync_transaction_log_scan *scan,
- HASH_TABLE_TYPE(dsync_uid_mail_change) *hash_r);
+HASH_TABLE_TYPE(dsync_uid_mail_change)
+dsync_transaction_log_scan_get_hash(struct dsync_transaction_log_scan *scan);
/* Returns TRUE if the entire transaction log was scanned */
bool dsync_transaction_log_scan_has_all_changes(struct dsync_transaction_log_scan *scan);
/* If the given UID has been expunged after the initial log scan, create/update
diff -r 44013be2e3d8 -r 9c69df65af7b src/lib/hash-decl.h
--- a/src/lib/hash-decl.h Mon Aug 20 10:19:57 2012 +0300
+++ b/src/lib/hash-decl.h Mon Aug 20 10:54:04 2012 +0300
@@ -4,10 +4,7 @@
#define HASH_TABLE_UNION(key_type, value_type) { \
struct hash_table *_table; \
key_type _key; \
- key_type *_keyp; \
- const key_type _const_key; \
value_type _value; \
- value_type *_valuep; \
}
#define HASH_TABLE_DEFINE_TYPE(name, key_type, value_type) \
diff -r 44013be2e3d8 -r 9c69df65af7b src/lib/hash.h
--- a/src/lib/hash.h Mon Aug 20 10:19:57 2012 +0300
+++ b/src/lib/hash.h Mon Aug 20 10:54:04 2012 +0300
@@ -31,12 +31,13 @@
!__builtin_types_compatible_p(typeof(&key_cmp_cb), \
int (*)(typeof((*table)._key), typeof((*table)._key))) && \
!__builtin_types_compatible_p(typeof(&key_cmp_cb), \
- int (*)(typeof((*table)._const_key), typeof((*table)._const_key)))); \
+ int (*)(typeof(const typeof(*(*table)._key) *), \
+ typeof(const typeof(*(*table)._key) *)))); \
(void)COMPILE_ERROR_IF_TRUE( \
!__builtin_types_compatible_p(typeof(&hash_cb), \
unsigned int (*)(typeof((*table)._key))) && \
!__builtin_types_compatible_p(typeof(&hash_cb), \
- unsigned int (*)(typeof((*table)._const_key)))); \
+ unsigned int (*)(typeof(const typeof(*(*table)._key) *)))); \
hash_table_create(&(*table)._table, pool, size, \
(hash_callback_t *)hash_cb, \
(hash_cmp_callback_t *)key_cmp_cb);})
@@ -77,17 +78,17 @@
void *hash_table_lookup(const struct hash_table *table, const void *key) ATTR_PURE;
#define hash_table_lookup(table, key) \
HASH_VALUE_CAST(table)hash_table_lookup((table)._table, \
- (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._key, (table)._const_key, key)))
+ (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(*(table)._key, *key)))
bool hash_table_lookup_full(const struct hash_table *table,
const void *lookup_key,
void **orig_key_r, void **value_r);
#define hash_table_lookup_full(table, lookup_key, orig_key_r, value_r) \
hash_table_lookup_full((table)._table, \
- (void *)((const char *)(lookup_key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._const_key, (table)._key, lookup_key)), \
- (void **)(void *)((orig_key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._keyp, orig_key_r) + \
+ (void *)((const char *)(lookup_key) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(*(table)._key, *lookup_key)), \
+ (void **)(void *)((orig_key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._key, *orig_key_r) + \
COMPILE_ERROR_IF_TRUE(sizeof(*orig_key_r) != sizeof(void *))), \
- (void **)(void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._valuep, value_r) + \
+ (void **)(void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._value, *value_r) + \
COMPILE_ERROR_IF_TRUE(sizeof(*value_r) != sizeof(void *))))
/* Insert/update node in hash table. The difference is that hash_table_insert()
@@ -106,7 +107,7 @@
void hash_table_remove(struct hash_table *table, const void *key);
#define hash_table_remove(table, key) \
hash_table_remove((table)._table, \
- (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._const_key, (table)._key, key)))
+ (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(*(table)._key, *key)))
unsigned int hash_table_count(const struct hash_table *table) ATTR_PURE;
#define hash_table_count(table) \
hash_table_count((table)._table)
@@ -121,10 +122,10 @@
void **key_r, void **value_r);
#define hash_table_iterate(ctx, table, key_r, value_r) \
hash_table_iterate(ctx, \
- (void **)(void *)((key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._keyp, key_r) + \
+ (void **)(void *)((key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._key, *key_r) + \
COMPILE_ERROR_IF_TRUE(sizeof(*key_r) != sizeof(void *)) + \
COMPILE_ERROR_IF_TRUE(sizeof(*value_r) != sizeof(void *))), \
- (void **)(void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._valuep, value_r)))
+ (void **)(void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._value, *value_r)))
void hash_table_iterate_deinit(struct hash_iterate_context **ctx);
/* Hash table isn't resized, and removed nodes aren't removed from
More information about the dovecot-cvs
mailing list