This happens because transceiver calls go client.Bind(), in which:
l.130-138: connection is set up
l.139: client.BindFunc is called, which is transceiver.bindFunc injected, which calls go transmitter.handlePDU, which calls client.Read, which waits on client.inbox channel)
l.147: if for whatever reason err is returned, break in l.153 is called, which means there is no send to client.inbox. close(client.inbox) is called nowhere, so transceiver.bindFunc waits forever
If this scenario repeats, we end up with more and more goroutines (transceiver.bindFunc -> transmitter.handlePDU -> client.Read) waiting on the client.inbox channel.
Using:
on unstable connection leads to memory leak (sorry for line numbers - issue encountered on old github.com/zpas-lab/go-smpp fork):
For current code would be:
This happens because transceiver calls
go client.Bind()
, in which:client.BindFunc
is called, which istransceiver.bindFunc
injected, which callsgo transmitter.handlePDU
, which callsclient.Read
, which waits onclient.inbox
channel)err
is returned,break
in l.153 is called, which means there is no send toclient.inbox
.close(client.inbox)
is called nowhere, sotransceiver.bindFunc
waits foreverIf this scenario repeats, we end up with more and more goroutines (
transceiver.bindFunc -> transmitter.handlePDU -> client.Read
) waiting on theclient.inbox
channel.