cmd/cli: fix log init end marker with partial data

For partial init log data (does not end with a newline), the log writer
discard data after the last newline to make the log prettier, then write
the init end marker. This causes the marker could be written more than
once, since the second overflows will preserve the data which does
include the marker from the first write.

To fix this, ensure that the init end marker is only written once, and
the second overflows will preserve data until the marker instead of the
fixed initial size like the first one.
This commit is contained in:
Cuong Manh Le
2025-02-14 21:58:42 +07:00
committed by Cuong Manh Le
parent 3480043e40
commit 7444d8517a
3 changed files with 60 additions and 15 deletions
+1 -1
View File
@@ -250,7 +250,7 @@ func (p *prog) registerControlServerHandler() {
}
}))
p.cs.register(sendLogsPath, http.HandlerFunc(func(w http.ResponseWriter, request *http.Request) {
if time.Since(p.internalLogSent) < logSentInterval {
if time.Since(p.internalLogSent) < logWriterSentInterval {
w.WriteHeader(http.StatusServiceUnavailable)
return
}