aboutsummaryrefslogtreecommitdiffstats
path: root/cmd_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd_linux.go')
-rw-r--r--cmd_linux.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/cmd_linux.go b/cmd_linux.go
index b80b197..d937000 100644
--- a/cmd_linux.go
+++ b/cmd_linux.go
@@ -87,11 +87,19 @@ func run() {
func handleClient(conn net.Conn, stack *GitignoreStack) {
defer conn.Close()
+ remoteManifest := &Manifest{Files: make(map[string]FileMeta)}
+ batches := 0
+
scanner := bufio.NewScanner(conn)
scanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024) // 1MB buffer per batch
- remoteManifest := &Manifest{Files: make(map[string]FileMeta)}
- for scanner.Scan() {
+ for {
+ conn.SetReadDeadline(time.Now().Add(30 * time.Second))
+ if !scanner.Scan() {
+ break
+ }
+ conn.SetReadDeadline(time.Time{}) // reset deadline
+
msg, err := DecodeMessage(scanner.Bytes())
if err != nil {
logDebug("bad message: %v", err)
@@ -108,10 +116,11 @@ func handleClient(conn net.Conn, stack *GitignoreStack) {
Symlink: v.Symlink,
}
}
- logDebug("manifest: received batch (%d files, total: %d)", len(msg.Files), len(remoteManifest.Files))
+ batches++
+ logDebug("manifest: batch %d received (%d files, total: %d)", batches, len(msg.Files), len(remoteManifest.Files))
case "manifest_done":
- logInfo("manifest: received %d files from host", len(remoteManifest.Files))
+ logInfo("manifest: received %d files in %d batches from host", len(remoteManifest.Files), batches)
logInfo("manifest: comparing with local state ...")
syncFromManifest(remoteManifest, stack)
logInfo("sync: done")
@@ -149,7 +158,7 @@ func handleClient(conn net.Conn, stack *GitignoreStack) {
}
if err := scanner.Err(); err != nil {
- logErrorf("read: %v", err)
+ logErrorf("client read: %v", err)
}
}