close connection after disconnect
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m54s

This commit is contained in:
matst80
2024-11-10 00:23:45 +01:00
parent 53a8e0a58f
commit 17425dafbb
2 changed files with 2 additions and 2 deletions

View File

@@ -3,7 +3,6 @@ package main
import (
"fmt"
"io"
"log"
"net"
"strings"
"sync"
@@ -46,7 +45,6 @@ func (g *RemoteGrain) Connect() error {
if !strings.Contains(addr, ":") {
addr = fmt.Sprintf("%s:1337", addr)
}
log.Printf("Connecting to %s %s", addr, g.Address)
client, err := net.Dial("tcp", addr)
if err != nil {
return err

View File

@@ -198,11 +198,13 @@ type PacketQueue struct {
}
func NewPacketQueue(connection net.Conn) *PacketQueue {
queue := &PacketQueue{
Packets: make([]PacketWithData, 0),
connection: connection,
}
go func() {
defer connection.Close()
for {
messageType, data, err := ReceivePacket(queue.connection)
ts := time.Now()