diff --git a/vst/authentication.go b/vst/authentication.go index 97a66dab..4a9d4de4 100644 --- a/vst/authentication.go +++ b/vst/authentication.go @@ -141,7 +141,7 @@ func (a *vstAuthenticationImpl) PrepareFunc(vstConn *vstConnection) func(ctx con // Wait for response m := <-respChan - resp, err := newResponse(m, "", nil) + resp, err := newResponse(m.Data, "", nil) if err != nil { return driver.WithStack(err) } diff --git a/vst/connection.go b/vst/connection.go index cb8254d3..456ca6b1 100644 --- a/vst/connection.go +++ b/vst/connection.go @@ -183,7 +183,7 @@ func (c *vstConnection) do(ctx context.Context, req driver.Request, transport me } } - vstResp, err := newResponse(msg, c.endpoint.String(), rawResponse) + vstResp, err := newResponse(msg.Data, c.endpoint.String(), rawResponse) if err != nil { fmt.Printf("Cannot decode msg %d: %#v\n", msg.ID, err) return nil, driver.WithStack(err) diff --git a/vst/protocol/connection.go b/vst/protocol/connection.go index d1af33c4..71b57853 100644 --- a/vst/protocol/connection.go +++ b/vst/protocol/connection.go @@ -230,7 +230,7 @@ func (c *Connection) readChunkLoop() { if err != nil { if !c.IsClosed() { // Handle error - if err == io.EOF { + if driver.Cause(err) == io.EOF { // Connection closed c.Close() } else { @@ -286,5 +286,5 @@ func (c *Connection) updateLastActivity() { // IsIdle returns true when the last activity was more than the given timeout ago. func (c *Connection) IsIdle(idleTimeout time.Duration) bool { - return time.Since(c.lastActivity) > idleTimeout + return time.Since(c.lastActivity) > idleTimeout && c.msgStore.Size() == 0 } diff --git a/vst/protocol/transport.go b/vst/protocol/transport.go index 36192c88..10542818 100644 --- a/vst/protocol/transport.go +++ b/vst/protocol/transport.go @@ -228,7 +228,7 @@ func (c *Transport) createConnection() (*Connection, error) { func (c *Transport) cleanup() { for { time.Sleep(c.IdleConnTimeout / 10) - remaining, _ := c.CloseIdleConnections() + _, remaining := c.CloseIdleConnections() if remaining == 0 { return } diff --git a/vst/response.go b/vst/response.go index e290e6c1..2beb225b 100644 --- a/vst/response.go +++ b/vst/response.go @@ -28,7 +28,6 @@ import ( "sync" driver "github.com/arangodb/go-driver" - "github.com/arangodb/go-driver/vst/protocol" velocypack "github.com/arangodb/go-velocypack" ) @@ -46,9 +45,9 @@ type vstResponse struct { } // newResponse builds a vstResponse from given message. -func newResponse(msg protocol.Message, endpoint string, rawResponse *[]byte) (*vstResponse, error) { +func newResponse(msgData []byte, endpoint string, rawResponse *[]byte) (*vstResponse, error) { // Decode header - hdr := velocypack.Slice(msg.Data) + hdr := velocypack.Slice(msgData) if err := hdr.AssertType(velocypack.Array); err != nil { return nil, driver.WithStack(err) }