Skip to content

Commit

Permalink
Fix port session premature close when local server is not connected b…
Browse files Browse the repository at this point in the history
  • Loading branch information
yuting-fan authored and gianniLesl committed May 27, 2022
1 parent a225d1e commit 688339c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
5 changes: 1 addition & 4 deletions agent/session/plugins/port/port_mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,8 @@ func (p *MuxPortSession) initialize() (err error) {
}
log.Debugf("Accepted a connection %s\n", conn.LocalAddr())

config := smux.DefaultConfig()
// Disable smux KeepAlive or else it breaks Session Manager idle timeout.
config.KeepAliveDisabled = true
var session *smux.Session
if session, err = smux.Server(conn, config); err != nil {
if session, err = smux.Server(conn, nil); err != nil {
log.Errorf("Unable to setup smux server: %v", err)
return err
}
Expand Down
12 changes: 3 additions & 9 deletions agent/session/plugins/port/port_mux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ func (suite *MuxPortTestSuite) TestWritePumpFailsToRead() {
suite.mockDataChannel.On("IsActive").Return(true)

out, in := net.Pipe()
config := smux.DefaultConfig()
config.KeepAliveDisabled = true
session, _ := smux.Server(in, config)
session, _ := smux.Server(in, nil)
defer session.Close()
defer in.Close()
out.Close()
Expand All @@ -122,9 +120,7 @@ func (suite *MuxPortTestSuite) TestWritePumpWhenDatachannelIsNotActive() {
suite.mockDataChannel.On("IsActive").Return(false)

out, in := net.Pipe()
config := smux.DefaultConfig()
config.KeepAliveDisabled = true
session, _ := smux.Server(in, config)
session, _ := smux.Server(in, nil)
defer session.Close()
defer out.Close()

Expand All @@ -151,9 +147,7 @@ func (suite *MuxPortTestSuite) TestWritePump() {
suite.mockDataChannel.On("SendStreamDataMessage", suite.mockContext.Log(), mgsContracts.Output, payload).Return(nil)

out, in := net.Pipe()
config := smux.DefaultConfig()
config.KeepAliveDisabled = true
session, _ := smux.Server(in, config)
session, _ := smux.Server(in, nil)
defer session.Close()
defer out.Close()

Expand Down

0 comments on commit 688339c

Please sign in to comment.