summaryrefslogtreecommitdiffhomepage
path: root/src/receive.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-11-11 23:26:44 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-11-11 23:26:44 +0100
commit566269275ed97812ec909b10ec77c7c037d9e2ea (patch)
treea5cf35234f15728dee85918088502ad5653a9513 /src/receive.go
parent892276aa64ca9b14d2e96186b83145ab2f5ce25a (diff)
Fixed blocking reader on closed socket
Diffstat (limited to 'src/receive.go')
-rw-r--r--src/receive.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/receive.go b/src/receive.go
index cb53f80..3e88be3 100644
--- a/src/receive.go
+++ b/src/receive.go
@@ -95,23 +95,22 @@ func (device *Device) addToHandshakeQueue(
func (device *Device) RoutineReceiveIncomming(IPVersion int) {
logDebug := device.log.Debug
- logDebug.Println("Routine, receive incomming, started")
+ logDebug.Println("Routine, receive incomming, IP version:", IPVersion)
for {
// wait for bind
- logDebug.Println("Waiting for udp bind")
- device.net.mutex.Lock()
+ logDebug.Println("Waiting for UDP socket, IP version:", IPVersion)
+
device.net.update.Wait()
+ device.net.mutex.RLock()
bind := device.net.bind
- device.net.mutex.Unlock()
+ device.net.mutex.RUnlock()
if bind == nil {
continue
}
- logDebug.Println("LISTEN\n\n\n")
-
// receive datagrams until conn is closed
buffer := device.GetMessageBuffer()
@@ -427,6 +426,8 @@ func (device *Device) RoutineHandshake() {
err = peer.SendBuffer(packet)
if err == nil {
peer.TimerAnyAuthenticatedPacketTraversal()
+ } else {
+ logError.Println("Failed to send response to:", peer.String(), err)
}
case MessageResponseType: