Skip to content

Commit

Permalink
Revert (bad) refcount improvement in pubsub.
Browse files Browse the repository at this point in the history
  • Loading branch information
lthibault committed Jun 6, 2022
1 parent 53c1c68 commit 1f6e103
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pkg/ocap/pubsub/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,23 @@ func (t Topic) Publish(ctx context.Context, b []byte) error {
return err
}

func (t Topic) Subscribe(ctx context.Context, ch chan<- []byte) (capnp.ReleaseFunc, error) {
func (t Topic) Subscribe(ctx context.Context, ch chan<- []byte) (release capnp.ReleaseFunc, err error) {
h := chan_api.Sender_ServerToClient(handler{
ms: ch,
release: t.AddRef().Release,
}, &server.Policy{
MaxConcurrentCalls: cap(ch),
})

f, release := api.Topic(t).Subscribe(ctx, sender(h.AddRef()))
f, release := api.Topic(t).Subscribe(ctx, sender(h))
defer release()

_, err := f.Struct()
if err != nil {
h.Release()
if _, err = f.Struct(); err == nil {
release = h.Release
}

return h.Release, err
return
}

func (t Topic) Release() { t.Client.Release() }

func (t Topic) AddRef() Topic {
Expand Down

0 comments on commit 1f6e103

Please sign in to comment.