From 6fb60a48131bd6ca2bb8ea760f253e057547c429 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 31 Jan 2019 09:44:35 +0100 Subject: executor: handle pthread_create errors better See the added comment for explanation. --- pkg/csource/generated.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'pkg') 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 -- cgit mrf-deployment