Lines Matching refs:connection
164 struct wl_connection *connection; in wl_connection_create() local
166 connection = zalloc(sizeof *connection); in wl_connection_create()
167 if (connection == NULL) in wl_connection_create()
170 connection->fd = fd; in wl_connection_create()
172 return connection; in wl_connection_create()
195 wl_connection_destroy(struct wl_connection *connection) in wl_connection_destroy() argument
197 int fd = connection->fd; in wl_connection_destroy()
199 close_fds(&connection->fds_out, -1); in wl_connection_destroy()
200 close_fds(&connection->fds_in, -1); in wl_connection_destroy()
201 free(connection); in wl_connection_destroy()
207 wl_connection_copy(struct wl_connection *connection, void *data, size_t size) in wl_connection_copy() argument
209 wl_buffer_copy(&connection->in, data, size); in wl_connection_copy()
213 wl_connection_consume(struct wl_connection *connection, size_t size) in wl_connection_consume() argument
215 connection->in.tail += size; in wl_connection_consume()
274 wl_connection_flush(struct wl_connection *connection) in wl_connection_flush() argument
282 if (!connection->want_flush) in wl_connection_flush()
285 tail = connection->out.tail; in wl_connection_flush()
286 while (connection->out.head - connection->out.tail > 0) { in wl_connection_flush()
287 wl_buffer_get_iov(&connection->out, iov, &count); in wl_connection_flush()
289 build_cmsg(&connection->fds_out, cmsg, &clen); in wl_connection_flush()
300 len = sendmsg(connection->fd, &msg, in wl_connection_flush()
307 close_fds(&connection->fds_out, MAX_FDS_OUT); in wl_connection_flush()
309 connection->out.tail += len; in wl_connection_flush()
312 connection->want_flush = 0; in wl_connection_flush()
314 return connection->out.head - tail; in wl_connection_flush()
318 wl_connection_pending_input(struct wl_connection *connection) in wl_connection_pending_input() argument
320 return wl_buffer_size(&connection->in); in wl_connection_pending_input()
324 wl_connection_read(struct wl_connection *connection) in wl_connection_read() argument
331 if (wl_buffer_size(&connection->in) >= sizeof(connection->in.data)) { in wl_connection_read()
336 wl_buffer_put_iov(&connection->in, iov, &count); in wl_connection_read()
347 len = wl_os_recvmsg_cloexec(connection->fd, &msg, MSG_DONTWAIT); in wl_connection_read()
353 ret = decode_cmsg(&connection->fds_in, &msg); in wl_connection_read()
357 connection->in.head += len; in wl_connection_read()
359 return wl_connection_pending_input(connection); in wl_connection_read()
363 wl_connection_write(struct wl_connection *connection, in wl_connection_write() argument
366 if (connection->out.head - connection->out.tail + in wl_connection_write()
367 count > ARRAY_LENGTH(connection->out.data)) { in wl_connection_write()
368 connection->want_flush = 1; in wl_connection_write()
369 if (wl_connection_flush(connection) < 0) in wl_connection_write()
373 if (wl_buffer_put(&connection->out, data, count) < 0) in wl_connection_write()
376 connection->want_flush = 1; in wl_connection_write()
382 wl_connection_queue(struct wl_connection *connection, in wl_connection_queue() argument
385 if (connection->out.head - connection->out.tail + in wl_connection_queue()
386 count > ARRAY_LENGTH(connection->out.data)) { in wl_connection_queue()
387 connection->want_flush = 1; in wl_connection_queue()
388 if (wl_connection_flush(connection) < 0) in wl_connection_queue()
392 return wl_buffer_put(&connection->out, data, count); in wl_connection_queue()
409 wl_connection_get_fd(struct wl_connection *connection) in wl_connection_get_fd() argument
411 return connection->fd; in wl_connection_get_fd()
415 wl_connection_put_fd(struct wl_connection *connection, int32_t fd) in wl_connection_put_fd() argument
417 if (wl_buffer_size(&connection->fds_out) == MAX_FDS_OUT * sizeof fd) { in wl_connection_put_fd()
418 connection->want_flush = 1; in wl_connection_put_fd()
419 if (wl_connection_flush(connection) < 0) in wl_connection_put_fd()
423 return wl_buffer_put(&connection->fds_out, &fd, sizeof fd); in wl_connection_put_fd()
622 wl_connection_demarshal(struct wl_connection *connection, in wl_connection_demarshal() argument
640 wl_connection_consume(connection, size); in wl_connection_demarshal()
648 wl_connection_consume(connection, size); in wl_connection_demarshal()
656 wl_connection_copy(connection, p, size); in wl_connection_demarshal()
767 if (connection->fds_in.tail == connection->fds_in.head) { in wl_connection_demarshal()
776 wl_buffer_copy(&connection->fds_in, &fd, sizeof fd); in wl_connection_demarshal()
777 connection->fds_in.tail += sizeof fd; in wl_connection_demarshal()
789 wl_connection_consume(connection, size); in wl_connection_demarshal()
795 wl_connection_consume(connection, size); in wl_connection_demarshal()
948 struct wl_connection *connection) in copy_fds_to_connection() argument
963 if (wl_connection_put_fd(connection, fd)) { in copy_fds_to_connection()
1115 wl_closure_send(struct wl_closure *closure, struct wl_connection *connection) in wl_closure_send() argument
1122 if (copy_fds_to_connection(closure, connection)) in wl_closure_send()
1136 result = wl_connection_write(connection, buffer, size); in wl_closure_send()
1143 wl_closure_queue(struct wl_closure *closure, struct wl_connection *connection) in wl_closure_queue() argument
1150 if (copy_fds_to_connection(closure, connection)) in wl_closure_queue()
1164 result = wl_connection_queue(connection, buffer, size); in wl_closure_queue()