~ubuntu-branches/ubuntu/wily/dovecot/wily

« back to all changes in this revision

Viewing changes to src/plugins/stats/stats-connection.c

  • Committer: Package Import Robot
  • Author(s): Jaldhar H. Vyas
  • Date: 2013-09-09 00:57:32 UTC
  • mfrom: (1.13.11)
  • mto: (4.8.5 experimental) (1.16.1)
  • mto: This revision was merged to the branch mainline in revision 97.
  • Revision ID: package-import@ubuntu.com-20130909005732-dn1eell8srqbhh0e
Tags: upstream-2.2.5
ImportĀ upstreamĀ versionĀ 2.2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2011-2012 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2011-2013 Dovecot authors, see the included COPYING file */
2
2
 
3
3
#include "lib.h"
4
4
#include "hostpid.h"
5
 
#include "network.h"
 
5
#include "net.h"
6
6
#include "str.h"
7
7
#include "strescape.h"
 
8
#include "master-service.h"
8
9
#include "mail-storage.h"
9
10
#include "stats-plugin.h"
10
11
#include "stats-connection.h"
23
24
        if (conn->open_failed)
24
25
                return FALSE;
25
26
 
26
 
        conn->fd = open(conn->path, O_WRONLY);
 
27
        conn->fd = open(conn->path, O_WRONLY | O_NONBLOCK);
27
28
        if (conn->fd == -1) {
28
29
                i_error("stats: open(%s) failed: %m", conn->path);
29
30
                conn->open_failed = TRUE;
40
41
        conn = i_new(struct stats_connection, 1);
41
42
        conn->refcount = 1;
42
43
        conn->path = i_strdup(path);
43
 
        stats_connection_open(conn);
 
44
        (void)stats_connection_open(conn);
44
45
        return conn;
45
46
}
46
47
 
71
72
        static bool pipe_warned = FALSE;
72
73
        ssize_t ret;
73
74
 
 
75
        /* if master process has been stopped (and restarted), don't even try
 
76
           to notify the stats process anymore. even if one exists, it doesn't
 
77
           know about us. */
 
78
        if (master_service_is_master_stopped(master_service))
 
79
                return;
 
80
 
74
81
        if (conn->fd == -1) {
75
82
                if (!stats_connection_open(conn))
76
83
                        return;
108
115
        /* required fields */
109
116
        str_append(str, guid_128_to_string(suser->session_guid));
110
117
        str_append_c(str, '\t');
111
 
        str_tabescape_write(str, user->username);
 
118
        str_append_tabescaped(str, user->username);
112
119
        str_append_c(str, '\t');
113
 
        str_tabescape_write(str, user->service);
 
120
        str_append_tabescaped(str, user->service);
114
121
        str_printfa(str, "\t%s", my_pid);
115
122
 
116
123
        /* optional fields */