Skip to content

Commit

Permalink
Merge pull request #77 from named-data/mudp-exit
Browse files Browse the repository at this point in the history
transport: fix multicast udp exit
  • Loading branch information
pulsejet authored Dec 22, 2024
2 parents d10c0a6 + 031714b commit 8b2d1e8
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions face/multicast-udp-transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,21 @@ func (t *MulticastUDPTransport) sendFrame(frame []byte) {
func (t *MulticastUDPTransport) runReceive() {
defer t.Close()

for {
for t.running.Load() {
err := readTlvStream(t.recvConn, func(b []byte) {
t.nInBytes += uint64(len(b))
t.linkService.handleIncomingFrame(b)
}, func(err error) bool {
// Same as unicast UDP transport
return strings.Contains(err.Error(), "connection refused")
})
if err != nil {
core.LogWarn(t, "Unable to read from socket (", err, ") - Face DOWN")

if err != nil && t.running.Load() {
// Re-create the socket if connection is still running
if t.running.Load() {
err = t.connectRecv()
if err != nil {
core.LogError(t, "Unable to re-create receive connection: ", err)
return
}
core.LogWarn(t, "Unable to read from socket (", err, ") - Face DOWN")
err = t.connectRecv()
if err != nil {
core.LogError(t, "Unable to re-create receive connection: ", err)
return
}
}
}
Expand Down

0 comments on commit 8b2d1e8

Please sign in to comment.