diff --git a/postgres_stek/postgres_stek.go b/postgres_stek/postgres_stek.go index a893dfaa..536afbcb 100644 --- a/postgres_stek/postgres_stek.go +++ b/postgres_stek/postgres_stek.go @@ -111,12 +111,11 @@ func Connect_err(Connection connections.Connection) error { } mutex_Connect.Lock() //race + defer mutex_Connect.Unlock() MapConnection[Connection.ID] = Connection MapConn[Connection.ID] = Conn - mutex_Connect.Unlock() - return err } @@ -252,12 +251,11 @@ func CloseConnection_err(Connection connections.Connection) error { Conn = nil mutex_Connect.Lock() //race + defer mutex_Connect.Unlock() delete(MapConnection, Connection.ID) delete(MapConn, Connection.ID) - mutex_Connect.Unlock() - return err } @@ -342,10 +340,6 @@ func GetConnection(Connection connections.Connection) *gorm.DB { mutex_Connect.RLock() defer mutex_Connect.RUnlock() - //мьютекс чтоб не подключаться одновременно - mutex_Connect.RLock() - defer mutex_Connect.RUnlock() - // Conn := MapConn[Connection.ID] if Conn == nil { diff --git a/telegram_client/telegram_client.go b/telegram_client/telegram_client.go index 9c5ba8ce..52e7e7b0 100644 --- a/telegram_client/telegram_client.go +++ b/telegram_client/telegram_client.go @@ -389,6 +389,7 @@ func (s *memorySession) StoreSession(ctx context.Context, data []byte) error { } s.mux.Lock() + defer s.mux.Unlock() //s.data = data // write the whole body at once @@ -397,8 +398,6 @@ func (s *memorySession) StoreSession(ctx context.Context, data []byte) error { panic(err) } - s.mux.Unlock() - return nil }