Server endpoints goroutine refactor #69

Merged
jeffreypicard merged 18 commits from server-endpoints-goroutine-refactor into master 2022-10-25 07:48:13 +02:00
2 changed files with 0 additions and 27 deletions
Showing only changes of commit c2624ba8fa - Show all commits

View file

@ -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
moodyjon commented 2022-10-14 16:14:51 +02:00 (Migrated from github.com)
Review

OpenIterators, ItMut not needed anymore.

`OpenIterator`s, `ItMut` not needed anymore.
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...")

View file

@ -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