From dd5bc6b6e7c4fffc2febb0665730cc7028cfb8e2 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 16 Feb 2023 11:22:44 +1000 Subject: [PATCH] proto: add a bunch of error reasons for debugging --- proto/protocol.xml | 16 +++++++++++++--- src/brei-shared.c | 6 +++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/proto/protocol.xml b/proto/protocol.xml index 85aa44f..561d849 100644 --- a/proto/protocol.xml +++ b/proto/protocol.xml @@ -301,9 +301,19 @@ provide information to the client on whether it was disconnected as part of normal operations or as result of an error on either the client or EIS implementation side. + + A nonzero value describes an error, with the generic value "error" (1) reserved + as fallback. + + This enum may be extended in the future, clients must be able to handle + values that are not in their supproted version of this enum. + + + + @@ -312,11 +322,11 @@ the client is disconnected. Where a client is disconnected by EIS on purpose, for example after - a user interaction, the reason is disconnect_reason.disconnected and - the explanation is NULL. + a user interaction, the reason is disconnect_reason.disconnected (i.e. zero) + and the explanation is NULL. Where a client is disconnected due to some invalid request or other - protocol error, the reason is disconnect_reason.error and + protocol error, the reason is one of disconnect_reason (i.e. nonzero) and explanation may contain a string explaining why. This string is intended to help debugging only and is not guaranteed to stay constant. diff --git a/src/brei-shared.c b/src/brei-shared.c index e585587..a250a22 100644 --- a/src/brei-shared.c +++ b/src/brei-shared.c @@ -323,10 +323,10 @@ brei_dispatch(struct brei_context *brei, if (rc == -EAGAIN) { return NULL; } else if (rc == 0) { - return brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_ERROR, + return brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_TRANSPORT, "socket disconnected"); } else if (rc < 0) { - return brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_ERROR, + return brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_TRANSPORT, "error: %s", strerror(-rc)); } @@ -367,7 +367,7 @@ brei_dispatch(struct brei_context *brei, assert(interface); if (opcode >= interface->nincoming) { - result = brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_ERROR, + result = brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_PROTOCOL, "opcode %u exceeds interface %s method count %u", opcode, interface->name, interface->nincoming); goto error;