aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/os_aix.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-11-01 16:04:50 -0700
committerGopher Robot <gobot@golang.org>2022-11-10 20:44:45 +0000
commit14018c8becc385f79f62f9cdf24cab93fe3e0cdc (patch)
tree74490921a6f54463f4b3d561afb5190ebe75f9b1 /src/runtime/os_aix.go
parentd96eb826cb7cd4fe36745e3b1a79e0a2571acc4a (diff)
downloadgo-14018c8becc385f79f62f9cdf24cab93fe3e0cdc.tar.xz
runtime: retry thread creation on EAGAIN
This copies the logic we use in runtime/cgo, when calling pthread_create, into runtime proper, when calling newosproc. We only do this in newosproc, not newosproc0, because in newosproc0 we need a nosplit function literal, and we need to pass arguments to it through newosproc, which is a pain. Also newosproc0 is only called at process startup, when thread creation is less likely to fail anyhow. Fixes #49438 Change-Id: Ia26813952fdbae8aaad5904c9102269900a07ba9 Reviewed-on: https://go-review.googlesource.com/c/go/+/447175 Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/runtime/os_aix.go')
-rw-r--r--src/runtime/os_aix.go13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/runtime/os_aix.go b/src/runtime/os_aix.go
index 1a534db0e4..7c5947d06f 100644
--- a/src/runtime/os_aix.go
+++ b/src/runtime/os_aix.go
@@ -211,16 +211,9 @@ func newosproc(mp *m) {
// Disable signals during create, so that the new thread starts
// with signals disabled. It will enable them in minit.
sigprocmask(_SIG_SETMASK, &sigset_all, &oset)
- var ret int32
- for tries := 0; tries < 20; tries++ {
- // pthread_create can fail with EAGAIN for no reasons
- // but it will be ok if it retries.
- ret = pthread_create(&tid, &attr, &tstart, unsafe.Pointer(mp))
- if ret != _EAGAIN {
- break
- }
- usleep(uint32(tries+1) * 1000) // Milliseconds.
- }
+ ret := retryOnEAGAIN(func() int32 {
+ return pthread_create(&tid, &attr, &tstart, unsafe.Pointer(mp))
+ })
sigprocmask(_SIG_SETMASK, &oset, nil)
if ret != 0 {
print("runtime: failed to create new OS thread (have ", mcount(), " already; errno=", ret, ")\n")