Skip to content

Commit

Permalink
Optimize error log of failed thread creation, fix #4202
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed May 15, 2021
1 parent 1ec3202 commit 8ce5041
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/swoole_coroutine.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,17 @@ class Coroutine {
static void bailout(BailoutCallback func);

static inline long create(const coroutine_func_t &fn, void *args = nullptr) {
#ifdef SW_USE_THREAD_CONTEXT
try {
return (new Coroutine(fn, args))->run();
} catch (const std::system_error& e) {
swoole_set_last_error(e.code().value());
swWarn("failed to create coroutine, Error: %s[%d]", e.what(), swoole_get_last_error());
return -1;
}
#else
return (new Coroutine(fn, args))->run();
#endif
}

static void activate();
Expand Down

0 comments on commit 8ce5041

Please sign in to comment.