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

« back to all changes in this revision

Viewing changes to src/lib-storage/index/istream-mail-stats.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) 2009-2011 Dovecot authors, see the included COPYING file */
2
 
 
3
 
#include "lib.h"
4
 
#include "mail-storage-private.h"
5
 
#include "istream-internal.h"
6
 
#include "istream-mail-stats.h"
7
 
 
8
 
struct mail_stats_istream {
9
 
        struct istream_private istream;
10
 
 
11
 
        struct mail_private *mail;
12
 
        unsigned int files_read_increased:1;
13
 
};
14
 
 
15
 
static ssize_t
16
 
i_stream_mail_stats_read_mail_stats(struct istream_private *stream)
17
 
{
18
 
        struct mail_stats_istream *mstream =
19
 
                (struct mail_stats_istream *)stream;
20
 
        ssize_t ret;
21
 
 
22
 
        i_stream_seek(stream->parent, stream->parent_start_offset +
23
 
                      stream->istream.v_offset);
24
 
 
25
 
        ret = i_stream_read_copy_from_parent(&stream->istream);
26
 
        if (ret > 0) {
27
 
                mstream->mail->stats_files_read_bytes += ret;
28
 
                if (!mstream->files_read_increased) {
29
 
                        mstream->files_read_increased = TRUE;
30
 
                        mstream->mail->stats_files_read_count++;
31
 
                }
32
 
        }
33
 
        return ret;
34
 
}
35
 
 
36
 
static void
37
 
i_stream_mail_stats_seek(struct istream_private *stream,
38
 
                         uoff_t v_offset, bool mark ATTR_UNUSED)
39
 
{
40
 
        stream->istream.v_offset = v_offset;
41
 
        stream->skip = stream->pos = 0;
42
 
}
43
 
 
44
 
static const struct stat *
45
 
i_stream_mail_stats_stat(struct istream_private *stream, bool exact)
46
 
{
47
 
        return i_stream_stat(stream->parent, exact);
48
 
}
49
 
 
50
 
struct istream *i_stream_create_mail_stats_counter(struct mail_private *mail,
51
 
                                                   struct istream *input)
52
 
{
53
 
        struct mail_stats_istream *mstream;
54
 
 
55
 
        mstream = i_new(struct mail_stats_istream, 1);
56
 
        mstream->mail = mail;
57
 
        mstream->istream.max_buffer_size = input->real_stream->max_buffer_size;
58
 
 
59
 
        mstream->istream.parent = input;
60
 
        mstream->istream.read = i_stream_mail_stats_read_mail_stats;
61
 
        mstream->istream.seek = i_stream_mail_stats_seek;
62
 
        mstream->istream.stat = i_stream_mail_stats_stat;
63
 
 
64
 
        mstream->istream.istream.blocking = input->blocking;
65
 
        mstream->istream.istream.seekable = input->seekable;
66
 
        return i_stream_create(&mstream->istream, input,
67
 
                               i_stream_get_fd(input));
68
 
}