socket/unix: clean up socket queue after releasing a queue lock

A socket queue can contain sockets (others and this one). We have to avoid
taking locks of the same class where it is possible.

PiperOrigin-RevId: 398100744
This commit is contained in:
Andrei Vagin
2021-09-21 15:39:44 -07:00
committed by gVisor bot
parent 6fccc18560
commit c485602ded
+5 -3
View File
@@ -59,12 +59,14 @@ func (q *queue) Close() {
// q.WriterQueue.Notify(waiter.WritableEvents)
func (q *queue) Reset(ctx context.Context) {
q.mu.Lock()
for cur := q.dataList.Front(); cur != nil; cur = cur.Next() {
cur.Release(ctx)
}
dataList := q.dataList
q.dataList.Reset()
q.used = 0
q.mu.Unlock()
for cur := dataList.Front(); cur != nil; cur = cur.Next() {
cur.Release(ctx)
}
}
// DecRef implements RefCounter.DecRef.