aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/stack.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/stack.go')
-rw-r--r--src/runtime/stack.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/runtime/stack.go b/src/runtime/stack.go
index b14b4005d8..8398a101fd 100644
--- a/src/runtime/stack.go
+++ b/src/runtime/stack.go
@@ -784,8 +784,12 @@ func syncadjustsudogs(gp *g, used uintptr, adjinfo *adjustinfo) uintptr {
// copystack; otherwise, gp may be in the middle of
// putting itself on wait queues and this would
// self-deadlock.
+ var lastc *hchan
for sg := gp.waiting; sg != nil; sg = sg.waitlink {
- lock(&sg.c.lock)
+ if sg.c != lastc {
+ lock(&sg.c.lock)
+ }
+ lastc = sg.c
}
// Adjust sudogs.
@@ -803,8 +807,12 @@ func syncadjustsudogs(gp *g, used uintptr, adjinfo *adjustinfo) uintptr {
}
// Unlock channels.
+ lastc = nil
for sg := gp.waiting; sg != nil; sg = sg.waitlink {
- unlock(&sg.c.lock)
+ if sg.c != lastc {
+ unlock(&sg.c.lock)
+ }
+ lastc = sg.c
}
return sgsize