From 8ebba4ecc6375e9048de108dc74ec74ce4d2b365 Mon Sep 17 00:00:00 2001 From: arcadia-devtools Date: Wed, 5 Aug 2020 15:14:08 +0300 Subject: [PATCH] sync upstream ref:f822f0be6169f6f5f8d7990163a001723d62fd67 --- table/session.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/table/session.go b/table/session.go index e65e546..f373480 100644 --- a/table/session.go +++ b/table/session.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "io" + "sync" "time" "github.com/yandex-cloud/ydb-go-sdk" @@ -76,11 +77,14 @@ type Session struct { qcache lru.Cache qhash queryHasher - closed bool - onClose []func() + closeMux sync.Mutex + closed bool + onClose []func() } func (s *Session) OnClose(cb func()) { + s.closeMux.Lock() + defer s.closeMux.Unlock() if s.closed { return } @@ -88,6 +92,8 @@ func (s *Session) OnClose(cb func()) { } func (s *Session) Close(ctx context.Context) (err error) { + s.closeMux.Lock() + defer s.closeMux.Unlock() if s.closed { return nil }