Переглянути джерело

cmd/strelaysrv: Outbox will get GCed (fixes #3718)

Audrius Butkevicius 9 роки тому
батько
коміт
94e4370c7e
1 змінених файлів з 1 додано та 6 видалено
  1. 1 6
      cmd/strelaysrv/listener.go

+ 1 - 6
cmd/strelaysrv/listener.go

@@ -172,7 +172,7 @@ func protocolConnectionHandler(tcpConn net.Conn, config *tls.Config) {
 					if debug {
 					if debug {
 						log.Println("Sent invitation from", id, "to", requestedPeer)
 						log.Println("Sent invitation from", id, "to", requestedPeer)
 					}
 					}
-				default:
+				case <-time.After(time.Second):
 					if debug {
 					if debug {
 						log.Println("Could not send invitation from", id, "to", requestedPeer, "as peer disconnected")
 						log.Println("Could not send invitation from", id, "to", requestedPeer, "as peer disconnected")
 					}
 					}
@@ -204,7 +204,6 @@ func protocolConnectionHandler(tcpConn net.Conn, config *tls.Config) {
 			if debug {
 			if debug {
 				log.Printf("Closing connection %s: %s", id, err)
 				log.Printf("Closing connection %s: %s", id, err)
 			}
 			}
-			close(outbox)
 
 
 			// Potentially closing a second time.
 			// Potentially closing a second time.
 			conn.Close()
 			conn.Close()
@@ -260,10 +259,6 @@ func protocolConnectionHandler(tcpConn net.Conn, config *tls.Config) {
 			conn.Close()
 			conn.Close()
 
 
 		case msg := <-outbox:
 		case msg := <-outbox:
-			if msg == nil {
-				conn.Close()
-				return
-			}
 			if debug {
 			if debug {
 				log.Printf("Sending message %T to %s", msg, id)
 				log.Printf("Sending message %T to %s", msg, id)
 			}
 			}