Fix assertion failure on connection write error.

Connection::on_write on failure attempts to transition the state from REQUEST_STATE_WRITING to REQUEST_STATE_DONE. This caused Connection::Request::change_state to immediately kill the application with assert(false && "Invalid request state after writing").
Merge branch 'planetbeing-1.0' into 1.0
Merged similiar cases (to match fix in beta2)
Merge branch 'planetbeing-1.0' into 1.0