datarhei / gosrt

Implementation of the SRT protocol in pure Go
https://datarhei.com
MIT License
98 stars 15 forks source link

Allow parallel Accepts #43

Closed rlpeck closed 5 months ago

rlpeck commented 6 months ago

It is not currently possible to safely run multiple goroutines that call Accept which means that we are limited in scale by how fast that Accept function returns. There are two issues that prevent using parallel Accepts

  1. Shutdown behavior. Currently the library depends on a single message sent over the error channel to exit out of the Accept function, subsequent calls will block indefinitely waiting for a message
  2. Re-use of the config attribute on listener. Currently the library only uses the config attribute on listener to store state about the request which means that a) 1 stream can change behavior for other streams b) There's a data race preventing parallel reads. We can fix this by creating a copy of the base configuration & attach that copy to the request