mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-04 21:37:58 +03:00
wip
This commit is contained in:
parent
fbce7d70f0
commit
ab584b034b
2 changed files with 22 additions and 25 deletions
|
@ -1,7 +1,5 @@
|
|||
use std::thread;
|
||||
|
||||
use signal_hook::consts::signal::*;
|
||||
|
||||
use crate::server::Server;
|
||||
|
||||
/// Different types of process signals
|
||||
|
@ -26,6 +24,7 @@ pub(crate) fn start<T: Send + 'static>(srv: Server<T>) {
|
|||
let _ = thread::Builder::new()
|
||||
.name("ntex-server signals".to_string())
|
||||
.spawn(move || {
|
||||
use signal_hook::consts::signal::*;
|
||||
use signal_hook::iterator::Signals;
|
||||
|
||||
let sigs = vec![SIGHUP, SIGINT, SIGTERM, SIGQUIT];
|
||||
|
|
|
@ -335,31 +335,29 @@ impl Accept {
|
|||
ServerStatus::Ready
|
||||
});
|
||||
|
||||
if self.backpressure {
|
||||
if !on {
|
||||
// handle backlog
|
||||
while let Some(msg) = self.backlog.pop_front() {
|
||||
if let Err(msg) = self.srv.process(msg) {
|
||||
log::trace!("Server is unavailable");
|
||||
self.backlog.push_front(msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// re-enable acceptors
|
||||
self.backpressure = false;
|
||||
for (key, info) in self.sockets.iter().enumerate() {
|
||||
if info.timeout.get().is_none() {
|
||||
// socket with timeout will re-register itself after timeout
|
||||
log::info!(
|
||||
"Resuming socket listener on {} after back-pressure",
|
||||
info.addr
|
||||
);
|
||||
self.add_source(key);
|
||||
}
|
||||
if self.backpressure && !on {
|
||||
// handle backlog
|
||||
while let Some(msg) = self.backlog.pop_front() {
|
||||
if let Err(msg) = self.srv.process(msg) {
|
||||
log::trace!("Server is unavailable");
|
||||
self.backlog.push_front(msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if on {
|
||||
|
||||
// re-enable acceptors
|
||||
self.backpressure = false;
|
||||
for (key, info) in self.sockets.iter().enumerate() {
|
||||
if info.timeout.get().is_none() {
|
||||
// socket with timeout will re-register itself after timeout
|
||||
log::info!(
|
||||
"Resuming socket listener on {} after back-pressure",
|
||||
info.addr
|
||||
);
|
||||
self.add_source(key);
|
||||
}
|
||||
}
|
||||
} else if !self.backpressure && on {
|
||||
self.backpressure = true;
|
||||
for key in 0..self.sockets.len() {
|
||||
// disable err timeout
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue