reorder UnsafeSerialize

pull/19792/head
Jan Tattermusch 5 years ago
parent 127d69383a
commit ec351c1ac2
  1. 1
      src/csharp/Grpc.Core.Tests/Internal/SliceBufferSafeHandleTest.cs
  2. 31
      src/csharp/Grpc.Core/Internal/AsyncCall.cs
  3. 2
      src/csharp/Grpc.Core/Internal/AsyncCallBase.cs

@ -152,7 +152,6 @@ namespace Grpc.Core.Internal.Tests
// TODO: other TODOs
// -- provide a null instance of SliceBufferSafeHandle
//-- order of UnsafeSerialize in AsyncCall methods...
private byte[] GetTestBuffer(int length)
{

@ -160,16 +160,15 @@ namespace Grpc.Core.Internal
halfcloseRequested = true;
readingDone = true;
//var payload = UnsafeSerialize(msg);
unaryResponseTcs = new TaskCompletionSource<TResponse>();
using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope())
using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers))
{
var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array?
call.StartUnary(UnaryResponseClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags);
callStartedOk = true;
var payload = UnsafeSerialize(msg, serializationScope.Context);
unaryResponseTcs = new TaskCompletionSource<TResponse>();
using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers))
{
call.StartUnary(UnaryResponseClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags);
callStartedOk = true;
}
}
return unaryResponseTcs.Task;
@ -238,17 +237,15 @@ namespace Grpc.Core.Internal
halfcloseRequested = true;
//var payload = UnsafeSerialize(msg);
streamingResponseCallFinishedTcs = new TaskCompletionSource<object>();
using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope())
using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers))
{
var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array?
call.StartServerStreaming(ReceivedStatusOnClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags);
callStartedOk = true;
var payload = UnsafeSerialize(msg, serializationScope.Context);
streamingResponseCallFinishedTcs = new TaskCompletionSource<object>();
using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers))
{
call.StartServerStreaming(ReceivedStatusOnClientCallback, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags);
callStartedOk = true;
}
}
call.StartReceiveInitialMetadata(ReceivedResponseHeadersCallback);
}

@ -117,7 +117,7 @@ namespace Grpc.Core.Internal
{
using (var serializationScope = DefaultSerializationContext.GetInitializedThreadLocalScope())
{
var payload = UnsafeSerialize(msg, serializationScope.Context); // do before metadata array?
var payload = UnsafeSerialize(msg, serializationScope.Context);
lock (myLock)
{
GrpcPreconditions.CheckState(started);

Loading…
Cancel
Save