~james-page/ubuntu/raring/dovecot/autopkgtest

« back to all changes in this revision

Viewing changes to src/lib-index/mail-cache-fields.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-06-11 11:11:54 UTC
  • mfrom: (1.15.2) (4.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120611111154-678cwbdj6ktgsv1h
Tags: 1:2.1.7-1ubuntu1
* Merge from Debian unstable, remaining changes:
  + Add mail-stack-delivery package:
    - Update d/rules
    - d/control: convert existing dovecot-postfix package to a dummy
      package and add new mail-stack-delivery package.
    - Update maintainer scripts.
    - Rename d/dovecot-postfix.* to debian/mail-stack-delivery.*
    - d/mail-stack-delivery.preinst: Move previously installed backups and
      config files to a new package namespace.
    - d/mail-stack-delivery.prerm: Added to handle downgrades.
  + Use Snakeoil SSL certificates by default:
    - d/control: Depend on ssl-cert.
    - d/dovecot-core.postinst: Relax grep for SSL_* a bit.
  + Add autopkgtest to debian/tests/*.
  + Add ufw integration:
    - d/dovecot-core.ufw.profile: new ufw profile.
    - d/rules: install profile in dovecot-core.
    - d/control: dovecot-core - suggest ufw.
  + d/{control,rules}: enable PIE hardening.
  + d/dovecot-core.dirs: Added usr/share/doc/dovecot-core
  + Add apport hook:
    - d/rules, d/source_dovecot.py
  + Add upstart job:
    - d/rules, d/dovecot-core.dovecot.upstart, d/control,
      d/dovecot-core.dirs, dovecot-imapd.{postrm, postinst, prerm},
      d/dovecot-pop3d.{postinst, postrm, prerm}.
      d/mail-stack-deliver.postinst: Convert init script to upstart.
  + d/control: Added Pre-Depends: dpkg (>= 1.15.6) to dovecot-dbg to support
    xz compression in Ubuntu.
  + d/control: Demote dovecot-common Recommends: to Suggests: to prevent
    install of extra packages on upgrade.
  + d/patches/dovecot-drac.patch: Updated with version for dovecot >= 2.0.0.
  + d/control: Drop B-D on systemd.
* Dropped changes:
  + d/patches/fix-racey-restart.patch: part of 2.1.x, no longer required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2004-2011 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2004-2012 Dovecot authors, see the included COPYING file */
2
2
 
3
3
#include "lib.h"
4
4
#include "ioloop.h"
65
65
        return 0;
66
66
}
67
67
 
 
68
static void
 
69
mail_cache_field_update(struct mail_cache *cache,
 
70
                        const struct mail_cache_field *newfield)
 
71
{
 
72
        struct mail_cache_field_private *orig;
 
73
 
 
74
        i_assert(newfield->type < MAIL_CACHE_FIELD_COUNT);
 
75
 
 
76
        orig = &cache->fields[newfield->idx];
 
77
        if (newfield->decision != MAIL_CACHE_DECISION_NO &&
 
78
            orig->field.decision != newfield->decision) {
 
79
                orig->field.decision = newfield->decision;
 
80
                orig->decision_dirty = TRUE;
 
81
        }
 
82
        if (orig->field.last_used < newfield->last_used) {
 
83
                orig->field.last_used = newfield->last_used;
 
84
                orig->decision_dirty = TRUE;
 
85
        }
 
86
        if (orig->decision_dirty)
 
87
                cache->field_header_write_pending = TRUE;
 
88
 
 
89
        (void)field_type_verify(cache, newfield->idx,
 
90
                                newfield->type, newfield->field_size);
 
91
}
 
92
 
68
93
void mail_cache_register_fields(struct mail_cache *cache,
69
94
                                struct mail_cache_field *fields,
70
95
                                unsigned int fields_count)
71
96
{
72
 
        struct mail_cache_field *orig_field;
73
97
        void *orig_key, *orig_value;
74
98
        char *name;
75
99
        unsigned int new_idx;
80
104
                if (hash_table_lookup_full(cache->field_name_hash,
81
105
                                           fields[i].name,
82
106
                                           &orig_key, &orig_value)) {
83
 
                        i_assert(fields[i].type < MAIL_CACHE_FIELD_COUNT);
84
 
 
85
107
                        fields[i].idx =
86
108
                                POINTER_CAST_TO(orig_value, unsigned int);
87
 
 
88
 
                        orig_field = &cache->fields[fields[i].idx].field;
89
 
                        if (orig_field->decision == MAIL_CACHE_DECISION_NO)
90
 
                                orig_field->decision = fields[i].decision;
91
 
 
92
 
                        (void)field_type_verify(cache, fields[i].idx,
93
 
                                                fields[i].type,
94
 
                                                fields[i].field_size);
 
109
                        mail_cache_field_update(cache, &fields[i]);
95
110
                        continue;
96
111
                }
97
112
 
130
145
                name = p_strdup(cache->field_pool, fields[i].name);
131
146
                cache->fields[idx].field = fields[i];
132
147
                cache->fields[idx].field.name = name;
 
148
                cache->fields[idx].field.last_used = fields[i].last_used;
133
149
                cache->field_file_map[idx] = (uint32_t)-1;
134
150
 
135
151
                if (!field_has_fixed_size(cache->fields[idx].field.type))
387
403
                cache->file_field_map[i] = fidx;
388
404
 
389
405
                /* update last_used if it's newer than ours */
390
 
                if (last_used[i] > cache->fields[fidx].last_used)
391
 
                        cache->fields[fidx].last_used = last_used[i];
 
406
                if ((time_t)last_used[i] > cache->fields[fidx].field.last_used)
 
407
                        cache->fields[fidx].field.last_used = last_used[i];
392
408
 
393
409
                dec = cache->fields[fidx].field.decision;
394
 
                if ((time_t)cache->fields[fidx].last_used < max_drop_time &&
395
 
                    cache->fields[fidx].last_used != 0 &&
 
410
                if (cache->fields[fidx].field.last_used < max_drop_time &&
 
411
                    cache->fields[fidx].field.last_used != 0 &&
396
412
                    (dec & MAIL_CACHE_DECISION_FORCED) == 0 &&
397
413
                    dec != MAIL_CACHE_DECISION_NO) {
398
414
                        /* time to drop this field. don't bother dropping
469
485
        buffer = buffer_create_dynamic(pool_datastack_create(), 256);
470
486
 
471
487
        copy_to_buf(cache, buffer, FALSE,
472
 
                    offsetof(struct mail_cache_field_private, last_used),
 
488
                    offsetof(struct mail_cache_field, last_used),
473
489
                    sizeof(uint32_t));
474
490
        ret = mail_cache_write(cache, buffer->data, buffer->used,
475
491
                               offset + MAIL_CACHE_FIELD_LAST_USED());
532
548
 
533
549
        /* we have to keep the field order for the existing fields. */
534
550
        copy_to_buf(cache, dest, TRUE,
535
 
                    offsetof(struct mail_cache_field_private, last_used),
 
551
                    offsetof(struct mail_cache_field, last_used),
536
552
                    sizeof(uint32_t));
537
553
        copy_to_buf(cache, dest, TRUE,
538
554
                    offsetof(struct mail_cache_field, field_size),