thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "boxcppguy (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (THRIFT-4449) C# - TNamedPipeServerTransport.AcceptImpl can block indefinitely if TNamedPipeServerTransport.Close is called too quickly
Date Thu, 11 Jan 2018 01:10:00 GMT

     [ https://issues.apache.org/jira/browse/THRIFT-4449?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

boxcppguy updated THRIFT-4449:
------------------------------
    Description: 
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}

  was:
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
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}


> 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
>         Environment: Windows 10.0.16299 64bit
>            Reporter: boxcppguy
>
> 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
(v6.4.14#64029)

Mime
View raw message