Unverified Commit 548a3721 authored by Dennis Jenkins's avatar Dennis Jenkins Committed by GitHub

Merge pull request #636 from DmtKats/master

Fix for segmentation fault caused by incorrect lambda capture in promise
parents f0b86b0e 582c04fe
...@@ -570,15 +570,18 @@ namespace Async { ...@@ -570,15 +570,18 @@ namespace Async {
template<typename P> template<typename P>
void finishResolve(P& promise) { void finishResolve(P& promise) {
auto chainer = makeChainer(promise); auto chainer = makeChainer(promise);
promise.then(std::move(chainer), [=](std::exception_ptr exc) { std::weak_ptr<Core> weakPtr = this->chain_;
auto core = this->chain_; promise.then(std::move(chainer), [weakPtr](std::exception_ptr exc) {
core->exc = std::move(exc); if (auto core = weakPtr.lock()) {
core->state = State::Rejected; core->exc = std::move(exc);
core->state = State::Rejected;
for (const auto& req: core->requests) {
req->reject(core); for (const auto& req: core->requests) {
req->reject(core);
}
} }
}); });
} }
Resolve resolve_; Resolve resolve_;
......
...@@ -287,7 +287,7 @@ Transport::asyncWriteImpl(Fd fd) ...@@ -287,7 +287,7 @@ Transport::asyncWriteImpl(Fd fd)
// EBADF can happen when the HTTP parser, in the case of // EBADF can happen when the HTTP parser, in the case of
// an error, closes fd before the entire request is processed. // an error, closes fd before the entire request is processed.
// https://github.com/oktal/pistache/issues/501 // https://github.com/oktal/pistache/issues/501
else if (errno == EBADF) { else if (errno == EBADF || errno == EPIPE || errno == ECONNRESET) {
wq.pop_front(); wq.pop_front();
toWrite.erase(fd); toWrite.erase(fd);
stop = true; stop = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment