~ubuntu-branches/ubuntu/trusty/dovecot/trusty-updates

« back to all changes in this revision

Viewing changes to src/log/log-connection.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-08 09:35:49 UTC
  • mfrom: (1.15.3) (96.1.1 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20140108093549-814nkqdcxfbvgktg
Tags: 1:2.2.9-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/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.
  + Use the autotools-dev dh addon to update config.guess/config.sub for
    arm64.
* Dropped changes, included in Debian:
  - Update Dovecot name to reflect distribution in login greeting.
  - Update Drac plugin for >= 2.0.0 support.
* d/control: Drop dovecot-postfix package as its no longer required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2005-2013 Dovecot authors, see the included COPYING file */
2
2
 
3
3
#include "lib.h"
4
4
#include "array.h"
33
33
        struct istream *input;
34
34
 
35
35
        char *default_prefix;
36
 
        /* pid -> struct log_client* */
37
 
        struct hash_table *clients;
 
36
        HASH_TABLE(void *, struct log_client *) clients;
38
37
 
39
38
        unsigned int master:1;
40
39
        unsigned int handshaked:1;
41
40
};
42
41
 
43
42
static struct log_connection *log_connections = NULL;
44
 
static ARRAY_DEFINE(logs_by_fd, struct log_connection *);
 
43
static ARRAY(struct log_connection *) logs_by_fd;
 
44
 
 
45
static void log_connection_destroy(struct log_connection *log);
45
46
 
46
47
static struct log_client *log_client_get(struct log_connection *log, pid_t pid)
47
48
{
103
104
                log_error_buffer_add(log->errorbuf, &err);
104
105
                break;
105
106
        }
106
 
        i_set_failure_prefix(prefix);
 
107
        i_set_failure_prefix("%s", prefix);
107
108
        i_log_type(ctx, "%s", text);
108
109
        i_set_failure_prefix("log: ");
109
110
}
139
140
        const char *p, *p2, *cmd;
140
141
        unsigned int count;
141
142
        int service_fd;
142
 
        long pid;
 
143
        pid_t pid;
143
144
 
144
145
        p = strchr(line, ' ');
145
146
        if (p == NULL || (p2 = strchr(++p, ' ')) == NULL) {
203
204
        switch (failure.log_type) {
204
205
        case LOG_TYPE_FATAL:
205
206
        case LOG_TYPE_PANIC:
206
 
                client = log_client_get(log, failure.pid);
207
 
                client->fatal_logged = TRUE;
 
207
                if (failure.pid != 0) {
 
208
                        client = log_client_get(log, failure.pid);
 
209
                        client->fatal_logged = TRUE;
 
210
                }
208
211
                break;
209
212
        case LOG_TYPE_OPTION:
210
213
                log_parse_option(log, &failure);
211
214
                return;
212
215
        default:
213
 
                client = hash_table_lookup(log->clients,
214
 
                                           POINTER_CAST(failure.pid));
 
216
                client = failure.pid == 0 ? NULL :
 
217
                        hash_table_lookup(log->clients,
 
218
                                          POINTER_CAST(failure.pid));
215
219
                break;
216
220
        }
217
221
        i_assert(failure.log_type < LOG_TYPE_COUNT);
304
308
        }
305
309
}
306
310
 
307
 
struct log_connection *
308
 
log_connection_create(struct log_error_buffer *errorbuf, int fd, int listen_fd)
 
311
void log_connection_create(struct log_error_buffer *errorbuf,
 
312
                           int fd, int listen_fd)
309
313
{
310
314
        struct log_connection *log;
311
315
 
315
319
        log->listen_fd = listen_fd;
316
320
        log->io = io_add(fd, IO_READ, log_connection_input, log);
317
321
        log->input = i_stream_create_fd(fd, PIPE_BUF, FALSE);
318
 
        log->clients = hash_table_create(default_pool, default_pool, 0,
319
 
                                         NULL, NULL);
 
322
        hash_table_create_direct(&log->clients, default_pool, 0);
320
323
        array_idx_set(&logs_by_fd, listen_fd, &log);
321
324
 
322
325
        DLLIST_PREPEND(&log_connections, log);
323
326
        log_connection_input(log);
324
 
        return log;
325
327
}
326
328
 
327
 
void log_connection_destroy(struct log_connection *log)
 
329
static void log_connection_destroy(struct log_connection *log)
328
330
{
329
331
        struct hash_iterate_context *iter;
330
 
        void *key, *value;
 
332
        void *key;
 
333
        struct log_client *client;
331
334
 
332
335
        array_idx_clear(&logs_by_fd, log->listen_fd);
333
336
 
334
337
        DLLIST_REMOVE(&log_connections, log);
335
338
 
336
339
        iter = hash_table_iterate_init(log->clients);
337
 
        while (hash_table_iterate(iter, &key, &value))
338
 
                i_free(value);
 
340
        while (hash_table_iterate(iter, log->clients, &key, &client))
 
341
                i_free(client);
339
342
        hash_table_iterate_deinit(&iter);
340
343
        hash_table_destroy(&log->clients);
341
344