Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split: skip zero len writes #519

Merged
merged 9 commits into from
Jul 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Android/app/src/go/intra/split/retrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ func (r *retrier) Write(b []byte) (int, error) {
r.conn.SetReadDeadline(time.Now().Add(r.timeout))
}
r.mutex.Unlock()

if attempted {
if err == nil {
return n, nil
Expand All @@ -322,11 +323,19 @@ func (r *retrier) Write(b []byte) (int, error) {
// by the retry procedure. Block until we have a final socket (which will
// already have replayed b[:n]), and retry.
<-r.retryCompleteFlag

r.mutex.Lock()
c := r.conn
r.mutex.Unlock()
m, err := c.Write(b[n:])
return n + m, err

// zero len writes are no-ops, but Quad9 servers
// are observed to respond better when these are skipped.
if buf := b[n:]; len(buf) > 0 {
m, e := c.Write(buf)
n += m
err = e
}
return n, err
}
}

Expand Down
Loading