Skip to content

Commit ce609ef

Browse files
committed
🫩 conn: drop sendmmsg short-write optimization
1 parent 859785d commit ce609ef

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

conn/mmsg.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,16 @@ func (c MmsgConn) NewWConn() *MmsgWConn {
107107
return true
108108
}
109109

110-
// Short-write optimization:
110+
// sendmmsg(2) may return less than vlen in one of the following cases:
111111
//
112-
// According to tokio, not writing the full msgvec is sufficient to show
113-
// that the socket buffer is full. Previous tests also showed that this is
114-
// faster than immediately trying to write again.
112+
// - The socket write buffer is full.
113+
// - vlen is greater than UIO_MAXIOV (1024).
114+
// - Sending the next message would return an error.
115115
//
116-
// Do keep in mind that this is not how the Go runtime handles writes though.
117-
118-
// sendmmsg(2) sends up to UIO_MAXIOV (1024) messages per call.
119-
if n == 1024 {
120-
continue
121-
}
122-
123-
return false
116+
// The first case is the only one where it's safe to clear write readiness.
117+
// The other cases require the caller to retry sending the remaining messages.
118+
// Unfortunately, the API does not tell us which one is the case, so we always
119+
// retry the call with the remaining messages.
124120
}
125121
}
126122

0 commit comments

Comments
 (0)