Lines Matching refs:conn

34 	struct notify_connection *conn;
40 static void notify_connection_destroy(struct notify_connection *conn);
46 o_stream_nsend_str(request->conn->output, t_strdup_printf(
49 notify_connection_unref(&request->conn);
54 notify_connection_input_line(struct notify_connection *conn, const char *line)
76 (void)replicator_queue_add(conn->queue, args[1], priority);
82 request->conn = conn;
84 notify_connection_ref(conn);
85 replicator_queue_add_sync(conn->queue, args[1],
91 static void notify_connection_input(struct notify_connection *conn)
96 switch (i_stream_read(conn->input)) {
99 notify_connection_destroy(conn);
102 notify_connection_destroy(conn);
106 if (!conn->version_received) {
107 if ((line = i_stream_next_line(conn->input)) == NULL)
114 notify_connection_destroy(conn);
117 conn->version_received = TRUE;
120 while ((line = i_stream_next_line(conn->input)) != NULL) {
122 ret = notify_connection_input_line(conn, line);
125 notify_connection_destroy(conn);
134 struct notify_connection *conn;
138 conn = i_new(struct notify_connection, 1);
139 conn->refcount = 1;
140 conn->queue = queue;
141 conn->fd = fd;
142 conn->input = i_stream_create_fd(fd, MAX_INBUF_SIZE);
143 conn->output = o_stream_create_fd(fd, (size_t)-1);
144 o_stream_set_no_error_handling(conn->output, TRUE);
145 conn->io = io_add(fd, IO_READ, notify_connection_input, conn);
146 conn->queue = queue;
148 DLLIST_PREPEND(&connections, conn);
149 return conn;
152 static void notify_connection_destroy(struct notify_connection *conn)
154 if (conn->destroyed)
156 conn->destroyed = TRUE;
158 DLLIST_REMOVE(&connections, conn);
160 io_remove(&conn->io);
161 i_stream_close(conn->input);
162 o_stream_close(conn->output);
163 if (close(conn->fd) < 0)
165 conn->fd = -1;
167 notify_connection_unref(&conn);
171 void notify_connection_ref(struct notify_connection *conn)
173 i_assert(conn->refcount > 0);
175 conn->refcount++;
180 struct notify_connection *conn = *_conn;
182 i_assert(conn->refcount > 0);
185 if (--conn->refcount > 0)
188 notify_connection_destroy(conn);
189 i_stream_unref(&conn->input);
190 o_stream_unref(&conn->output);
191 i_free(conn);