Commit e743d71b authored by Max Kellermann's avatar Max Kellermann

client: check "expired" after command execution

The old code tried to write a response to the client, without even checking if it was already closed. Now that we have added more assertions, these may fail... perform the "expired" check earlier.
parent 76ecc302
...@@ -343,11 +343,14 @@ static int client_process_line(struct client *client) ...@@ -343,11 +343,14 @@ static int client_process_line(struct client *client)
DEBUG("client %i: process command " DEBUG("client %i: process command "
"list returned %i\n", client->num, ret); "list returned %i\n", client->num, ret);
if (ret == COMMAND_RETURN_CLOSE ||
client_is_expired(client)) {
client_close(client);
return COMMAND_RETURN_CLOSE;
}
if (ret == 0) if (ret == 0)
commandSuccess(client->fd); commandSuccess(client->fd);
else if (ret == COMMAND_RETURN_CLOSE
|| client_is_expired(client))
client_close(client);
client_write_output(client); client_write_output(client);
free_cmd_list(client->cmd_list); free_cmd_list(client->cmd_list);
...@@ -385,12 +388,16 @@ static int client_process_line(struct client *client) ...@@ -385,12 +388,16 @@ static int client_process_line(struct client *client)
&(client->permission), line); &(client->permission), line);
DEBUG("client %i: command returned %i\n", DEBUG("client %i: command returned %i\n",
client->num, ret); client->num, ret);
if (ret == 0)
commandSuccess(client->fd); if (ret == COMMAND_RETURN_CLOSE ||
else if (ret == COMMAND_RETURN_CLOSE client_is_expired(client)) {
|| client_is_expired(client)) {
client_close(client); client_close(client);
return COMMAND_RETURN_CLOSE;
} }
if (ret == 0)
commandSuccess(client->fd);
client_write_output(client); client_write_output(client);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment