Merge pull request #58 from sgotti/readdb_fix_deadlock

readdb: fix deadlock in Run method
This commit is contained in:
Simone Gotti 2019-07-23 15:47:05 +02:00 committed by GitHub
commit 77ee8d9e7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -424,7 +424,6 @@ func (r *ReadDB) Run(ctx context.Context) error {
} }
r.SetInitialized(true) r.SetInitialized(true)
errCh := make(chan error)
for { for {
for { for {
initialized := r.IsInitialized() initialized := r.IsInitialized()
@ -441,6 +440,7 @@ func (r *ReadDB) Run(ctx context.Context) error {
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
} }
errCh := make(chan error, 1)
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
wg := &sync.WaitGroup{} wg := &sync.WaitGroup{}

View File

@ -274,7 +274,6 @@ func (r *ReadDB) Run(ctx context.Context) error {
} }
r.SetInitialized(true) r.SetInitialized(true)
errCh := make(chan error)
for { for {
for { for {
initialized := r.IsInitialized() initialized := r.IsInitialized()
@ -291,6 +290,7 @@ func (r *ReadDB) Run(ctx context.Context) error {
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
} }
errCh := make(chan error, 2)
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
wg := &sync.WaitGroup{} wg := &sync.WaitGroup{}