Преглед на файлове

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

backfeed-full-error
Fusl преди 2 години
родител
ревизия
d14917c95d
променени са 1 файла, в които са добавени 17 реда и са изтрити 16 реда
  1. +17
    -16
      main.go

+ 17
- 16
main.go Целия файл

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


Зареждане…
Отказ
Запис