diff options
| author | historia <[not public]> | 2026-09-15 20:35:23 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-15 20:35:23 -0400 |
| commit | fcb806c3445ce56f2e57e208de773b4dac957c8d (patch) | |
| tree | 3b08c3d51bfe5456dcd215449cf07509aca2353a /internal/net/server.go | |
| parent | 69235cac5b3da5ff0dc20310e7474cabd8e63ba3 (diff) | |
| download | thehouseoficarus-fcb806c3445ce56f2e57e208de773b4dac957c8d.tar.gz | |
fix: owner re-entrancy deadlock, telnet write queue, recovery/refund money safety, admin path traversal
Diffstat (limited to 'internal/net/server.go')
| -rw-r--r-- | internal/net/server.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/net/server.go b/internal/net/server.go index b0407fc..42077a1 100644 --- a/internal/net/server.go +++ b/internal/net/server.go @@ -174,7 +174,15 @@ func (sess *Session) StartWriter() { // enqueue appends msg to the outbound queue. When the client's queue is full // the session is disconnected instead of blocking the caller: the world must // never wait on a single slow client. +// enqueue appends msg to the outbound queue. When the client's queue is +// full the session is disconnected instead of blocking the caller: the world +// must never wait on a single slow client. func (sess *Session) enqueue(msg string) { + // A broadcast can race Close(): the queue may already be (or become) + // closed mid-send. Such late writes are dropped, never panicked on — + // Close() closes the queue so the writer goroutine drains whatever was + // queued before the close and then flushes the transport. + defer func() { _ = recover() }() select { case sess.outbox <- msg: default: @@ -490,6 +498,10 @@ func (s *Server) serveTelnet() { Conn: newTCPConn(conn), State: StateAccountName, } + // Queued writes like the websocket transport: a dedicated writer + // goroutine performs the I/O with per-message deadlines, so a slow + // or stalled telnet client can never block game code. + sess.StartWriter() s.hub.Add(sess) go s.handleSession(sess, s.handler) } @@ -505,6 +517,7 @@ func (s *Server) serveTelnetTLS() { Conn: newTCPConn(conn), State: StateAccountName, } + sess.StartWriter() s.hub.Add(sess) go s.handleSession(sess, s.handler) } |
