Make sure the deffered objects stay in scope when we call into callback in tagger.
This commit is contained in:
parent
0d2ea8aa72
commit
c2e0cc57eb
|
|
@ -60,9 +60,11 @@ void Tagger::onAck(uint64_t deliveryTag, bool multiple)
|
||||||
if (!_close || unacknowledged()) return;
|
if (!_close || unacknowledged()) return;
|
||||||
|
|
||||||
// close the channel, and forward the callbacks to the installed handler
|
// close the channel, and forward the callbacks to the installed handler
|
||||||
|
// we need to be sure the the deffered object stays alive even if the callback
|
||||||
|
// decides to remove us.
|
||||||
_implementation->close()
|
_implementation->close()
|
||||||
.onSuccess([this]() { _close->reportSuccess(); })
|
.onSuccess([this]() { auto close = _close; close->reportSuccess(); })
|
||||||
.onError([this](const char *message) { _close->reportError(message); });
|
.onError([this](const char *message) { auto close = _close; close->reportError(message); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -76,9 +78,11 @@ void Tagger::onNack(uint64_t deliveryTag, bool multiple)
|
||||||
if (!_close || unacknowledged()) return;
|
if (!_close || unacknowledged()) return;
|
||||||
|
|
||||||
// close the channel, and forward the callbacks to the installed handler
|
// close the channel, and forward the callbacks to the installed handler
|
||||||
|
// we need to be sure the the deffered object stays alive even if the callback
|
||||||
|
// decides to remove us.
|
||||||
_implementation->close()
|
_implementation->close()
|
||||||
.onSuccess([this]() { _close->reportSuccess(); })
|
.onSuccess([this]() { auto close = _close; close->reportSuccess(); })
|
||||||
.onError([this](const char *message) { _close->reportError(message); });
|
.onError([this](const char *message) { auto close = _close; close->reportError(message); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -164,9 +168,11 @@ Deferred &Tagger::close()
|
||||||
if (unacknowledged()) return *_close;
|
if (unacknowledged()) return *_close;
|
||||||
|
|
||||||
// there are no open messages, we can close the channel directly.
|
// there are no open messages, we can close the channel directly.
|
||||||
|
// we need to be sure the the deffered object stays alive even if the callback
|
||||||
|
// decides to remove us.
|
||||||
_implementation->close()
|
_implementation->close()
|
||||||
.onSuccess([this]() { _close->reportSuccess(); })
|
.onSuccess([this]() { auto close = _close; close->reportSuccess(); })
|
||||||
.onError([this](const char *message) { _close->reportError(message); });
|
.onError([this](const char *message) { auto close = _close; close->reportError(message); });
|
||||||
|
|
||||||
// return the created deferred
|
// return the created deferred
|
||||||
return *_close;
|
return *_close;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue