summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Geyer <jensg@apache.org>2018-11-23 01:44:02 +0100
committerJens Geyer <jensg@apache.org>2018-11-24 02:08:20 +0100
commitfc52c3cceed1070d8c618d18a1abd0a437cf0295 (patch)
tree5618301021623743a6aea022cd2e34ad3ae8dc50
parent7abb7d5fbc700db2338719bc88b7f4b10304942b (diff)
downloadthrift-fc52c3cceed1070d8c618d18a1abd0a437cf0295.tar.gz
THRIFT-4673 IAsyncResult not supported by layered transports (buffered/framed)
Client: C# Patch: Jens Geyer This closes #1634
-rw-r--r--lib/csharp/src/Transport/TBufferedTransport.cs27
-rw-r--r--lib/csharp/src/Transport/TFramedTransport.cs21
2 files changed, 44 insertions, 4 deletions
diff --git a/lib/csharp/src/Transport/TBufferedTransport.cs b/lib/csharp/src/Transport/TBufferedTransport.cs
index 76c6b1a7b..887098810 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 3436cc6fe..a746a3223 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