summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/link/rawfile/rawfile_unsafe.go
diff options
context:
space:
mode:
authorTing-Yu Wang <anivia@google.com>2020-07-06 16:46:27 -0700
committergVisor bot <gvisor-bot@google.com>2020-07-06 16:47:37 -0700
commit15c56d92d8b12b7a7bc72aa8a7d1751682e68302 (patch)
treea73f9b20f14be7d7626653f742d16462a629282a /pkg/tcpip/link/rawfile/rawfile_unsafe.go
parentbd43368f491a02b050cd9f87f69185dc74386f2b (diff)
Fix NonBlockingWrite3 not writing b3 if b2 is zero-length.
PiperOrigin-RevId: 319882171
Diffstat (limited to 'pkg/tcpip/link/rawfile/rawfile_unsafe.go')
-rw-r--r--pkg/tcpip/link/rawfile/rawfile_unsafe.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/pkg/tcpip/link/rawfile/rawfile_unsafe.go b/pkg/tcpip/link/rawfile/rawfile_unsafe.go
index 44e25d475..69de6eb3e 100644
--- a/pkg/tcpip/link/rawfile/rawfile_unsafe.go
+++ b/pkg/tcpip/link/rawfile/rawfile_unsafe.go
@@ -69,13 +69,12 @@ func NonBlockingWrite(fd int, buf []byte) *tcpip.Error {
// NonBlockingWrite3 writes up to three byte slices to a file descriptor in a
// single syscall. It fails if partial data is written.
func NonBlockingWrite3(fd int, b1, b2, b3 []byte) *tcpip.Error {
- // If the is no second buffer, issue a regular write.
- if len(b2) == 0 {
+ // If there is no second and third buffer, issue a regular write.
+ if len(b2) == 0 && len(b3) == 0 {
return NonBlockingWrite(fd, b1)
}
- // We have two buffers. Build the iovec that represents them and issue
- // a writev syscall.
+ // Build the iovec that represents them and issue a writev syscall.
iovec := [3]syscall.Iovec{
{
Base: &b1[0],