mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-28 08:05:56 -05:00
[commands] Stop command execution, if command function returns an unkown
command state
This commit is contained in:
parent
da83af04e2
commit
1238fe124a
@ -65,7 +65,7 @@ command_cb_async(struct commands_base *cmdbase, struct command *cmd)
|
|||||||
cmdstate = cmd->func(cmd->arg, &cmd->ret);
|
cmdstate = cmd->func(cmd->arg, &cmd->ret);
|
||||||
|
|
||||||
// Only free arg if there are no pending events (used in worker.c)
|
// Only free arg if there are no pending events (used in worker.c)
|
||||||
if (cmdstate == COMMAND_END && cmd->arg)
|
if (cmdstate != COMMAND_PENDING && cmd->arg)
|
||||||
free(cmd->arg);
|
free(cmd->arg);
|
||||||
|
|
||||||
free(cmd);
|
free(cmd);
|
||||||
@ -84,7 +84,13 @@ command_cb_sync(struct commands_base *cmdbase, struct command *cmd)
|
|||||||
pthread_mutex_lock(&cmd->lck);
|
pthread_mutex_lock(&cmd->lck);
|
||||||
|
|
||||||
cmdstate = cmd->func(cmd->arg, &cmd->ret);
|
cmdstate = cmd->func(cmd->arg, &cmd->ret);
|
||||||
if (cmdstate == COMMAND_END)
|
if (cmdstate == COMMAND_PENDING)
|
||||||
|
{
|
||||||
|
// Command execution is waiting for pending events before returning to the caller
|
||||||
|
cmdbase->current_cmd = cmd;
|
||||||
|
cmd->pending = cmd->ret;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// Command execution finished, execute the bottom half function
|
// Command execution finished, execute the bottom half function
|
||||||
if (cmd->ret == 0 && cmd->func_bh)
|
if (cmd->ret == 0 && cmd->func_bh)
|
||||||
@ -98,12 +104,6 @@ command_cb_sync(struct commands_base *cmdbase, struct command *cmd)
|
|||||||
|
|
||||||
event_add(cmdbase->command_event, NULL);
|
event_add(cmdbase->command_event, NULL);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Command execution is waiting for pending events before returning to the caller
|
|
||||||
cmdbase->current_cmd = cmd;
|
|
||||||
cmd->pending = cmd->ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user