Open joao-r-reis opened 3 years ago
h.isClosed()
after acquiring h.connectionsLock
in onConnectionAccepted
.https://pkg.go.dev/golang.org/x/sync/errgroup
. We used it already in another project and it works great, even if it does not have a stable version yet.For 1
, won't that introduce a race condition?
I ran into two different issues, one is a deadlock and the other is leaked goroutines. I'm not exactly sure if these goroutines will be cleaned at some point but I did see them in the debugger.
Deadlock
While trying to reproduce #36 with an automated test, I ran into a deadlock caused by a blocking channel write here that causes the goroutine to not release the
connectionsLock
.In the debugger I see a lot of goroutines blocked while trying to acquire that lock which is not possible because of that blocked channel write in the first goroutine.
I believe that this is because that channel is in fact
nil
due to this call toclose()
and writing to anil
channel blocks forever.Leaked goroutines
I also see several background goroutines blocked here and here.
This happens because neither channel is buffered so the write will only progress when a read happens but the
for
loop returns before reading from both when an error happens.Here is the test that I used to reproduce these issues: