When shell_write_data was added in shell_write, which was called in shell_read_data right before getline_reset, eventually, shell_destroy was called because shutdown was set (quit command) and getline_reset aborted, because s->getline was NULL. But this does not indicates that just preventing shell_write_data from being called from shell_write would do the trick. Since shell_handle_data called shell_write_data and shell_read_data in this order, it could eventually happen, when there would be a READ and WRITE event on the socket right after shutdown (more commands after quit). Reversing this order wouldn't solve the problem either, since we don't want to accept more commands after shutdown. Checking for shutdown in shell_handle_data between calls to shell_write_data and shell_read_data solves our problem.
Thadeu Cascardo
shell.patch4
Description: Binary data
