mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-05 05:47:40 +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 std::thread;
|
||||||
|
|
||||||
use signal_hook::consts::signal::*;
|
|
||||||
|
|
||||||
use crate::server::Server;
|
use crate::server::Server;
|
||||||
|
|
||||||
/// Different types of process signals
|
/// Different types of process signals
|
||||||
|
@ -26,6 +24,7 @@ pub(crate) fn start<T: Send + 'static>(srv: Server<T>) {
|
||||||
let _ = thread::Builder::new()
|
let _ = thread::Builder::new()
|
||||||
.name("ntex-server signals".to_string())
|
.name("ntex-server signals".to_string())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
|
use signal_hook::consts::signal::*;
|
||||||
use signal_hook::iterator::Signals;
|
use signal_hook::iterator::Signals;
|
||||||
|
|
||||||
let sigs = vec![SIGHUP, SIGINT, SIGTERM, SIGQUIT];
|
let sigs = vec![SIGHUP, SIGINT, SIGTERM, SIGQUIT];
|
||||||
|
|
|
@ -335,31 +335,29 @@ impl Accept {
|
||||||
ServerStatus::Ready
|
ServerStatus::Ready
|
||||||
});
|
});
|
||||||
|
|
||||||
if self.backpressure {
|
if self.backpressure && !on {
|
||||||
if !on {
|
// handle backlog
|
||||||
// handle backlog
|
while let Some(msg) = self.backlog.pop_front() {
|
||||||
while let Some(msg) = self.backlog.pop_front() {
|
if let Err(msg) = self.srv.process(msg) {
|
||||||
if let Err(msg) = self.srv.process(msg) {
|
log::trace!("Server is unavailable");
|
||||||
log::trace!("Server is unavailable");
|
self.backlog.push_front(msg);
|
||||||
self.backlog.push_front(msg);
|
return;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} 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;
|
self.backpressure = true;
|
||||||
for key in 0..self.sockets.len() {
|
for key in 0..self.sockets.len() {
|
||||||
// disable err timeout
|
// disable err timeout
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue