From c2624ba8fab3e007b19f0c3005db4c2cc8e386bb Mon Sep 17 00:00:00 2001 From: Jeffrey Picard Date: Sat, 15 Oct 2022 15:11:56 +0000 Subject: [PATCH] remove shutdowncalled and itmut --- db/db.go | 24 ------------------------ db/db_test.go | 3 --- 2 files changed, 27 deletions(-) diff --git a/db/db.go b/db/db.go index dc9de53..7779776 100644 --- a/db/db.go +++ b/db/db.go @@ -8,7 +8,6 @@ import ( "encoding/hex" "fmt" "os" - "sync" "time" "github.com/lbryio/herald.go/db/prefixes" @@ -61,11 +60,9 @@ type ReadOnlyDBColumnFamily struct { FilteredStreams map[string][]byte FilteredChannels map[string][]byte OpenIterators map[string][]chan struct{} - ItMut sync.RWMutex Grp *stop.Group ShutdownChan chan struct{} DoneChan chan struct{} - ShutdownCalled bool Cleanup func() } @@ -606,9 +603,7 @@ func GetDBColumnFamilies(name string, secondayPath string, cfNames []string) (*R Height: 0, Headers: nil, OpenIterators: make(map[string][]chan struct{}), - ItMut: sync.RWMutex{}, ShutdownChan: make(chan struct{}, 1), - ShutdownCalled: false, DoneChan: make(chan struct{}, 1), } @@ -678,26 +673,7 @@ func (db *ReadOnlyDBColumnFamily) Unwind() { // Shutdown shuts down the db. func (db *ReadOnlyDBColumnFamily) Shutdown() { - db.ShutdownCalled = true db.Grp.StopAndWait() - // log.Println("Sending message to ShutdownChan...") - // db.ShutdownChan <- struct{}{} - // log.Println("Locking iterator mutex...") - // db.ItMut.Lock() - // log.Println("Setting ShutdownCalled to true...") - // db.ShutdownCalled = true - // log.Println("Notifying iterators to shutdown...") - // for _, it := range db.OpenIterators { - // it[1] <- struct{}{} - // } - // log.Println("Waiting for iterators to shutdown...") - // for _, it := range db.OpenIterators { - // <-it[0] - // } - // log.Println("Unlocking iterator mutex...") - // db.ItMut.Unlock() - // log.Println("Sending message to DoneChan...") - // <-db.DoneChan log.Println("Calling cleanup...") db.Cleanup() log.Println("Leaving Shutdown...") diff --git a/db/db_test.go b/db/db_test.go index 2855753..b6294c4 100644 --- a/db/db_test.go +++ b/db/db_test.go @@ -7,7 +7,6 @@ import ( "log" "os" "strings" - "sync" "testing" dbpkg "github.com/lbryio/herald.go/db" @@ -95,10 +94,8 @@ func OpenAndFillTmpDBColumnFamlies(filePath string) (*dbpkg.ReadOnlyDBColumnFami Height: 0, Headers: nil, OpenIterators: make(map[string][]chan struct{}), - ItMut: sync.RWMutex{}, ShutdownChan: make(chan struct{}, 1), DoneChan: make(chan struct{}, 1), - ShutdownCalled: false, } // err = dbpkg.ReadDBState(myDB) //TODO: Figure out right place for this