summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Chen <erikchen@chromium.org>2022-09-29 23:39:40 +0000
committerDaniel Stone <daniels@collabora.com>2024-01-19 15:51:33 +0000
commit2f17d480e848dc8cbd047fab9f322f326da54df9 (patch)
tree51ccbb3e5f0fcb0c6345bdba948aafa57e82d633
parent9867bdb111f827e8e6f43e1c1111bb513811f3f1 (diff)
connection: Spruce up logging for client errors.
Some code paths that lead to a client error and connection termination have no associated logging, or insufficient logging. This makes it difficult to understand what went wrong. This commit adds or supplements logging for all these code paths. Signed-off-by: Erik Chen <erikchen@chromium.org>
-rw-r--r--src/connection.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/connection.c b/src/connection.c
index bcee87e..a6ad410 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -558,20 +558,27 @@ wl_closure_init(const struct wl_message *message, uint32_t size,
count = arg_count_for_signature(message->signature);
if (count > WL_CLOSURE_MAX_ARGS) {
- wl_log("too many args (%d)\n", count);
+ wl_log("too many args (%d) for %s (signature %s)\n", count,
+ message->name, message->signature);
errno = EINVAL;
return NULL;
}
+ int size_to_allocate;
+
if (size) {
*num_arrays = wl_message_count_arrays(message);
- closure = zalloc(sizeof *closure + size +
- *num_arrays * sizeof(struct wl_array));
+ size_to_allocate = sizeof *closure + size +
+ *num_arrays * sizeof(struct wl_array);
} else {
- closure = zalloc(sizeof *closure);
+ size_to_allocate = sizeof *closure;
}
+ closure = zalloc(size_to_allocate);
if (!closure) {
+ wl_log("could not allocate closure of size (%d) for "
+ "%s (signature %s)\n", size_to_allocate, message->name,
+ message->signature);
errno = ENOMEM;
return NULL;
}
@@ -1202,6 +1209,8 @@ serialize_closure(struct wl_closure *closure, uint32_t *buffer,
return size;
overflow:
+ wl_log("serialize_closure overflow for %s (signature %s)\n",
+ message->name, message->signature);
errno = ERANGE;
return -1;
}
@@ -1219,8 +1228,13 @@ wl_closure_send(struct wl_closure *closure, struct wl_connection *connection)
buffer_size = buffer_size_for_closure(closure);
buffer = zalloc(buffer_size * sizeof buffer[0]);
- if (buffer == NULL)
+ if (buffer == NULL) {
+ wl_log("wl_closure_send error: buffer allocation failure of "
+ "size %d\n for %s (signature %s)",
+ buffer_size * sizeof buffer[0], closure->message->name,
+ closure->message->signature);
return -1;
+ }
size = serialize_closure(closure, buffer, buffer_size);
if (size < 0) {
@@ -1247,8 +1261,13 @@ wl_closure_queue(struct wl_closure *closure, struct wl_connection *connection)
buffer_size = buffer_size_for_closure(closure);
buffer = malloc(buffer_size * sizeof buffer[0]);
- if (buffer == NULL)
+ if (buffer == NULL) {
+ wl_log("wl_closure_queue error: buffer allocation failure of "
+ "size %d\n for %s (signature %s)",
+ buffer_size * sizeof buffer[0], closure->message->name,
+ closure->message->signature);
return -1;
+ }
size = serialize_closure(closure, buffer, buffer_size);
if (size < 0) {