peer table cleanup
async cleanup
This commit is contained in:
@@ -122,10 +122,7 @@ impl ConnectionManager {
|
||||
}
|
||||
|
||||
// Returns a network connection if one already is established
|
||||
pub async fn get_connection(
|
||||
&self,
|
||||
descriptor: ConnectionDescriptor,
|
||||
) -> Option<ConnectionHandle> {
|
||||
pub fn get_connection(&self, descriptor: ConnectionDescriptor) -> Option<ConnectionHandle> {
|
||||
let mut inner = self.arc.inner.lock();
|
||||
let inner = match &mut *inner {
|
||||
Some(v) => v,
|
||||
@@ -363,6 +360,7 @@ impl ConnectionManager {
|
||||
None => None,
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(mut conn) = conn {
|
||||
conn.close();
|
||||
conn.await;
|
||||
|
@@ -1184,7 +1184,7 @@ impl NetworkManager {
|
||||
}
|
||||
|
||||
// And now use the existing connection to send over
|
||||
if let Some(descriptor) = inbound_nr.last_connection().await {
|
||||
if let Some(descriptor) = inbound_nr.last_connection() {
|
||||
match self
|
||||
.net()
|
||||
.send_data_to_existing_connection(descriptor, data)
|
||||
@@ -1283,7 +1283,7 @@ impl NetworkManager {
|
||||
}
|
||||
|
||||
// And now use the existing connection to send over
|
||||
if let Some(descriptor) = inbound_nr.last_connection().await {
|
||||
if let Some(descriptor) = inbound_nr.last_connection() {
|
||||
match self
|
||||
.net()
|
||||
.send_data_to_existing_connection(descriptor, data)
|
||||
@@ -1316,7 +1316,7 @@ impl NetworkManager {
|
||||
let this = self.clone();
|
||||
Box::pin(async move {
|
||||
// First try to send data to the last socket we've seen this peer on
|
||||
let data = if let Some(connection_descriptor) = node_ref.last_connection().await {
|
||||
let data = if let Some(connection_descriptor) = node_ref.last_connection() {
|
||||
match this
|
||||
.net()
|
||||
.send_data_to_existing_connection(connection_descriptor, data)
|
||||
|
@@ -521,7 +521,7 @@ impl Network {
|
||||
// Handle connection-oriented protocols
|
||||
|
||||
// Try to send to the exact existing connection if one exists
|
||||
if let Some(conn) = self.connection_manager().get_connection(descriptor).await {
|
||||
if let Some(conn) = self.connection_manager().get_connection(descriptor) {
|
||||
// connection exists, send over it
|
||||
match conn.send_async(data).await {
|
||||
ConnectionHandleSendResult::Sent => {
|
||||
|
Reference in New Issue
Block a user