Lines Matching defs:conn
24 static bool stats_connection_open(struct stats_connection *conn)
26 if (conn->open_failed)
29 conn->fd = open(conn->path, O_WRONLY | O_NONBLOCK);
30 if (conn->fd == -1) {
31 i_error("stats: open(%s) failed: %m", conn->path);
32 conn->open_failed = TRUE;
41 struct stats_connection *conn;
43 conn = i_new(struct stats_connection, 1);
44 conn->refcount = 1;
45 conn->path = i_strdup(path);
46 (void)stats_connection_open(conn);
47 return conn;
50 void stats_connection_ref(struct stats_connection *conn)
52 conn->refcount++;
57 struct stats_connection *conn = *_conn;
59 i_assert(conn->refcount > 0);
60 if (--conn->refcount > 0)
64 i_close_fd_path(&conn->fd, conn->path);
65 i_free(conn->path);
66 i_free(conn);
69 int stats_connection_send(struct stats_connection *conn, const string_t *str)
80 if (conn->fd == -1) {
81 if (!stats_connection_open(conn))
83 i_assert(conn->fd != -1);
93 ret = write(conn->fd, str_data(str), str_len(str));
99 if (ioloop_time > conn->next_warning_timestamp) {
100 i_warning("write(%s) failed: %m (stats process is busy)", conn->path);
101 conn->next_warning_timestamp = ioloop_time +
111 i_error("write(%s) failed: %m", conn->path);
113 i_error("write(%s) wrote partial update", conn->path);
114 if (close(conn->fd) < 0)
115 i_error("close(%s) failed: %m", conn->path);
116 conn->fd = -1;