diff --git a/src/connection.c b/src/connection.c index fa01545..05fa8f8 100644 --- a/src/connection.c +++ b/src/connection.c @@ -123,7 +123,10 @@ static void wl_buffer_get_iov(struct wl_buffer *b, struct iovec *iov, int *count) { int head, tail; - + if (b->head == b->tail) { + *count = 0; + return; + } head = MASK(b->head); tail = MASK(b->tail); if (tail < head) { @@ -275,14 +278,12 @@ wl_connection_data(struct wl_connection *connection, uint32_t mask) do { len = sendmsg(connection->fd, &msg, MSG_NOSIGNAL | MSG_DONTWAIT); - } while (len < 0 && errno == EINTR); + } while (len < 0 && (errno == EINTR || errno == EAGAIN)); - if (len == -1 && errno == EPIPE) { - return -1; - } else if (len < 0) { + if (len < 0) { fprintf(stderr, - "write error for connection %p, fd %d: %m\n", - connection, connection->fd); + "write error for connection %p, fd %d: %m (%d)\n", + connection, connection->fd, errno); return -1; } @@ -311,7 +312,7 @@ wl_connection_data(struct wl_connection *connection, uint32_t mask) do { len = recvmsg(connection->fd, &msg, MSG_CMSG_CLOEXEC); - } while (len < 0 && errno == EINTR); + } while (len < 0 && (errno == EINTR || errno == EAGAIN)); if (len < 0) { fprintf(stderr, @@ -554,8 +555,8 @@ wl_connection_vmarshal(struct wl_connection *connection, return closure; err: - printf("request too big to marshal, maximum size is %lu\n", - sizeof closure->buffer); + printf("request too big to marshal, maximum size is %u\n", + (unsigned)(sizeof closure->buffer)); errno = ENOMEM; return NULL; } @@ -584,8 +585,8 @@ wl_connection_demarshal(struct wl_connection *connection, extra_space = wl_message_size_extra(message); if (sizeof closure->buffer < size + extra_space) { - printf("request too big to demarshal, maximum %lu actual %d\n", - sizeof closure->buffer, size + extra_space); + printf("request too big to demarshal, maximum %u actual %d\n", + (unsigned)(sizeof closure->buffer), size + extra_space); errno = ENOMEM; wl_connection_consume(connection, size); return NULL; diff --git a/src/wayland-server.c b/src/wayland-server.c index 899c094..075ebe8 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -161,6 +161,9 @@ wl_resource_post_error(struct wl_resource *resource, vsnprintf(buffer, sizeof buffer, msg, ap); va_end(ap); + if (wl_debug) + fprintf(stderr, "%s\n", buffer); + client->error = 1; /* @@ -212,7 +215,8 @@ wl_client_connection_data(int fd, uint32_t mask, void *data) if (resource == NULL) { wl_resource_post_error(client->display_resource, WL_DISPLAY_ERROR_INVALID_OBJECT, - "invalid object %d", p[0]); + "invalid object %d (method %d, size %d)", + p[0], opcode, size); break; } @@ -220,9 +224,10 @@ wl_client_connection_data(int fd, uint32_t mask, void *data) if (opcode >= object->interface->method_count) { wl_resource_post_error(client->display_resource, WL_DISPLAY_ERROR_INVALID_METHOD, - "invalid method %d, object %s@%d", + "invalid method %d (size %d), object %s@%d", + opcode, size, object->interface->name, - object->id, opcode); + object->id); break; }