Lines Matching refs:conn
17 #define CONNECTION_IS_FIFO(conn) \
18 ((conn)->output == NULL)
32 static void notify_connection_unref(struct notify_connection *conn);
33 static void notify_connection_destroy(struct notify_connection *conn);
35 static bool notify_input_error(struct notify_connection *conn)
37 if (CONNECTION_IS_FIFO(conn))
39 notify_connection_destroy(conn);
45 struct notify_connection *conn = context;
47 o_stream_nsend_str(conn->output, success ? "+\n" : "-\n");
48 notify_connection_unref(conn);
52 notify_input_line(struct notify_connection *conn, const char *line)
70 conn->refcount++;
71 replicator_connection_notify_sync(replicator, args[0], conn);
76 static void notify_input(struct notify_connection *conn)
81 switch (i_stream_read(conn->input)) {
85 (void)notify_input_error(conn);
89 notify_connection_destroy(conn);
93 while ((line = i_stream_next_line(conn->input)) != NULL) {
95 ret = notify_input_line(conn, line);
98 if (!notify_input_error(conn))
106 struct notify_connection *conn;
108 conn = i_new(struct notify_connection, 1);
109 conn->refcount = 1;
110 conn->fd = fd;
111 conn->io = io_add(fd, IO_READ, notify_input, conn);
112 conn->input = i_stream_create_fd(fd, MAX_INBUF_SIZE);
114 conn->output = o_stream_create_fd(fd, (size_t)-1);
115 o_stream_set_no_error_handling(conn->output, TRUE);
118 DLLIST_PREPEND(&conns, conn);
121 static void notify_connection_unref(struct notify_connection *conn)
123 i_assert(conn->refcount > 0);
124 if (--conn->refcount > 0)
127 i_stream_destroy(&conn->input);
128 o_stream_destroy(&conn->output);
129 i_free(conn);
132 static void notify_connection_destroy(struct notify_connection *conn)
134 i_assert(conn->fd != -1);
136 if (!CONNECTION_IS_FIFO(conn))
139 DLLIST_REMOVE(&conns, conn);
141 io_remove(&conn->io);
142 i_stream_close(conn->input);
143 o_stream_close(conn->output);
144 net_disconnect(conn->fd);
145 conn->fd = -1;
147 notify_connection_unref(conn);