aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-01-31 09:44:35 +0100
committerDmitry Vyukov <dvyukov@google.com>2019-01-31 11:35:53 +0100
commit6fb60a48131bd6ca2bb8ea760f253e057547c429 (patch)
tree4259ab876f074c1ee9d1876be07b8ef62de41356 /pkg
parent7e81a532301ad5caef5158226cef3a11898987c9 (diff)
executor: handle pthread_create errors better
See the added comment for explanation.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/csource/generated.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go
index b52a6dc17..f6337cb88 100644
--- a/pkg/csource/generated.go
+++ b/pkg/csource/generated.go
@@ -226,9 +226,19 @@ static void thread_start(void* (*fn)(void*), void* arg)
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, 128 << 10);
- if (pthread_create(&th, &attr, fn, arg))
- exitf("pthread_create failed");
- pthread_attr_destroy(&attr);
+ int i;
+ for (i = 0; i < 100; i++) {
+ if (pthread_create(&th, &attr, fn, arg) == 0) {
+ pthread_attr_destroy(&attr);
+ return;
+ }
+ if (errno == EAGAIN) {
+ usleep(50);
+ continue;
+ }
+ break;
+ }
+ exitf("pthread_create failed");
}
#endif