This is an automated email from the ASF dual-hosted git repository. jensg pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/thrift.git
The following commit(s) were added to refs/heads/master by this push: new fc52c3c THRIFT-4673 IAsyncResult not supported by layered transports (buffered/framed) Client: C# Patch: Jens Geyer fc52c3c is described below commit fc52c3cceed1070d8c618d18a1abd0a437cf0295 Author: Jens Geyer <je...@apache.org> AuthorDate: Fri Nov 23 01:44:02 2018 +0100 THRIFT-4673 IAsyncResult not supported by layered transports (buffered/framed) Client: C# Patch: Jens Geyer This closes #1634 --- lib/csharp/src/Transport/TBufferedTransport.cs | 27 +++++++++++++++++++++++--- lib/csharp/src/Transport/TFramedTransport.cs | 21 +++++++++++++++++++- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/lib/csharp/src/Transport/TBufferedTransport.cs b/lib/csharp/src/Transport/TBufferedTransport.cs index 76c6b1a..8870988 100644 --- a/lib/csharp/src/Transport/TBufferedTransport.cs +++ b/lib/csharp/src/Transport/TBufferedTransport.cs @@ -81,7 +81,7 @@ namespace Thrift.Transport inputBuffer.Capacity = bufSize; while (true) - { + { int got = inputBuffer.Read(buf, off, len); if (got > 0) return got; @@ -129,9 +129,8 @@ namespace Thrift.Transport } } - public override void Flush() + private void InternalFlush() { - CheckNotDisposed(); if (!IsOpen) throw new TTransportException(TTransportException.ExceptionType.NotOpen); if (outputBuffer.Length > 0) @@ -139,9 +138,31 @@ namespace Thrift.Transport transport.Write(outputBuffer.GetBuffer(), 0, (int)outputBuffer.Length); outputBuffer.SetLength(0); } + } + + public override void Flush() + { + CheckNotDisposed(); + InternalFlush(); + transport.Flush(); } + public override IAsyncResult BeginFlush(AsyncCallback callback, object state) + { + CheckNotDisposed(); + InternalFlush(); + + return transport.BeginFlush( callback, state); + } + + public override void EndFlush(IAsyncResult asyncResult) + { + transport.EndFlush( asyncResult); + } + + + protected void CheckNotDisposed() { if (_IsDisposed) diff --git a/lib/csharp/src/Transport/TFramedTransport.cs b/lib/csharp/src/Transport/TFramedTransport.cs index 3436cc6..a746a32 100644 --- a/lib/csharp/src/Transport/TFramedTransport.cs +++ b/lib/csharp/src/Transport/TFramedTransport.cs @@ -108,7 +108,7 @@ namespace Thrift.Transport writeBuffer.Write(buf, off, len); } - public override void Flush() + private void InternalFlush() { CheckNotDisposed(); if (!IsOpen) @@ -126,10 +126,29 @@ namespace Thrift.Transport transport.Write(buf, 0, len); InitWriteBuffer(); + } + + public override void Flush() + { + CheckNotDisposed(); + InternalFlush(); transport.Flush(); } + public override IAsyncResult BeginFlush(AsyncCallback callback, object state) + { + CheckNotDisposed(); + InternalFlush(); + + return transport.BeginFlush( callback, state); + } + + public override void EndFlush(IAsyncResult asyncResult) + { + transport.EndFlush( asyncResult); + } + private void InitWriteBuffer() { // Reserve space for message header to be put right before sending it out