netstack: remove unnecessary Inc/DecRef pair in the write path

The endpoint's mutex is held during the entirety of Write, so it's impossible
for something to DecRef the segment via the send list.

PiperOrigin-RevId: 536745711
This commit is contained in:
Kevin Krakauer
2023-05-31 10:04:48 -07:00
committed by gVisor bot
parent 543a60e4a1
commit 6f795f33e5
-4
View File
@@ -1600,7 +1600,6 @@ func (e *endpoint) queueSegment(p tcpip.Payloader, opts tcpip.WriteOptions) (*se
size := int(buf.Size())
s := newOutgoingSegment(e.TransportEndpointInfo.ID, e.stack.Clock(), buf)
e.sndQueueInfo.SndBufUsed += size
s.IncRef()
e.snd.writeList.PushBack(s)
return s, size, nil
@@ -1618,9 +1617,6 @@ func (e *endpoint) Write(p tcpip.Payloader, opts tcpip.WriteOptions) (int64, tcp
// Return if either we didn't queue anything or if an error occurred while
// attempting to queue data.
nextSeg, n, err := e.queueSegment(p, opts)
if nextSeg != nil {
defer nextSeg.DecRef()
}
if n == 0 || err != nil {
return 0, err
}