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