~ubuntu-dev/ubuntu/lucid/dovecot/lucid-201002101901

« back to all changes in this revision

Viewing changes to src/plugins/quota/quota.c

  • Committer: Bazaar Package Importer
  • Author(s): Marco Nenciarini
  • Date: 2009-12-17 10:52:53 UTC
  • mfrom: (1.13.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 61.
  • Revision ID: james.westby@ubuntu.com-20091217105253-guybg5b34vmits39
* New upstream release.
* debian/patches/gold-fix.patch: Removed. Fixed upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
262
262
 
263
263
static void
264
264
quota_rule_recalculate_relative_rules(struct quota_rule *rule,
265
 
                                      const struct quota_rule *default_rule)
 
265
                                      int64_t bytes_limit, int64_t count_limit)
266
266
{
267
 
        if (rule->bytes_percent > 0) {
268
 
                rule->bytes_limit = default_rule->bytes_limit *
269
 
                        rule->bytes_percent / 100;
270
 
        }
271
 
        if (rule->count_percent > 0) {
272
 
                rule->count_limit = default_rule->count_limit *
273
 
                        rule->count_percent / 100;
274
 
        }
 
267
        if (rule->bytes_percent > 0)
 
268
                rule->bytes_limit = bytes_limit * rule->bytes_percent / 100;
 
269
        if (rule->count_percent > 0)
 
270
                rule->count_limit = count_limit * rule->count_percent / 100;
275
271
}
276
272
 
277
 
void quota_root_recalculate_relative_rules(struct quota_root_settings *root_set)
 
273
void quota_root_recalculate_relative_rules(struct quota_root_settings *root_set,
 
274
                                           int64_t bytes_limit,
 
275
                                           int64_t count_limit)
278
276
{
279
277
        struct quota_rule *rules;
280
278
        struct quota_warning_rule *warning_rules;
282
280
 
283
281
        rules = array_get_modifiable(&root_set->rules, &count);
284
282
        for (i = 0; i < count; i++) {
285
 
                quota_rule_recalculate_relative_rules(&rules[i],
286
 
                                                      &root_set->default_rule);
 
283
                quota_rule_recalculate_relative_rules(&rules[i], bytes_limit,
 
284
                                                      count_limit);
287
285
        }
288
286
 
289
287
        warning_rules = array_get_modifiable(&root_set->warning_rules, &count);
290
288
        for (i = 0; i < count; i++) {
291
289
                quota_rule_recalculate_relative_rules(&warning_rules[i].rule,
292
 
                                                      &root_set->default_rule);
 
290
                                                      bytes_limit, count_limit);
293
291
        }
294
292
}
295
293
 
419
417
                        ret = -1;
420
418
        }
421
419
 
422
 
        quota_root_recalculate_relative_rules(root_set);
 
420
        quota_root_recalculate_relative_rules(root_set,
 
421
                                              root_set->default_rule.bytes_limit,
 
422
                                              root_set->default_rule.count_limit);
423
423
        if (root_set->set->debug) {
424
424
                i_info("Quota rule: root=%s mailbox=%s "
425
425
                       "bytes=%lld%s messages=%lld%s", root_set->name,
580
580
        warning->command = i_strdup(p+1);
581
581
        warning->rule = rule;
582
582
 
583
 
        quota_root_recalculate_relative_rules(root_set);
 
583
        quota_root_recalculate_relative_rules(root_set,
 
584
                                              root_set->default_rule.bytes_limit,
 
585
                                              root_set->default_rule.count_limit);
584
586
        if (root_set->set->debug) {
585
587
                i_info("Quota warning: bytes=%llu%s "
586
588
                       "messages=%llu%s command=%s",