@@ -167,12 +167,16 @@ void response_promise::state::cancel() {
167
167
void response_promise::state::deliver_impl (message msg) {
168
168
CAF_LOG_TRACE (CAF_ARG (msg));
169
169
auto cancel_guard = detail::make_scope_guard ([this ] {
170
- cancel ();
171
- });
170
+ cancel ();
171
+ });
172
172
if (msg.empty () && id.is_async ()) {
173
173
CAF_LOG_DEBUG (" drop response: empty response to asynchronous input" );
174
174
return ;
175
175
}
176
+ if (source == nullptr ) {
177
+ CAF_LOG_DEBUG (" drop response: source is nullptr" );
178
+ return ;
179
+ }
176
180
auto self = weak_self.lock ();
177
181
if (self == nullptr ) {
178
182
auto element = make_mailbox_element (self, id.response_id (),
@@ -181,15 +185,14 @@ void response_promise::state::deliver_impl(message msg) {
181
185
source->enqueue (std::move (element), nullptr );
182
186
return ;
183
187
}
184
- auto local_self = static_cast <local_actor*>(weak_self. get () ->get ());
188
+ auto local_self = static_cast <local_actor*>(self ->get ());
185
189
if (!stages.empty ()) {
186
190
auto next = std::move (stages.back ());
187
191
stages.pop_back ();
188
192
detail::profiled_send (local_self, std::move (source), next, id, std::move (stages),
189
193
local_self->context (), std::move (msg));
190
194
return ;
191
195
}
192
- CAF_ASSERT (source != nullptr );
193
196
detail::profiled_send (local_self, local_self->ctrl (), source, id.response_id (),
194
197
forwarding_stack{}, local_self->context (), std::move (msg));
195
198
}
0 commit comments