revid/senders.go: using len(s.buf) to adjust mtsSender ring buffer instead of len(d)

This commit is contained in:
Saxon 2020-05-02 20:37:13 +09:30
parent 3507474564
commit f4e6a5217c
1 changed files with 2 additions and 2 deletions

View File

@ -273,9 +273,9 @@ func (s *mtsSender) Write(d []byte) (int, error) {
s.ring.Flush() s.ring.Flush()
} }
if err != nil { if err != nil {
s.log(logger.Warning, "ringBuffer write error", "error", err.Error(), "n", n, "size", len(s.buf)) s.log(logger.Warning, "ringBuffer write error", "error", err.Error(), "n", n, "size", len(s.buf), "rb element size", adjustedMTSRBElementSize)
if err == ring.ErrTooLong { if err == ring.ErrTooLong {
adjustedMTSRBElementSize = len(d) * 2 adjustedMTSRBElementSize = len(s.buf) * 2
numElements := maxBuffLen / adjustedMTSRBElementSize numElements := maxBuffLen / adjustedMTSRBElementSize
s.ring = ring.NewBuffer(maxBuffLen/adjustedMTSRBElementSize, adjustedMTSRBElementSize, 5*time.Second) s.ring = ring.NewBuffer(maxBuffLen/adjustedMTSRBElementSize, adjustedMTSRBElementSize, 5*time.Second)
s.log(logger.Info, "adjusted MTS ring buffer element size", "new size", adjustedMTSRBElementSize, "num elements", numElements, "size(MB)", numElements*adjustedMTSRBElementSize) s.log(logger.Info, "adjusted MTS ring buffer element size", "new size", adjustedMTSRBElementSize, "num elements", numElements, "size(MB)", numElements*adjustedMTSRBElementSize)