remove shutdowncalled and itmut
This commit is contained in:
parent
7679b96231
commit
c2624ba8fa
2 changed files with 0 additions and 27 deletions
24
db/db.go
24
db/db.go
|
@ -8,7 +8,6 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lbryio/herald.go/db/prefixes"
|
"github.com/lbryio/herald.go/db/prefixes"
|
||||||
|
@ -61,11 +60,9 @@ type ReadOnlyDBColumnFamily struct {
|
||||||
FilteredStreams map[string][]byte
|
FilteredStreams map[string][]byte
|
||||||
FilteredChannels map[string][]byte
|
FilteredChannels map[string][]byte
|
||||||
OpenIterators map[string][]chan struct{}
|
OpenIterators map[string][]chan struct{}
|
||||||
ItMut sync.RWMutex
|
|
||||||
Grp *stop.Group
|
Grp *stop.Group
|
||||||
ShutdownChan chan struct{}
|
ShutdownChan chan struct{}
|
||||||
DoneChan chan struct{}
|
DoneChan chan struct{}
|
||||||
ShutdownCalled bool
|
|
||||||
Cleanup func()
|
Cleanup func()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,9 +603,7 @@ func GetDBColumnFamilies(name string, secondayPath string, cfNames []string) (*R
|
||||||
Height: 0,
|
Height: 0,
|
||||||
Headers: nil,
|
Headers: nil,
|
||||||
OpenIterators: make(map[string][]chan struct{}),
|
OpenIterators: make(map[string][]chan struct{}),
|
||||||
ItMut: sync.RWMutex{},
|
|
||||||
ShutdownChan: make(chan struct{}, 1),
|
ShutdownChan: make(chan struct{}, 1),
|
||||||
ShutdownCalled: false,
|
|
||||||
DoneChan: make(chan struct{}, 1),
|
DoneChan: make(chan struct{}, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,26 +673,7 @@ func (db *ReadOnlyDBColumnFamily) Unwind() {
|
||||||
|
|
||||||
// Shutdown shuts down the db.
|
// Shutdown shuts down the db.
|
||||||
func (db *ReadOnlyDBColumnFamily) Shutdown() {
|
func (db *ReadOnlyDBColumnFamily) Shutdown() {
|
||||||
db.ShutdownCalled = true
|
|
||||||
db.Grp.StopAndWait()
|
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...")
|
log.Println("Calling cleanup...")
|
||||||
db.Cleanup()
|
db.Cleanup()
|
||||||
log.Println("Leaving Shutdown...")
|
log.Println("Leaving Shutdown...")
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
dbpkg "github.com/lbryio/herald.go/db"
|
dbpkg "github.com/lbryio/herald.go/db"
|
||||||
|
@ -95,10 +94,8 @@ func OpenAndFillTmpDBColumnFamlies(filePath string) (*dbpkg.ReadOnlyDBColumnFami
|
||||||
Height: 0,
|
Height: 0,
|
||||||
Headers: nil,
|
Headers: nil,
|
||||||
OpenIterators: make(map[string][]chan struct{}),
|
OpenIterators: make(map[string][]chan struct{}),
|
||||||
ItMut: sync.RWMutex{},
|
|
||||||
ShutdownChan: make(chan struct{}, 1),
|
ShutdownChan: make(chan struct{}, 1),
|
||||||
DoneChan: make(chan struct{}, 1),
|
DoneChan: make(chan struct{}, 1),
|
||||||
ShutdownCalled: false,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// err = dbpkg.ReadDBState(myDB) //TODO: Figure out right place for this
|
// err = dbpkg.ReadDBState(myDB) //TODO: Figure out right place for this
|
||||||
|
|
Loading…
Reference in a new issue