Fix ocache and streampool bugs, fix push space
This commit is contained in:
parent
524cf07d56
commit
bb156e1bd0
@ -52,11 +52,13 @@ type streamPool struct {
|
||||
}
|
||||
|
||||
func newStreamPool(messageHandler MessageHandler) StreamPool {
|
||||
return &streamPool{
|
||||
s := &streamPool{
|
||||
peerStreams: make(map[string]spacesyncproto.SpaceStream),
|
||||
messageHandler: messageHandler,
|
||||
wg: &sync.WaitGroup{},
|
||||
}
|
||||
s.lastUsage.Store(time.Now().Unix())
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *streamPool) LastUsage() time.Time {
|
||||
|
||||
@ -356,7 +356,6 @@ func (c *oCache) GC() {
|
||||
c.mu.Unlock()
|
||||
return
|
||||
}
|
||||
deadline := c.timeNow().Add(-c.ttl)
|
||||
var toClose []*entry
|
||||
for _, e := range c.data {
|
||||
if e.isClosing {
|
||||
@ -366,7 +365,8 @@ func (c *oCache) GC() {
|
||||
if lug, ok := e.value.(ObjectLastUsage); ok {
|
||||
lu = lug.LastUsage()
|
||||
}
|
||||
if !e.locked() && e.refCount <= 0 && lu.Before(deadline) {
|
||||
deadline := lu.Add(c.ttl)
|
||||
if !e.locked() && e.refCount <= 0 && c.timeNow().After(deadline) {
|
||||
e.isClosing = true
|
||||
e.close = make(chan struct{})
|
||||
toClose = append(toClose, e)
|
||||
|
||||
@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/treegetter"
|
||||
)
|
||||
|
||||
type rpcHandler struct {
|
||||
@ -17,7 +16,7 @@ func (r *rpcHandler) PushSpace(ctx context.Context, req *spacesyncproto.PushSpac
|
||||
err = spacesyncproto.ErrSpaceExists
|
||||
return
|
||||
}
|
||||
if err != treegetter.ErrSpaceNotFound {
|
||||
if err != storage.ErrSpaceStorageMissing {
|
||||
err = spacesyncproto.ErrUnexpected
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user