diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2015-11-19 10:26:37 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2015-11-19 10:26:37 +0100 |
| commit | 485651138e96741ff79f16d212f4db0fa7ec1b28 (patch) | |
| tree | fd4cea91a7eceb91fe088925dc0db4821804ee45 /executor/executor.cc | |
| parent | f67856dae0496c8fd414a762b81e9b4307d486eb (diff) | |
executor: fix detection of out of threads
Diffstat (limited to 'executor/executor.cc')
| -rw-r--r-- | executor/executor.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/executor/executor.cc b/executor/executor.cc index 671828703..fa03107bd 100644 --- a/executor/executor.cc +++ b/executor/executor.cc @@ -335,21 +335,22 @@ thread_t* schedule_call(int n, int call_index, int call_num, uint64_t num_args, root = true; } // Find a spare thread to execute the call. - thread_t* th = 0; - for (int i = 0; i < kMaxThreads; i++) { - th = &threads[i]; + int i; + for (i = 0; i < kMaxThreads; i++) { + thread_t* th = &threads[i]; if (!th->created) thread_create(th, i, false); - if (flag_drop_privs && root != th->root) - continue; if (__atomic_load_n(&th->done, __ATOMIC_ACQUIRE)) { if (!th->handled) handle_completion(th); + if (flag_drop_privs && root != th->root) + continue; break; } } - if (th == &threads[kMaxThreads]) - fail("out of threads"); + if (i == kMaxThreads) + exitf("out of threads"); + thread_t* th = &threads[i]; debug("scheduling call %d [%s] on thread %d\n", call_index, syscalls[call_num].name, th->id); if (th->ready || !th->done || !th->handled) fail("bad thread state in schedule: ready=%d done=%d handled=%d", th->ready, th->done, th->handled); |
