summaryrefslogtreecommitdiff
path: root/internal/server/session/session.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/server/session/session.go')
-rw-r--r--internal/server/session/session.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/internal/server/session/session.go b/internal/server/session/session.go
index 88a19e7..a904d39 100644
--- a/internal/server/session/session.go
+++ b/internal/server/session/session.go
@@ -4,6 +4,7 @@ import (
"context"
"crypto/ed25519"
"crypto/rand"
+ "log"
"net"
"sync"
"time"
@@ -99,7 +100,7 @@ func (s *Session) Read(ctx context.Context) (packet.Packet, bool) {
}
func (s *Session) Close() {
- timeout := 1 * time.Second
+ timeout := 10 * time.Millisecond
ctx, cancel := context.WithTimeout(context.Background(), timeout)
payload := &packet.Error{
Error: "new connection from another location, closing this one",
@@ -109,5 +110,13 @@ func (s *Session) Close() {
s.Write(ctx, pkt)
cancel()
+ // Add some delay before canceling to let the writer enough time to
+ // actually write that into the connection
+ // HACK: consider just giving session the private connection and to
+ // write directly so we don't have to wait
+ time.Sleep(100 * time.Millisecond)
+
+ log.Println(s.addr, "closed due to new connection from another location")
+
s.cancel()
}