annotate src/anvil/penalty.h @ 22715:20415dd0b85a

dsync: Add per-mailbox sync lock that is always used. Both importing and exporting gets the lock before they even sync the mailbox. The lock is kept until the import/export finishes. This guarantees that no matter how dsync is run, two dsyncs can't be working on the same mailbox at the same time. This lock is in addition to the optional per-user lock enabled by the -l parameter. If the -l parameter is used, the same lock timeout is used for the per-mailbox lock. Otherwise 30s timeout is used. This should help to avoid email duplication when replication is enabled for public namespaces, and maybe in some other rare situations as well.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 28 Dec 2017 14:10:23 +0200
parents 1282d027ce67
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10298
ea209b33ef96 anvil: Added support for penalty tracking.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
1 #ifndef PENALTY_H
ea209b33ef96 anvil: Added support for penalty tracking.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2 #define PENALTY_H
ea209b33ef96 anvil: Added support for penalty tracking.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3
10773
4cdb58bb0360 auth/anvil: Penalty is no longer increased if the same user+pass combination was recently used.
Timo Sirainen <tss@iki.fi>
parents: 10298
diff changeset
4 #define PENALTY_MAX_VALUE ((1 << 16)-1)
4cdb58bb0360 auth/anvil: Penalty is no longer increased if the same user+pass combination was recently used.
Timo Sirainen <tss@iki.fi>
parents: 10298
diff changeset
5
10298
ea209b33ef96 anvil: Added support for penalty tracking.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6 struct penalty *penalty_init(void);
ea209b33ef96 anvil: Added support for penalty tracking.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 void penalty_deinit(struct penalty **penalty);
ea209b33ef96 anvil: Added support for penalty tracking.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8
ea209b33ef96 anvil: Added support for penalty tracking.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9 void penalty_set_expire_secs(struct penalty *penalty, unsigned int expire_secs);
ea209b33ef96 anvil: Added support for penalty tracking.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10
ea209b33ef96 anvil: Added support for penalty tracking.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11 unsigned int penalty_get(struct penalty *penalty, const char *ident,
10773
4cdb58bb0360 auth/anvil: Penalty is no longer increased if the same user+pass combination was recently used.
Timo Sirainen <tss@iki.fi>
parents: 10298
diff changeset
12 time_t *last_penalty_r);
4cdb58bb0360 auth/anvil: Penalty is no longer increased if the same user+pass combination was recently used.
Timo Sirainen <tss@iki.fi>
parents: 10298
diff changeset
13 /* if checksum is non-zero and it already exists for ident, the value
4cdb58bb0360 auth/anvil: Penalty is no longer increased if the same user+pass combination was recently used.
Timo Sirainen <tss@iki.fi>
parents: 10298
diff changeset
14 is set to "value-1", otherwise it's set to "value". */
4cdb58bb0360 auth/anvil: Penalty is no longer increased if the same user+pass combination was recently used.
Timo Sirainen <tss@iki.fi>
parents: 10298
diff changeset
15 void penalty_inc(struct penalty *penalty, const char *ident,
4cdb58bb0360 auth/anvil: Penalty is no longer increased if the same user+pass combination was recently used.
Timo Sirainen <tss@iki.fi>
parents: 10298
diff changeset
16 unsigned int checksum, unsigned int value);
4cdb58bb0360 auth/anvil: Penalty is no longer increased if the same user+pass combination was recently used.
Timo Sirainen <tss@iki.fi>
parents: 10298
diff changeset
17
4cdb58bb0360 auth/anvil: Penalty is no longer increased if the same user+pass combination was recently used.
Timo Sirainen <tss@iki.fi>
parents: 10298
diff changeset
18 bool penalty_has_checksum(struct penalty *penalty, const char *ident,
4cdb58bb0360 auth/anvil: Penalty is no longer increased if the same user+pass combination was recently used.
Timo Sirainen <tss@iki.fi>
parents: 10298
diff changeset
19 unsigned int checksum);
10779
1282d027ce67 anvil: Added PENALTY-DUMP command to dump penalty state.
Timo Sirainen <tss@iki.fi>
parents: 10773
diff changeset
20 void penalty_dump(struct penalty *penalty, struct ostream *output);
10298
ea209b33ef96 anvil: Added support for penalty tracking.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
21
ea209b33ef96 anvil: Added support for penalty tracking.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
22 #endif