mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 10:45:30 +00:00
udp: mio socket worker: make send_response plain fn
This commit is contained in:
parent
405bbaca93
commit
be5165bcf2
1 changed files with 60 additions and 58 deletions
|
|
@ -130,7 +130,7 @@ impl SocketWorker {
|
||||||
// If resend buffer is enabled, send any responses in it
|
// If resend buffer is enabled, send any responses in it
|
||||||
if let Some(resend_buffer) = self.opt_resend_buffer.as_mut() {
|
if let Some(resend_buffer) = self.opt_resend_buffer.as_mut() {
|
||||||
for (addr, response) in resend_buffer.drain(..) {
|
for (addr, response) in resend_buffer.drain(..) {
|
||||||
Self::send_response(
|
send_response(
|
||||||
&self.config,
|
&self.config,
|
||||||
&self.statistics,
|
&self.statistics,
|
||||||
&mut self.socket,
|
&mut self.socket,
|
||||||
|
|
@ -241,7 +241,7 @@ impl SocketWorker {
|
||||||
message: err.into(),
|
message: err.into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Self::send_response(
|
send_response(
|
||||||
&self.config,
|
&self.config,
|
||||||
&self.statistics,
|
&self.statistics,
|
||||||
&mut self.socket,
|
&mut self.socket,
|
||||||
|
|
@ -288,7 +288,7 @@ impl SocketWorker {
|
||||||
transaction_id: request.transaction_id,
|
transaction_id: request.transaction_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
Self::send_response(
|
send_response(
|
||||||
&self.config,
|
&self.config,
|
||||||
&self.statistics,
|
&self.statistics,
|
||||||
&mut self.socket,
|
&mut self.socket,
|
||||||
|
|
@ -324,7 +324,7 @@ impl SocketWorker {
|
||||||
message: "Info hash not allowed".into(),
|
message: "Info hash not allowed".into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Self::send_response(
|
send_response(
|
||||||
&self.config,
|
&self.config,
|
||||||
&self.statistics,
|
&self.statistics,
|
||||||
&mut self.socket,
|
&mut self.socket,
|
||||||
|
|
@ -392,7 +392,7 @@ impl SocketWorker {
|
||||||
ConnectedResponse::AnnounceIpv6(r) => Response::AnnounceIpv6(r),
|
ConnectedResponse::AnnounceIpv6(r) => Response::AnnounceIpv6(r),
|
||||||
};
|
};
|
||||||
|
|
||||||
Self::send_response(
|
send_response(
|
||||||
&self.config,
|
&self.config,
|
||||||
&self.statistics,
|
&self.statistics,
|
||||||
&mut self.socket,
|
&mut self.socket,
|
||||||
|
|
@ -403,6 +403,7 @@ impl SocketWorker {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn send_response(
|
fn send_response(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
|
|
@ -467,7 +468,8 @@ impl SocketWorker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(err) => match opt_resend_buffer.as_mut() {
|
Err(err) => {
|
||||||
|
match opt_resend_buffer.as_mut() {
|
||||||
Some(resend_buffer)
|
Some(resend_buffer)
|
||||||
if (err.raw_os_error() == Some(libc::ENOBUFS))
|
if (err.raw_os_error() == Some(libc::ENOBUFS))
|
||||||
|| (err.kind() == ErrorKind::WouldBlock) =>
|
|| (err.kind() == ErrorKind::WouldBlock) =>
|
||||||
|
|
@ -483,7 +485,7 @@ impl SocketWorker {
|
||||||
_ => {
|
_ => {
|
||||||
::log::warn!("Sending response to {} failed: {:#}", addr, err);
|
::log::warn!("Sending response to {} failed: {:#}", addr, err);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue