Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent a subscriber from blocking all others #178

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion publisher_sub.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"github.com/bluenviron/goroslib/v2/pkg/prototcp"
)

const (
writeBufferSize = 16
)

type publisherSubscriber struct {
pub *Publisher
callerID string
Expand Down Expand Up @@ -40,7 +44,7 @@
udpAddr: udpAddr,
ctx: ctx,
ctxCancel: ctxCancel,
chWriteMessage: make(chan interface{}),
chWriteMessage: make(chan interface{}, writeBufferSize),
}

pub.subscribersWg.Add(1)
Expand Down Expand Up @@ -197,5 +201,6 @@
select {
case ps.chWriteMessage <- msg:
case <-ps.ctx.Done():
default: // buffer is full

Check warning on line 204 in publisher_sub.go

View check run for this annotation

Codecov / codecov/patch

publisher_sub.go#L204

Added line #L204 was not covered by tests
}
}
Loading