[
https://issues.apache.org/jira/browse/THRIFT-4449?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sylwester Lachiewicz resolved THRIFT-4449.
------------------------------------------
Resolution: Fixed
The netstd named-pipe server was reworked onto async {{NamedPipeServerStream}}
({{_asyncMode}}, {{PipeOptions.Asynchronous}} —
[lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs|https://github.com/apache/thrift/blob/master/lib/netstd/Thrift/Transport/Server/TNamedPipeServerTransport.cs]
lines 68, 161-176); the synchronous blocking AcceptImpl the ticket describes
predates this rewrite. Resolving as Fixed.
> C# - TNamedPipeServerTransport.AcceptImpl can block indefinitely if
> TNamedPipeServerTransport.Close is called too quickly
> -------------------------------------------------------------------------------------------------------------------------
>
> Key: THRIFT-4449
> URL: https://issues.apache.org/jira/browse/THRIFT-4449
> Project: Thrift
> Issue Type: Bug
> Components: netstd - Library
> Affects Versions: 0.9.3, 0.11.0
> Environment: Windows 10.0.16299 64bit
> Reporter: boxcppguy
> Priority: Major
> Labels: windows
>
> What we observed is, when using the C# implementation
> TNamedPipeServerTransport along with TSimpleServer, if you call
> TSimpleServer.Stop too quickly after TSimpleServer.Serve, the call to
> evt.WaitOne in TNamedPipeServerTransport.AcceptImpl will block indefinitely
> because the lambda passed into stream.BeginWaitForConnection is never
> executed and evt.Set will never get called. We saw this in 0.9.3 but it's
> suspected to be in 0.11.0 as well.
> {noformat}
> // in server wrapper class MyServer
> lock (this.serverLock)
> {
> this.serverThread = new Thread(() =>
> {
> var processor = new MyProcessor();
> var transport = new TNamedPipeServerTransport("MyPipeName");
> var svr = new TSimpleServer(processor, transport);
> lock (this.serverLock)
> {
> this.server = svr;
> }
> svr.Serve(); // This sometimes will not return
> })
> {
> IsBackground = true
> };
> this.serverThread.Start();
> }
> {noformat}
> {noformat}
> // server wrapper class MyServer
> public void Dispose()
> {
> this.Dispose(true);
> }
> protected virtual void Dispose(bool disposing)
> {
> lock (this.serverLock)
> {
> try
> {
> if (this.server != null)
> {
> this.server.Stop();
> }
> if (this.serverThread != null)
> {
> this.serverThread.Join(); // This will wait indefinitely
> waiting for Serve to complete
> }
> }
> finally
> {
> this.server = null;
> this.serverThread = null;
> }
> }
> }
> {noformat}
> {noformat}
> // test code
> for (int i = 0; i < 100; ++i)
> {
> using (var server = new MyServer())
> {
> server.Start();
> }
> }
> {noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)