~sbeattie/ubuntu/oneiric/dovecot/dovecot-lp792557

« back to all changes in this revision

Viewing changes to src/lib/ioloop-select.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-05-16 10:18:41 UTC
  • mfrom: (4.1.20 sid)
  • Revision ID: james.westby@ubuntu.com-20110516101841-wo4hf1ewxssic6xj
Tags: 1:2.0.12-1ubuntu1
* Merge from Debian Unstable, remaining changes are:
  + Add mail-stack-delivery as per server-maverick-mail-integration spec:
    - Update debian/rules
    - Convert existing package to a dummy package and new binary in debian/control.
    - Update maintainer scripts.
    - Move previously installed backups and config files to a new package namespace in preinst.
    - Add new debian/mail-stack-delivery.prerm to handle downgrades.
    - Rename debian/dovecot-postfix.* to debian/mail-stack-delivery.*
  + Use Snakeoil SSL certifications by default:
    - debian/control: Depend on ssl-cert.
    - debian/dovecot-common.postinst: Relax grep for SSL_* a bit.
  + Add autopkgtest to debian/tests/*.
  + Add ufw integration:
    - Create debian/dovecot-common.ufw.profile.
    - debian/rules: install profile
    - debian/control: suggest ufw.
  + debian/{control,rules}: enable PIE hardening.
  + debian/dovecot-common.dirs: Added usr/share/doc/dovecot-common
  + Add apport hook:
    - debian/rules, debian/source_dovecot.py
  + Add upstart job:
    - debian/rules, debian/dovecot-common.dovecot.upstart, debian/control,
      debian/dovecot-common.dirs, dovecot-imapd.{postrm, postinst, prerm},
      debian/dovecot-pop3d.{postinst, postrm, prerm}. mail-stack-deliver.postinst:
      Convert init script to upstart. Apart of the server-maverick-upstart-conversion
      specification.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2002-2011 Dovecot authors, see the included COPYING file */
2
2
 
3
3
#include "lib.h"
4
4
#include "ioloop-internal.h"
65
65
        if (fd >= FD_SETSIZE)
66
66
                i_fatal("fd %d too large for select()", fd);
67
67
 
68
 
        if (condition & IO_READ)
 
68
        if ((condition & (IO_READ | IO_ERROR)) != 0)
69
69
                FD_SET(fd, &ctx->read_fds);
70
 
        if (condition & IO_WRITE)
 
70
        if ((condition & IO_WRITE) != 0)
71
71
                FD_SET(fd, &ctx->write_fds);
72
72
        FD_SET(fd, &ctx->except_fds);
73
73
 
83
83
 
84
84
        i_assert(fd >= 0 && fd < FD_SETSIZE);
85
85
 
86
 
        if (condition & IO_READ)
 
86
        if ((condition & (IO_READ | IO_ERROR)) != 0)
87
87
                FD_CLR(fd, &ctx->read_fds);
88
 
        if (condition & IO_WRITE)
 
88
        if ((condition & IO_WRITE) != 0)
89
89
                FD_CLR(fd, &ctx->write_fds);
90
90
 
91
91
        if (!FD_ISSET(fd, &ctx->read_fds) && !FD_ISSET(fd, &ctx->write_fds)) {
99
99
}
100
100
 
101
101
#define io_check_condition(ctx, fd, cond) \
102
 
        ((FD_ISSET((fd), &(ctx)->tmp_read_fds) && ((cond) & IO_READ)) || \
 
102
        ((FD_ISSET((fd), &(ctx)->tmp_read_fds) && ((cond) & (IO_READ|IO_ERROR))) || \
103
103
         (FD_ISSET((fd), &(ctx)->tmp_write_fds) && ((cond) & IO_WRITE)) || \
104
104
         (FD_ISSET((fd), &(ctx)->tmp_except_fds)))
105
105
 
108
108
        struct ioloop_handler_context *ctx = ioloop->handler_context;
109
109
        struct timeval tv;
110
110
        struct io_file *io;
111
 
        unsigned int t_id;
112
111
        int ret;
113
112
 
114
113
        /* get the time left for next timeout task */
115
 
        io_loop_get_wait_time(ioloop, &tv, NULL);
 
114
        io_loop_get_wait_time(ioloop, &tv);
116
115
 
117
116
        memcpy(&ctx->tmp_read_fds, &ctx->read_fds, sizeof(fd_set));
118
117
        memcpy(&ctx->tmp_write_fds, &ctx->write_fds, sizeof(fd_set));
137
136
 
138
137
                if (io_check_condition(ctx, io->fd, io->io.condition)) {
139
138
                        ret--;
140
 
 
141
 
                        t_id = t_push();
142
 
                        io->io.callback(io->io.context);
143
 
                        if (t_pop() != t_id) {
144
 
                                i_panic("Leaked a t_pop() call in "
145
 
                                        "I/O handler %p",
146
 
                                        (void *)io->io.callback);
147
 
                        }
 
139
                        io_loop_call_io(&io->io);
148
140
                }
149
141
        }
150
142
}