[mpd] Add missing OK response line, if multiple commands are sent

without beeing wrapped in a command list
This commit is contained in:
chme 2020-11-08 08:22:57 +01:00
parent ccaa7967bf
commit 59bac6b068
1 changed files with 14 additions and 5 deletions

View File

@ -108,7 +108,8 @@ enum command_list_type
{ {
COMMAND_LIST = 1, COMMAND_LIST = 1,
COMMAND_LIST_OK = 2, COMMAND_LIST_OK = 2,
COMMAND_LIST_NONE = 3 COMMAND_LIST_END = 3,
COMMAND_LIST_NONE = 4
}; };
/** /**
@ -4273,6 +4274,7 @@ mpd_read_cb(struct bufferevent *bev, void *ctx)
} }
else if (0 == strcmp(argv[0], "command_list_end")) else if (0 == strcmp(argv[0], "command_list_end"))
{ {
listtype = COMMAND_LIST_END;
free(line); free(line);
break; break;
} }
@ -4331,7 +4333,13 @@ mpd_read_cb(struct bufferevent *bev, void *ctx)
{ {
evbuffer_add(output, "list_OK\n", 8); evbuffer_add(output, "list_OK\n", 8);
} }
/*
* If everything was successful add OK line to signal clients end of command message.
*/
else if (listtype == COMMAND_LIST_NONE && idle_cmd == 0 && close_cmd == 0)
{
evbuffer_add(output, "OK\n", 3);
}
free(line); free(line);
ncmd++; ncmd++;
} }
@ -4339,10 +4347,11 @@ mpd_read_cb(struct bufferevent *bev, void *ctx)
DPRINTF(E_SPAM, L_MPD, "Finished MPD command sequence: %d\n", ret); DPRINTF(E_SPAM, L_MPD, "Finished MPD command sequence: %d\n", ret);
/* /*
* If everything was successful add OK line to signal clients end of message. * If everything was successful and we are processing a command list, add OK line to signal
* If an error occured the necessary ACK line should already be added to the response buffer. * clients end of message.
* If an error occurred the necessary ACK line should already be added to the response buffer.
*/ */
if (ret == 0 && idle_cmd == 0 && close_cmd == 0) if (ret == 0 && close_cmd == 0 && listtype == COMMAND_LIST_END)
{ {
evbuffer_add(output, "OK\n", 3); evbuffer_add(output, "OK\n", 3);
} }