Browse Source

dont close the channel when we're done, avoids lock congestion

backfeed-full-error
Fusl 2 years ago
parent
commit
d14917c95d
1 changed files with 17 additions and 16 deletions
  1. +17
    -16
      main.go

+ 17
- 16
main.go View File

@@ -54,7 +54,7 @@ type ProjectBackfeedManager struct {
BackfeedRedis *redis.ClusterClient
ProjectRedis *redis.Client
LegacyRedis *redis.Client
Lock sync.RWMutex
//Lock sync.RWMutex
ProjectConfig ProjectConfig
}

@@ -66,11 +66,11 @@ func (that *ProjectBackfeedManager) RedisConfigDiffers(new *ProjectRedisConfig)
}

func (that *ProjectBackfeedManager) PushItem(ctx context.Context, item *BackfeedItem) bool {
that.Lock.RLock()
defer that.Lock.RUnlock()
if that.C == nil {
return false
}
//that.Lock.RLock()
//defer that.Lock.RUnlock()
//if that.C == nil {
// return false
//}
select {
case <-ctx.Done():
return false
@@ -101,19 +101,20 @@ func (that *ProjectBackfeedManager) PopItem(blocking bool) (*BackfeedItem, bool)
}
}

func (that *ProjectBackfeedManager) CloseItemChannel() {
that.Lock.Lock()
defer that.Lock.Unlock()
if that.C == nil {
return
}
close(that.C)
that.C = nil
}
//func (that *ProjectBackfeedManager) CloseItemChannel() {
// log.Printf("closing item channel for %s", that.Name)
// that.Lock.Lock()
// defer that.Lock.Unlock()
// if that.C == nil {
// return
// }
// close(that.C)
// that.C = nil
//}

func (that *ProjectBackfeedManager) Do() {
defer close(that.Done)
defer that.CloseItemChannel()
//defer that.CloseItemChannel()
defer that.Cancel()

for {


Loading…
Cancel
Save