Skip to content

Commit

Permalink
Update Objective-C on error/cancel to include final_stream_intel (#1954)
Browse files Browse the repository at this point in the history
Description: This is a followup to #1937.
Risk Level: I believe these extra parameters are safe to ignore if we don't need to propagate them to the Objective-C interface, but would like someone else to confirm that. (Confirmed.)
Testing: Example apps still work, and downstream (closed source) consumers now compile again.

Signed-off-by: JP Simard <jp@jpsim.com>
  • Loading branch information
jpsim authored and Jose Nino committed Dec 15, 2021
1 parent 502ccb2 commit e07a0bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
5 changes: 4 additions & 1 deletion library/objective-c/EnvoyEngineImpl.m
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ static void ios_http_filter_set_response_callbacks(envoy_http_filter_callbacks c
}
}

static void ios_http_filter_on_cancel(envoy_stream_intel stream_intel, const void *context) {
static void ios_http_filter_on_cancel(envoy_stream_intel stream_intel,
envoy_final_stream_intel final_stream_intel,
const void *context) {
// This code block runs inside the Envoy event loop. Therefore, an explicit autoreleasepool block
// is necessary to act as a breaker for any Objective-C allocation that happens.
@autoreleasepool {
Expand All @@ -345,6 +347,7 @@ static void ios_http_filter_on_cancel(envoy_stream_intel stream_intel, const voi
}

static void ios_http_filter_on_error(envoy_error error, envoy_stream_intel stream_intel,
envoy_final_stream_intel final_stream_intel,
const void *context) {
// This code block runs inside the Envoy event loop. Therefore, an explicit autoreleasepool block
// is necessary to act as a breaker for any Objective-C allocation that happens.
Expand Down
22 changes: 15 additions & 7 deletions library/objective-c/EnvoyHTTPStreamImpl.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
return NULL;
}

static void *ios_on_complete(envoy_stream_intel stream_intel, void *context) {
static void *ios_on_complete(envoy_stream_intel stream_intel,
envoy_final_stream_intel final_stream_intel, void *context) {
ios_context *c = (ios_context *)context;
EnvoyHTTPCallbacks *callbacks = c->callbacks;
EnvoyHTTPStreamImpl *stream = c->stream;
Expand All @@ -74,7 +75,13 @@
return NULL;
}

static void *ios_on_cancel(envoy_stream_intel stream_intel, void *context) {
// TODO(goaway) fix this up to call ios_on_send_window_available
static void *ios_on_send_window_available(envoy_stream_intel stream_intel, void *context) {
return NULL;
}

static void *ios_on_cancel(envoy_stream_intel stream_intel,
envoy_final_stream_intel final_stream_intel, void *context) {
// This call is atomically gated at the call-site and will only happen once. It may still fire
// after a complete response or error callback, but no other callbacks for the stream will ever
// fire AFTER the cancellation callback.
Expand All @@ -93,7 +100,8 @@
return NULL;
}

static void *ios_on_error(envoy_error error, envoy_stream_intel stream_intel, void *context) {
static void *ios_on_error(envoy_error error, envoy_stream_intel stream_intel,
envoy_final_stream_intel final_stream_intel, void *context) {
ios_context *c = (ios_context *)context;
EnvoyHTTPCallbacks *callbacks = c->callbacks;
EnvoyHTTPStreamImpl *stream = c->stream;
Expand Down Expand Up @@ -142,10 +150,10 @@ - (instancetype)initWithHandle:(envoy_stream_t)handle
atomic_store(context->closed, NO);

// Create native callbacks
// TODO(goaway) fix this up to call ios_on_send_window_available
envoy_http_callbacks native_callbacks = {ios_on_headers, ios_on_data, ios_on_metadata,
ios_on_trailers, ios_on_error, ios_on_complete,
ios_on_cancel, ios_on_cancel, context};
envoy_http_callbacks native_callbacks = {
ios_on_headers, ios_on_data, ios_on_metadata, ios_on_trailers,
ios_on_error, ios_on_complete, ios_on_cancel, ios_on_send_window_available,
context};
_nativeCallbacks = native_callbacks;

// We need create the native-held strong ref on this stream before we call start_stream because
Expand Down

0 comments on commit e07a0bc

Please sign in to comment.