peer: do an orderly shutdown in case the driver indicates a peer should be disconnected
This will flush out all pending messages before doing shutting down
the socket, so that anything that happened correctly before the error
is still delivered correctly.
@@ -69,9 +69,7 @@ int peer_dispatch(DispatchFile *file, uint32_t mask) {
r = driver_goodbye(peer, false);
if (r)
return error_fold(r);
- connection_close(&peer->connection);
- peer_free(peer);
- return 0;
+ connection_shutdown(&peer->connection);
} else if (r)
return error_fold(r);
}
