dsync-worker-local.c revision 3fe67ec75ccae1230bb9eb9f16affc48377f6441
5a580c3a38ced62d4bcc95b8ac7c4f2935b5d294Timo Sirainen/* Copyright (c) 2009 Dovecot authors, see the included COPYING file */
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen struct mailbox_list_iterate_context *list_iter;
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen struct mailbox_list_iterate_context *list_iter;
79042f8c2ec1778528584c064b164d1ebcdde16bTimo Sirainen /* mailbox_guid_t -> struct local_dsync_mailbox* */
79042f8c2ec1778528584c064b164d1ebcdde16bTimo Sirainen /* mailbox_guid_t -> struct local_dsync_mailbox_change* */
79042f8c2ec1778528584c064b164d1ebcdde16bTimo Sirainen /* mailbox_guid_t -> struct local_dsync_subscription_change */
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen dsync_worker_finish_callback_t *finish_callback;
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainenextern struct dsync_worker_vfuncs local_dsync_worker;
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainenstatic void local_worker_mailbox_close(struct local_dsync_worker *worker);
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainenstatic void local_worker_msg_box_close(struct local_dsync_worker *worker);
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainenstatic int mailbox_guid_cmp(const void *p1, const void *p2)
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen return memcmp(g1->guid, g2->guid, sizeof(g1->guid));
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainenstatic unsigned int mailbox_guid_hash(const void *p)
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen unsigned int i, g, h = 0;
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen h = (h << 4) + s[i];
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen if ((g = h & 0xf0000000UL)) {
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen h = h ^ (g >> 24);
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainendsync_worker_init_local(struct mail_user *user, char alt_char)
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen pool = pool_alloconly_create("local dsync worker", 10240);
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen worker = p_new(pool, struct local_dsync_worker, 1);
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainenstatic void local_worker_deinit(struct dsync_worker *_worker)
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen hash_table_destroy(&worker->mailbox_changes_hash);
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen if (worker->subscription_changes_hash != NULL)
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen hash_table_destroy(&worker->subscription_changes_hash);
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainenstatic bool local_worker_is_output_full(struct dsync_worker *worker ATTR_UNUSED)
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainenstatic int local_worker_output_flush(struct dsync_worker *worker ATTR_UNUSED)
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainendsync_worker_save_mailbox_change(struct local_dsync_worker *worker,
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen change = hash_table_lookup(worker->mailbox_changes_hash,
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen change = i_new(struct local_dsync_mailbox_change, 1);
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen hash_table_insert(worker->mailbox_changes_hash,
2028d80c2704bbf62b29b2c624b0ee3c3a03c462Timo Sirainen stamp = mailbox_log_record_get_timestamp(rec);
i_unreached();
&new_change);
i_unreached();
static unsigned int mailbox_log_record_hash(const void *p)
static unsigned int subscription_change_hash(const void *p)
int ret = 0;
return ret;
static struct dsync_worker_mailbox_iter *
const char *storage_name,
const char *storage_name;
const char *const *fields;
unsigned int i, field_count;
for (i = 0; i < field_count; i++) {
return ret;
static struct dsync_worker_subs_iter *
const char *storage_name;
return ret;
const char *storage_name;
NULL);
static struct dsync_worker_msg_iter *
unsigned int mailbox_count)
for (i = 0; i < mailbox_count; i++) {
unsigned int count;
return FALSE;
return TRUE;
return FALSE;
T_BEGIN {
} T_END;
unsigned int *mailbox_idx_r,
const char *guid;
return ret;
char *dest_name, *p;
else if (*p == src_sep)
*p = dest_sep;
return dest_name;
char *output, *p;
*p = alt_char;
return output;
char *output, *p;
if (!i_isalnum(*p))
*p = alt_char;
return output;
bool creating)
if (creating) {
return name;
static struct mailbox *
const char *name;
NULL, 0);
return NULL;
int ret;
if (ret < 0) {
NULL));
const char *oldprefix;
unsigned int oldprefix_len;
unsigned int i, n, expected_count;
return FALSE;
return i == expected_count;
if (selected)
NULL));
if (selected)
unsigned int count;
int ret;
int ret;
if (ret == 0) {
if (ret < 0)
worker);