Skip to content

Commit

Permalink
THRIFT-4183: Named pipe client blocks forever on Open() when there is…
Browse files Browse the repository at this point in the history
… no server at the other end

Client: C#
Patch: Jens Geyer

This closes #1258
  • Loading branch information
Jens-G committed Apr 26, 2017
1 parent 3311a9b commit 9db23b7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/csharp/src/Transport/TNamedPipeClientTransport.cs
Expand Up @@ -22,6 +22,7 @@
*/

using System.IO.Pipes;
using System.Threading;

namespace Thrift.Transport
{
Expand All @@ -30,17 +31,20 @@ public class TNamedPipeClientTransport : TTransport
private NamedPipeClientStream client;
private string ServerName;
private string PipeName;
private int ConnectTimeout;

public TNamedPipeClientTransport(string pipe)
public TNamedPipeClientTransport(string pipe, int timeout = Timeout.Infinite)
{
ServerName = ".";
PipeName = pipe;
ConnectTimeout = timeout;
}

public TNamedPipeClientTransport(string server, string pipe)
public TNamedPipeClientTransport(string server, string pipe, int timeout = Timeout.Infinite)
{
ServerName = (server != "") ? server : ".";
PipeName = pipe;
ConnectTimeout = timeout;
}

public override bool IsOpen
Expand All @@ -55,7 +59,7 @@ public override void Open()
throw new TTransportException(TTransportException.ExceptionType.AlreadyOpen);
}
client = new NamedPipeClientStream(ServerName, PipeName, PipeDirection.InOut, PipeOptions.None);
client.Connect();
client.Connect(ConnectTimeout);
}

public override void Close()
Expand Down

0 comments on commit 9db23b7

Please sign in to comment.