Set self.pos before handling the message

This intuitively feels wrong, but isn't. Most importantly, handleError
immediately exits, but we still need to "consume" that message,
otherwise pounce will keep sending it on reconnect. The same goes for
any other handler that might cause an exit, such as a require parameter
count failure.
master
C. McEnroe 2020-03-08 23:15:56 -04:00
parent 5c167e4181
commit 7e120f00a1
1 changed files with 3 additions and 3 deletions

View File

@ -1018,6 +1018,9 @@ static int compar(const void *cmd, const void *_handler) {
void handle(struct Message msg) { void handle(struct Message msg) {
if (!msg.cmd) return; if (!msg.cmd) return;
if (msg.tags[TagPos]) {
self.pos = strtoull(msg.tags[TagPos], NULL, 10);
}
const struct Handler *handler = bsearch( const struct Handler *handler = bsearch(
msg.cmd, Handlers, ARRAY_LEN(Handlers), sizeof(*handler), compar msg.cmd, Handlers, ARRAY_LEN(Handlers), sizeof(*handler), compar
); );
@ -1026,7 +1029,4 @@ void handle(struct Message msg) {
} else if (strcmp(msg.cmd, "400") >= 0 && strcmp(msg.cmd, "599") <= 0) { } else if (strcmp(msg.cmd, "400") >= 0 && strcmp(msg.cmd, "599") <= 0) {
handleErrorGeneric(&msg); handleErrorGeneric(&msg);
} }
if (msg.tags[TagPos]) {
self.pos = strtoull(msg.tags[TagPos], NULL, 10);
}
} }