~mdw
/
disorder
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
disorder_eclient_queue_response now gets error as well as success
[disorder]
/
lib
/
eclient.c
diff --git
a/lib/eclient.c
b/lib/eclient.c
index
1fc0bfe
..
768220f
100644
(file)
--- a/
lib/eclient.c
+++ b/
lib/eclient.c
@@
-913,7
+913,10
@@
static void eclient_queue_error(const char *msg,
/* for commands that expect a queue dump */
static void queue_response_opcallback(disorder_eclient *c,
struct operation *op) {
/* for commands that expect a queue dump */
static void queue_response_opcallback(disorder_eclient *c,
struct operation *op) {
+ disorder_eclient_queue_response *const completed
+ = (disorder_eclient_queue_response *)op->completed;
int n;
int n;
+ int parse_failed = 0;
struct queue_entry *q, *qh = 0, **qtail = &qh, *qlast = 0;
D(("queue_response_callback"));
struct queue_entry *q, *qh = 0, **qtail = &qh, *qlast = 0;
D(("queue_response_callback"));
@@
-927,18
+930,24
@@
static void queue_response_opcallback(disorder_eclient *c,
*qtail = q;
qtail = &q->next;
qlast = q;
*qtail = q;
qtail = &q->next;
qlast = q;
- }
+ } else
+ parse_failed = 1;
}
}
- if(op->completed)
- ((disorder_eclient_queue_response *)op->completed)(op->v, qh);
+ /* Currently we pass the partial queue to the callback along with the
+ * error. This might not be very useful in practice... */
+ if(parse_failed)
+ completed(op->v, "cannot parse result", qh);
+ else
+ completed(op->v, 0, qh);
} else
} else
- /* TODO don't use protocol_error here */
- protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line);
+ completed(op->v, errorstring(c), 0);
}
/* for 'playing' */
static void playing_response_opcallback(disorder_eclient *c,
struct operation *op) {
}
/* for 'playing' */
static void playing_response_opcallback(disorder_eclient *c,
struct operation *op) {
+ disorder_eclient_queue_response *const completed
+ = (disorder_eclient_queue_response *)op->completed;
struct queue_entry *q;
D(("playing_response_callback"));
struct queue_entry *q;
D(("playing_response_callback"));
@@
-947,21
+956,19
@@
static void playing_response_opcallback(disorder_eclient *c,
case 2:
if(queue_unmarshall(q = xmalloc(sizeof *q), c->line + 4,
eclient_queue_error, c))
case 2:
if(queue_unmarshall(q = xmalloc(sizeof *q), c->line + 4,
eclient_queue_error, c))
- return;
+ completed(op->v, "cannot parse result", 0);
+ else
+ completed(op->v, 0, q);
break;
case 9:
break;
case 9:
-
q = 0
;
+
completed(op->v, 0, 0)
;
break;
default:
break;
default:
- /* TODO don't use protocol_error here */
- protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line);
- return;
+ completed(op->v, errorstring(c), 0);
+ break;
}
}
- if(op->completed)
- ((disorder_eclient_queue_response *)op->completed)(op->v, q);
} else
} else
- /* TODO don't use protocol_error here */
- protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line);
+ completed(op->v, errorstring(c), 0);
}
/* for commands that expect a list of some sort */
}
/* for commands that expect a list of some sort */
@@
-981,21
+988,20
@@
static void list_response_opcallback(disorder_eclient *c,
/* for volume */
static void volume_response_opcallback(disorder_eclient *c,
struct operation *op) {
/* for volume */
static void volume_response_opcallback(disorder_eclient *c,
struct operation *op) {
+ disorder_eclient_volume_response *completed
+ = (disorder_eclient_volume_response *)op->completed;
int l, r;
D(("volume_response_callback"));
if(c->rc / 100 == 2) {
if(op->completed) {
if(sscanf(c->line + 4, "%d %d", &l, &r) != 2 || l < 0 || r < 0)
int l, r;
D(("volume_response_callback"));
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);
+ completed(op->v, "cannot parse volume response", 0, 0);
else
else
-
((disorder_eclient_volume_response *)op->completed)(op->v
, l, r);
+
completed(op->v, 0
, l, r);
}
} else
}
} else
- /* TODO don't use protocol_error here */
- protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line);
+ completed(op->v, errorstring(c), 0, 0);
}
static int simple(disorder_eclient *c,
}
static int simple(disorder_eclient *c,