mirror of
https://github.com/actix/actix-web.git
synced 2024-12-21 15:46:48 +00:00
stop actor context on error #311
This commit is contained in:
parent
00c97504b6
commit
110605f50b
2 changed files with 22 additions and 10 deletions
|
@ -580,6 +580,7 @@ impl<S: 'static, H> ProcessResponse<S, H> {
|
|||
Frame::Chunk(Some(chunk)) => {
|
||||
match io.write(&chunk) {
|
||||
Err(err) => {
|
||||
info.context = Some(ctx);
|
||||
info.error = Some(err.into());
|
||||
return Ok(
|
||||
FinishingMiddlewares::init(
|
||||
|
@ -606,6 +607,7 @@ impl<S: 'static, H> ProcessResponse<S, H> {
|
|||
break;
|
||||
}
|
||||
Err(err) => {
|
||||
info.context = Some(ctx);
|
||||
info.error = Some(err);
|
||||
return Ok(FinishingMiddlewares::init(
|
||||
info, mws, self.resp,
|
||||
|
@ -641,6 +643,12 @@ impl<S: 'static, H> ProcessResponse<S, H> {
|
|||
}
|
||||
Ok(Async::NotReady) => return Err(PipelineState::Response(self)),
|
||||
Err(err) => {
|
||||
if let IOState::Actor(mut ctx) =
|
||||
mem::replace(&mut self.iostate, IOState::Done)
|
||||
{
|
||||
ctx.disconnected();
|
||||
info.context = Some(ctx);
|
||||
}
|
||||
info.error = Some(err.into());
|
||||
return Ok(FinishingMiddlewares::init(info, mws, self.resp));
|
||||
}
|
||||
|
@ -755,8 +763,14 @@ impl<S, H> Completed<S, H> {
|
|||
if info.context.is_none() {
|
||||
PipelineState::None
|
||||
} else {
|
||||
match info.poll_context() {
|
||||
Ok(Async::NotReady) => {
|
||||
PipelineState::Completed(Completed(PhantomData, PhantomData))
|
||||
}
|
||||
Ok(Async::Ready(())) => PipelineState::None,
|
||||
Err(_) => PipelineState::Error,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -127,8 +127,8 @@ where
|
|||
fn notify_disconnect(&mut self) {
|
||||
// notify all tasks
|
||||
self.stream.disconnected();
|
||||
for entry in &mut self.tasks {
|
||||
entry.pipe.disconnected()
|
||||
for task in &mut self.tasks {
|
||||
task.pipe.disconnected();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,6 +239,7 @@ where
|
|||
if let Ok(Async::NotReady) = self.stream.poll_completed(true) {
|
||||
return Ok(Async::NotReady);
|
||||
}
|
||||
self.flags.insert(Flags::ERROR);
|
||||
return Err(());
|
||||
}
|
||||
|
||||
|
@ -272,14 +273,10 @@ where
|
|||
Err(err) => {
|
||||
// it is not possible to recover from error
|
||||
// during pipe handling, so just drop connection
|
||||
error!("Unhandled error: {}", err);
|
||||
self.notify_disconnect();
|
||||
self.tasks[idx].flags.insert(EntryFlags::ERROR);
|
||||
|
||||
// check stream state, we still can have valid data in buffer
|
||||
if let Ok(Async::NotReady) = self.stream.poll_completed(true) {
|
||||
return Ok(Async::NotReady);
|
||||
}
|
||||
return Err(());
|
||||
error!("Unhandled error1: {}", err);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else if !self.tasks[idx].flags.contains(EntryFlags::FINISHED) {
|
||||
|
@ -292,6 +289,7 @@ where
|
|||
self.notify_disconnect();
|
||||
self.tasks[idx].flags.insert(EntryFlags::ERROR);
|
||||
error!("Unhandled error: {}", err);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue