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 {
template<typename P>
void finishResolve(P& promise) {
auto chainer = makeChainer(promise);
promise.then(std::move(chainer), [=](std::exception_ptr exc) {
auto core = this->chain_;
core->exc = std::move(exc);
core->state = State::Rejected;
for (const auto& req: core->requests) {
req->reject(core);
std::weak_ptr<Core> weakPtr = this->chain_;
promise.then(std::move(chainer), [weakPtr](std::exception_ptr exc) {
if (auto core = weakPtr.lock()) {
core->exc = std::move(exc);
core->state = State::Rejected;
for (const auto& req: core->requests) {
req->reject(core);
}
}
});
}
Resolve resolve_;
......
......@@ -287,7 +287,7 @@ Transport::asyncWriteImpl(Fd fd)
// EBADF can happen when the HTTP parser, in the case of
// an error, closes fd before the entire request is processed.
// https://github.com/oktal/pistache/issues/501
else if (errno == EBADF) {
else if (errno == EBADF || errno == EPIPE || errno == ECONNRESET) {
wq.pop_front();
toWrite.erase(fd);
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