From 8c85b8fc1fafd788d4b0b3b814ec5b25bb798276 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 10 Feb 2023 14:48:00 +1000 Subject: [PATCH] protocol: add ei_connection.invalid_object This event is to notify the client that an object used in a request was unknown. This allows the client to work around race conditions like binding to a seat that was removed. This is currently the server-side only which is probably enough for now. The only client-side created objects we have are the callbacks. --- proto/protocol.xml | 11 +++++++++++ src/brei-shared.c | 4 ++++ src/libei.c | 14 +++++++++++++- src/libeis-client.c | 2 ++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/proto/protocol.xml b/proto/protocol.xml index 1c01c90..f18d8e8 100644 --- a/proto/protocol.xml +++ b/proto/protocol.xml @@ -337,6 +337,17 @@ + + + + Notification that an object ID used in a prior request was + invalid and does not exist. + + This event is sent by the EIS implementation when an object that + does not exist as seen by the EIS implementation. + + + diff --git a/src/brei-shared.c b/src/brei-shared.c index 10aad0c..e0bb8e2 100644 --- a/src/brei-shared.c +++ b/src/brei-shared.c @@ -291,6 +291,10 @@ brei_dispatch(struct brei_context *brei, /* Find the object, it is stored in the ei/eis context */ struct brei_object *object = NULL; rc = lookup_object(object_id, &object, user_data); + if (rc == -ENOENT) { + iobuf_pop(buf, msglen); + continue; + } if (rc < 0) goto error; diff --git a/src/libei.c b/src/libei.c index a83b5c8..aced119 100644 --- a/src/libei.c +++ b/src/libei.c @@ -647,7 +647,8 @@ ei_connected(struct ei *ei) } } -static int handle_msg_disconnected(struct ei_connection *connection, uint32_t reason, const char *explanation) +static int +handle_msg_disconnected(struct ei_connection *connection, uint32_t reason, const char *explanation) { struct ei *ei = ei_connection_get_context(connection); @@ -659,6 +660,16 @@ static int handle_msg_disconnected(struct ei_connection *connection, uint32_t re return -ECANCELED; } +static int +handle_msg_invalid_object(struct ei_connection *connection, uint32_t object) +{ + struct ei *ei = ei_connection_get_context(connection); + + log_bug(ei, "Invalid object %#x, I don't yet know how to handle that", object); + + return 0; +} + #define DISCONNECT_IF_SENDER_CONTEXT(ei_) do {\ if (ei_->is_sender) { \ log_bug_client(ei_, "Invalid event from receiver EIS context. Disconnecting"); \ @@ -669,6 +680,7 @@ static int handle_msg_disconnected(struct ei_connection *connection, uint32_t re static const struct ei_connection_interface interface = { .disconnected = handle_msg_disconnected, .seat = handle_msg_seat, + .invalid_object = handle_msg_invalid_object, }; const struct ei_connection_interface * diff --git a/src/libeis-client.c b/src/libeis-client.c index 20f3322..3633610 100644 --- a/src/libeis-client.c +++ b/src/libeis-client.c @@ -321,6 +321,8 @@ lookup_object(uint32_t object_id, struct brei_object **object, void *userdata) } log_debug(eis_client_get_context(client), "Failed to find object %#x", object_id); + if (client->connection) + eis_connection_event_invalid_object(client->connection, object_id); return -ENOENT; }