mail-index-transaction-private.h revision a022088674a5ae72ed29ae001834cbad62a4f19f
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen#ifndef __MAIL_INDEX_TRANSACTION_PRIVATE_H
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen#define __MAIL_INDEX_TRANSACTION_PRIVATE_H
c0a708fa3f7b8f4fbca32052da5faf7a0125189dTimo Sirainen
c0a708fa3f7b8f4fbca32052da5faf7a0125189dTimo Sirainen#include "seq-range-array.h"
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen#include "mail-transaction-log.h"
c49a19168dab6fda80aee16ad799a8a56d3bc18fTimo Sirainen
c0a708fa3f7b8f4fbca32052da5faf7a0125189dTimo Sirainenstruct mail_index_transaction_keyword_update {
cd94aeaa294f7cc507206b4b2075852f00e14d61Timo Sirainen ARRAY_TYPE(seq_range) add_seq;
cd94aeaa294f7cc507206b4b2075852f00e14d61Timo Sirainen ARRAY_TYPE(seq_range) remove_seq;
cd94aeaa294f7cc507206b4b2075852f00e14d61Timo Sirainen};
cd94aeaa294f7cc507206b4b2075852f00e14d61Timo Sirainen
cd94aeaa294f7cc507206b4b2075852f00e14d61Timo Sirainenstruct mail_index_transaction_ext_hdr_update {
cd94aeaa294f7cc507206b4b2075852f00e14d61Timo Sirainen uint32_t ext_id;
cd94aeaa294f7cc507206b4b2075852f00e14d61Timo Sirainen uint16_t offset;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen uint16_t size;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen /* unsigned char data[]; */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen};
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenstruct mail_index_transaction_vfuncs {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen int (*commit)(struct mail_index_transaction *t,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen uint32_t *log_file_seq_r, uoff_t *log_file_offset_r);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen void (*rollback)(struct mail_index_transaction *t);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen};
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenunion mail_index_transaction_module_context {
cd94aeaa294f7cc507206b4b2075852f00e14d61Timo Sirainen struct mail_index_module_register *reg;
00fa8dcbc66f56daa737487c9dec7166c37de79eTimo Sirainen};
00fa8dcbc66f56daa737487c9dec7166c37de79eTimo Sirainen
00fa8dcbc66f56daa737487c9dec7166c37de79eTimo Sirainenstruct mail_index_transaction {
00fa8dcbc66f56daa737487c9dec7166c37de79eTimo Sirainen int refcount;
00fa8dcbc66f56daa737487c9dec7166c37de79eTimo Sirainen
00fa8dcbc66f56daa737487c9dec7166c37de79eTimo Sirainen enum mail_index_transaction_flags flags;
00fa8dcbc66f56daa737487c9dec7166c37de79eTimo Sirainen struct mail_index_transaction_vfuncs v;
00fa8dcbc66f56daa737487c9dec7166c37de79eTimo Sirainen struct mail_index_view *view;
00fa8dcbc66f56daa737487c9dec7166c37de79eTimo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen /* NOTE: If you add anything new, remember to update
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen mail_index_transaction_reset() to reset it. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen ARRAY_DEFINE(appends, struct mail_index_record);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen uint32_t first_new_seq, last_new_seq;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen ARRAY_TYPE(seq_range) expunges;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen ARRAY_DEFINE(updates, struct mail_transaction_flag_update);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen size_t last_update_idx;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
2598b2f36365b52d9754b9348a5be29569293e46Timo Sirainen unsigned char pre_hdr_change[sizeof(struct mail_index_header)];
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen unsigned char pre_hdr_mask[sizeof(struct mail_index_header)];
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen unsigned char post_hdr_change[sizeof(struct mail_index_header)];
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen unsigned char post_hdr_mask[sizeof(struct mail_index_header)];
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen ARRAY_DEFINE(ext_hdr_updates,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen struct mail_index_transaction_ext_hdr_update *);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen ARRAY_DEFINE(ext_rec_updates, ARRAY_TYPE(seq_array));
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen ARRAY_DEFINE(ext_resizes, struct mail_transaction_ext_intro);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen ARRAY_DEFINE(ext_resets, uint32_t);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen ARRAY_DEFINE(ext_reset_ids, uint32_t);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen ARRAY_DEFINE(keyword_updates,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen struct mail_index_transaction_keyword_update);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen ARRAY_TYPE(seq_range) keyword_resets;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen struct mail_cache_transaction_ctx *cache_trans_ctx;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen /* Module-specific contexts. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen ARRAY_DEFINE(module_contexts,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen union mail_index_transaction_module_context *);
4c6ddf2491104f917d00e6900e833e80ea02c7b6Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen /* this transaction was created for index_sync_view view */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen unsigned int sync_transaction:1;
00fa8dcbc66f56daa737487c9dec7166c37de79eTimo Sirainen unsigned int no_appends:1;
00fa8dcbc66f56daa737487c9dec7166c37de79eTimo Sirainen
c0a708fa3f7b8f4fbca32052da5faf7a0125189dTimo Sirainen unsigned int appends_nonsorted:1;
ad004e44be109684521494b5af2ad1da39b8bb27Timo Sirainen unsigned int pre_hdr_changed:1;
97db4761382024093f441e4bc78ba8b6a056504dTimo Sirainen unsigned int post_hdr_changed:1;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen unsigned int reset:1;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen /* non-extension updates. flag updates don't change this because
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen they may be added and removed, so be sure to check that the updates
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen array is non-empty also. */
ad004e44be109684521494b5af2ad1da39b8bb27Timo Sirainen unsigned int log_updates:1;
64e244defe74f513ce94f33d000a048ddbe2ea23Timo Sirainen /* extension updates */
c0a708fa3f7b8f4fbca32052da5faf7a0125189dTimo Sirainen unsigned int log_ext_updates:1;
12cf3d0e03fc70fb0c8b91bc8fd83b4e14d7cdefTimo Sirainen};
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
97db4761382024093f441e4bc78ba8b6a056504dTimo Sirainenextern void (*hook_mail_index_transaction_created)
bf72c930996df0691932fb1143f360d260f27a06Timo Sirainen (struct mail_index_transaction *t);
c0a708fa3f7b8f4fbca32052da5faf7a0125189dTimo Sirainen
cd94aeaa294f7cc507206b4b2075852f00e14d61Timo Sirainenstruct mail_index_record *
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenmail_index_transaction_lookup(struct mail_index_transaction *t, uint32_t seq);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_transaction_ref(struct mail_index_transaction *t);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_index_transaction_unref(struct mail_index_transaction **t);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
bbba7d0fce1b6ce5baa2d7ef946eb1b63e2ab518Timo Sirainenvoid mail_index_transaction_sort_appends(struct mail_index_transaction *t);
bbba7d0fce1b6ce5baa2d7ef946eb1b63e2ab518Timo Sirainenuint32_t mail_index_transaction_get_next_uid(struct mail_index_transaction *t);
c0a708fa3f7b8f4fbca32052da5faf7a0125189dTimo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenbool mail_index_seq_array_lookup(const ARRAY_TYPE(seq_array) *array,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen uint32_t seq, unsigned int *idx_r);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
c49a19168dab6fda80aee16ad799a8a56d3bc18fTimo Sirainen#endif
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen