From 1f3ce240ea5d0cc659c45cc8c0457dd10f36d847 Mon Sep 17 00:00:00 2001 Message-Id: <1f3ce240ea5d0cc659c45cc8c0457dd10f36d847.1714145096.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sat, 7 Jun 2008 20:13:59 +0100 Subject: [PATCH] TODOs for all the protocol_error() calls that need fixed Organization: Straylight/Edgeware From: Richard Kettlewell --- lib/eclient.c | 16 ++++++++++++++++ lib/eclient.h | 11 ++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/eclient.c b/lib/eclient.c index a9805f7..d0e398a 100644 --- a/lib/eclient.c +++ b/lib/eclient.c @@ -519,6 +519,7 @@ static void maybe_connected(disorder_eclient *c) { /* Authentication ************************************************************/ +/** @brief Called with the greeting from the server */ static void authbanner_opcallback(disorder_eclient *c, struct operation *op) { size_t nonce_len; @@ -577,6 +578,7 @@ static void authbanner_opcallback(disorder_eclient *c, (char *)0); } +/** @brief Called with the response to the @c user command */ static void authuser_opcallback(disorder_eclient *c, struct operation *op) { char *r; @@ -846,12 +848,14 @@ static void string_response_opcallback(disorder_eclient *c, if(rr && *rr) ((disorder_eclient_string_response *)op->completed)(op->v, *rr); else + /* TODO don't use protocol_error here */ protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line); } else ((disorder_eclient_string_response *)op->completed)(op->v, c->line + 4); } } else + /* TODO don't use protocol_error here */ protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line); } @@ -864,6 +868,7 @@ static void integer_response_opcallback(disorder_eclient *c, ((disorder_eclient_integer_response *)op->completed) (op->v, strtol(c->line + 4, 0, 10)); } else + /* TODO don't use protocol_error here */ protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line); } @@ -875,6 +880,7 @@ static void no_response_opcallback(disorder_eclient *c, if(op->completed) ((disorder_eclient_no_response *)op->completed)(op->v); } else + /* TODO don't use protocol_error here */ protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line); } @@ -883,6 +889,7 @@ static void eclient_queue_error(const char *msg, void *u) { struct operation *op = u; + /* TODO don't use protocol_error here */ protocol_error(op->client, op, -1, "error parsing queue entry: %s", msg); } @@ -908,6 +915,7 @@ static void queue_response_opcallback(disorder_eclient *c, if(op->completed) ((disorder_eclient_queue_response *)op->completed)(op->v, qh); } else + /* TODO don't use protocol_error here */ protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line); } @@ -928,12 +936,14 @@ static void playing_response_opcallback(disorder_eclient *c, q = 0; break; default: + /* TODO don't use protocol_error here */ protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line); return; } if(op->completed) ((disorder_eclient_queue_response *)op->completed)(op->v, q); } else + /* TODO don't use protocol_error here */ protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line); } @@ -947,6 +957,7 @@ static void list_response_opcallback(disorder_eclient *c, c->vec.nvec, c->vec.vec); } else + /* TODO don't use protocol_error here */ protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line); } @@ -959,12 +970,14 @@ static void volume_response_opcallback(disorder_eclient *c, if(c->rc / 100 == 2) { if(op->completed) { if(sscanf(c->line + 4, "%d %d", &l, &r) != 2 || l < 0 || r < 0) + /* TODO don't use protocol_error here */ protocol_error(c, op, -1, "%s: invalid volume response: %s", c->ident, c->line); else ((disorder_eclient_volume_response *)op->completed)(op->v, l, r); } } else + /* TODO don't use protocol_error here */ protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line); } @@ -1242,6 +1255,7 @@ static void rtp_response_opcallback(disorder_eclient *c, ((disorder_eclient_list_response *)op->completed)(op->v, nvec, vec); } } else + /* TODO don't use protocol_error here */ protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line); } @@ -1380,6 +1394,7 @@ static void log_opcallback(disorder_eclient *c, /* error callback for log line parsing */ static void logline_error(const char *msg, void *u) { disorder_eclient *c = u; + /* TODO don't use protocol_error here */ protocol_error(c, c->ops, -1, "error parsing log line: %s", msg); } @@ -1395,6 +1410,7 @@ static void logline(disorder_eclient *c, const char *line) { * reported */ if(sscanf(vec[0], "%"SCNxMAX, &when) != 1) { /* probably the wrong side of a format change */ + /* TODO don't use protocol_error here */ protocol_error(c, c->ops, -1, "invalid log timestamp '%s'", vec[0]); return; } diff --git a/lib/eclient.h b/lib/eclient.h index 157ad59..1b79cc0 100644 --- a/lib/eclient.h +++ b/lib/eclient.h @@ -42,9 +42,13 @@ struct queue_entry; * These must all be valid. */ typedef struct disorder_eclient_callbacks { - /** @brief Called when a communication error (e.g. connected refused) occurs. + /** @brief Called when a communication error occurs. * @param u from disorder_eclient_new() * @param msg error message + * + * This might be called at any time, and indicates a low-level error, + * e.g. connection refused by the server. It does not mean that any requests + * made of the owning eclient will not be fulfilled at some point. */ void (*comms_error)(void *u, const char *msg); @@ -52,6 +56,11 @@ typedef struct disorder_eclient_callbacks { * @param u from disorder_eclient_new() * @param v from failed command, or NULL if during setup * @param msg error message + * + * This call is obsolete at least in its current form, in which it is used to + * report most errors from most requests. Ultimately requests-specific + * errors will be reported in a request-specific way rather than via this + * generic callback. */ void (*protocol_error)(void *u, void *v, int code, const char *msg); -- [mdw]