File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -966,6 +966,15 @@ namespace Aws
966
966
int errorCode =
967
967
EventStreamCppToNativeCrtBuilder::s_fillNativeHeadersArray (headers, &headersArray, m_allocator);
968
968
969
+ /*
970
+ * Regardless of how the promise gets moved around (or not), this future should stay valid as a return
971
+ * value.
972
+ *
973
+ * We pull it out early because the call to aws_event_stream_rpc_client_continuation_activate() may complete
974
+ * and delete the promise before we pull out the future afterwords.
975
+ */
976
+ std::future<RpcError> retValue = onFlushPromise.get_future ();
977
+
969
978
if (!errorCode)
970
979
{
971
980
struct aws_event_stream_rpc_message_args msg_args;
@@ -1001,12 +1010,8 @@ namespace Aws
1001
1010
onFlushPromise.set_value ({EVENT_STREAM_RPC_CRT_ERROR, errorCode});
1002
1011
Crt::Delete (callbackContainer, m_allocator);
1003
1012
}
1004
- else
1005
- {
1006
- return callbackContainer->onFlushPromise .get_future ();
1007
- }
1008
1013
1009
- return onFlushPromise. get_future () ;
1014
+ return retValue ;
1010
1015
}
1011
1016
1012
1017
std::future<RpcError> ClientContinuation::SendMessage (
@@ -1588,4 +1593,4 @@ namespace Aws
1588
1593
}
1589
1594
1590
1595
} /* namespace Eventstreamrpc */
1591
- } // namespace Aws
1596
+ } // namespace Aws
You can’t perform that action at this time.
0 commit comments