Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- server/dispatcher.c | 26 +++++++++++++------------- server/dispatcher.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/server/dispatcher.c b/server/dispatcher.c index 3e27f2c2..4cd91f11 100644 --- a/server/dispatcher.c +++ b/server/dispatcher.c @@ -50,8 +50,8 @@ G_DEFINE_TYPE(Dispatcher, dispatcher, G_TYPE_OBJECT) #define DISPATCHER_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_DISPATCHER, DispatcherPrivate)) struct DispatcherPrivate { - int recv_fd; - int send_fd; + socket_t recv_fd; + socket_t send_fd; pthread_t thread_id; pthread_mutex_t lock; DispatcherMessage *messages; @@ -109,8 +109,8 @@ dispatcher_finalize(GObject *object) { Dispatcher *self = DISPATCHER(object); g_free(self->priv->messages); - close(self->priv->send_fd); - close(self->priv->recv_fd); + socket_close(self->priv->send_fd); + socket_close(self->priv->recv_fd); pthread_mutex_destroy(&self->priv->lock); g_free(self->priv->payload); G_OBJECT_CLASS(dispatcher_parent_class)->finalize(object); @@ -119,14 +119,14 @@ dispatcher_finalize(GObject *object) static void dispatcher_constructed(GObject *object) { Dispatcher *self = DISPATCHER(object); - int channels[2]; + socket_t channels[2]; G_OBJECT_CLASS(dispatcher_parent_class)->constructed(object); #ifdef DEBUG_DISPATCHER setup_dummy_signal_handler(); #endif - if (socketpair(AF_LOCAL, SOCK_STREAM, 0, channels) == -1) { + if (socket_newpair(SOCK_STREAM, 0, channels) == -1) { spice_error("socketpair failed %s", strerror(errno)); return; } @@ -187,7 +187,7 @@ dispatcher_new(size_t max_message_type) * if 0 poll first, return immediately if no bytes available, otherwise * read size in blocking mode. */ -static int read_safe(int fd, uint8_t *buf, size_t size, int block) +static int read_safe(socket_t fd, uint8_t *buf, size_t size, int block) { int read_size = 0; int ret; @@ -197,7 +197,7 @@ static int read_safe(int fd, uint8_t *buf, size_t size, int block) } if (!block) { - struct pollfd pollfd = {.fd = fd, .events = POLLIN, .revents = 0}; + struct pollfd pollfd = {.fd = socket_get_raw(fd), .events = POLLIN, .revents = 0}; while ((ret = poll(&pollfd, 1, 0)) == -1) { if (errno == EINTR) { spice_debug("EINTR in poll"); @@ -211,7 +211,7 @@ static int read_safe(int fd, uint8_t *buf, size_t size, int block) } } while (read_size < size) { - ret = read(fd, buf + read_size, size - read_size); + ret = socket_read(fd, buf + read_size, size - read_size); if (ret == -1) { if (errno == EINTR) { spice_debug("EINTR in read"); @@ -232,13 +232,13 @@ static int read_safe(int fd, uint8_t *buf, size_t size, int block) * write_safe * @return -1 for error, otherwise number of written bytes. may be zero. */ -static int write_safe(int fd, uint8_t *buf, size_t size) +static int write_safe(socket_t fd, uint8_t *buf, size_t size) { int written_size = 0; int ret; while (written_size < size) { - ret = write(fd, buf + written_size, size - written_size); + ret = socket_write(fd, buf + written_size, size - written_size); if (ret == -1) { if (errno != EINTR) { return -1; @@ -310,7 +310,7 @@ void dispatcher_send_message(Dispatcher *dispatcher, uint32_t message_type, { DispatcherMessage *msg; uint32_t ack; - int send_fd = dispatcher->priv->send_fd; + socket_t send_fd = dispatcher->priv->send_fd; assert(dispatcher->priv->max_message_type > message_type); assert(dispatcher->priv->messages[message_type].handler); @@ -393,7 +393,7 @@ void dispatcher_set_opaque(Dispatcher *self, void *opaque) self->priv->opaque = opaque; } -int dispatcher_get_recv_fd(Dispatcher *dispatcher) +socket_t dispatcher_get_recv_fd(Dispatcher *dispatcher) { return dispatcher->priv->recv_fd; } diff --git a/server/dispatcher.h b/server/dispatcher.h index bb968e56..bbc88224 100644 --- a/server/dispatcher.h +++ b/server/dispatcher.h @@ -155,7 +155,7 @@ void dispatcher_handle_recv_read(Dispatcher *); * * @return: receive file descriptor of the dispatcher */ -int dispatcher_get_recv_fd(Dispatcher *); +socket_t dispatcher_get_recv_fd(Dispatcher *); /* dispatcher_set_opaque * -- 2.17.2 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel