[ 
https://issues.apache.org/jira/browse/THRIFT-4449?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16539430#comment-16539430
 ] 

boxcppguy commented on THRIFT-4449:
-----------------------------------

Wondering if there's been any movement on this issue. We've had to fork the 
named pipe implementation but would prefer to use the Apache maintained 
versions.

> 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: C# - Library
>    Affects Versions: 0.9.3, 0.11.0
>         Environment: Windows 10.0.16299 64bit
>            Reporter: boxcppguy
>            Priority: Major
>
> 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
(v7.6.3#76005)

Reply via email to