hashicorp/yamux

The server should handle GoAway frames

ginkoob opened this issue · 6 comments

Currently GoAway is handled only on Session.Open. However there is also the case when the client sends a GoAway request. In that case the server should handle it on Accept(). A common use case is when the the client acts as a "server" (also known as back connection/ reverse connection)

armon commented

I think we do still handle it. The recv() loop should cause the session to shutdown I believe

I think that's wrong though, isn't it? It should error ErrRemoteGoAway. Here is a test of the expected behavior(currently failing/deadlock):

func TestGoAwayClient(t *testing.T) {
client, server := testClientServer()
defer client.Close()
defer server.Close()
go func(){
if err := client.GoAway(); err != nil {
t.Fatalf("err: %v", err)
}
}()
_, err := server.Accept()
if err != ErrRemoteGoAway {
t.Fatalf("err: %v", err)
}
}

@armon I've submitted a PR. It would be great if you could have a look. It works but sometimes client2.GoAway()[0] fails (with shutdown error) for reasons I don't know though I don't think it's due the PR changes either.

[0] https://github.com/hashicorp/yamux/pull/18/files#diff-7f24d50c1e949c023a423eec758d017bR374

@armon is this ticket still valid ?

armon commented

@marco-m I'm not sure. I'm not close enough anymore. Would require somebody to spend some time digging into this.

@armon thanks for answering!