]> git.r.bdr.sh - rbdr/mobius/commitdiff
Add workaround for Windows file transfer errors
authorJeff Halter <redacted>
Tue, 8 Nov 2022 04:05:25 +0000 (20:05 -0800)
committerJeff Halter <redacted>
Tue, 8 Nov 2022 04:05:25 +0000 (20:05 -0800)
hotline/server.go

index 8d6803b274f411c3a0b1eb4d360a9f9daeccd8b3..164b93ec1fa5045afae838fe939b80ffda35c331 100644 (file)
@@ -749,6 +749,10 @@ func (s *Server) handleFileTransfer(ctx context.Context, rwc io.ReadWriter) erro
                delete(s.fileTransfers, t.ReferenceNumber)
                s.mux.Unlock()
 
+               // Wait a few seconds before closing the connection: this is a workaround for problems
+               // observed with Windows clients where the client must initiate close of the TCP connection before
+               // the server does.  This is gross and seems unnecessary.  TODO: Revisit?
+               time.Sleep(3 * time.Second)
        }()
 
        s.mux.Lock()
@@ -783,7 +787,9 @@ func (s *Server) handleFileTransfer(ctx context.Context, rwc io.ReadWriter) erro
        case FileDownload:
                s.Stats.DownloadCounter += 1
                s.Stats.DownloadsInProgress += 1
-               defer func() { s.Stats.DownloadsInProgress -= 1 }()
+               defer func() {
+                       s.Stats.DownloadsInProgress -= 1
+               }()
 
                var dataOffset int64
                if fileTransfer.fileResumeData != nil {