aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-01-23 07:48:42 -0800
committerGravatar Craig Tiller <ctiller@google.com>2017-01-23 07:48:42 -0800
commit7c70b6c144a20782b6be4751da68c6aa7b35648d (patch)
treef8ca929338d9f73cd9eec35001ecf52e3b1f6c1b /src/objective-c/GRPCClient/private/GRPCWrappedCall.m
parentc7342a01bb069fcff6df0e22f6c2a403010998a1 (diff)
Revert "Revert "Metadata handling rewrite""
Diffstat (limited to 'src/objective-c/GRPCClient/private/GRPCWrappedCall.m')
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.m19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
index 38fcae0299..43c564552b 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
@@ -194,7 +194,7 @@
@implementation GRPCOpRecvStatus{
grpc_status_code _statusCode;
- char *_details;
+ grpc_slice _details;
size_t _detailsCapacity;
grpc_metadata_array _trailers;
}
@@ -208,7 +208,6 @@
_op.op = GRPC_OP_RECV_STATUS_ON_CLIENT;
_op.data.recv_status_on_client.status = &_statusCode;
_op.data.recv_status_on_client.status_details = &_details;
- _op.data.recv_status_on_client.status_details_capacity = &_detailsCapacity;
grpc_metadata_array_init(&_trailers);
_op.data.recv_status_on_client.trailing_metadata = &_trailers;
if (handler) {
@@ -216,11 +215,15 @@
__weak typeof(self) weakSelf = self;
_handler = ^{
__strong typeof(self) strongSelf = weakSelf;
- NSError *error = [NSError grpc_errorFromStatusCode:strongSelf->_statusCode
- details:strongSelf->_details];
- NSDictionary *trailers = [NSDictionary
- grpc_dictionaryFromMetadataArray:strongSelf->_trailers];
- handler(error, trailers);
+ if (strongSelf) {
+ char *details = grpc_slice_to_c_string(strongSelf->_details);
+ NSError *error = [NSError grpc_errorFromStatusCode:strongSelf->_statusCode
+ details:details];
+ NSDictionary *trailers = [NSDictionary
+ grpc_dictionaryFromMetadataArray:strongSelf->_trailers];
+ handler(error, trailers);
+ gpr_free(details);
+ }
};
}
}
@@ -229,7 +232,7 @@
- (void)dealloc {
grpc_metadata_array_destroy(&_trailers);
- gpr_free(_details);
+ grpc_slice_unref(_details);
}
@end