mirror of
https://github.com/schoebel/mars
synced 2025-02-11 09:38:16 +00:00
infra: defend against OOM and fork limits
This commit is contained in:
parent
1f64238160
commit
ae79f46a3e
@ -702,17 +702,26 @@ typedef enum {
|
||||
({ \
|
||||
brick_thread_t *_thr = NULL; \
|
||||
int _max_retry = 3; \
|
||||
int _nr_retry = 0; \
|
||||
\
|
||||
while (_max_retry-- > 0) { \
|
||||
for (;;) { \
|
||||
int _err; \
|
||||
\
|
||||
flush_signals(current); \
|
||||
_thr = kthread_create(_thread_fn, _data, _fmt, ##_args); \
|
||||
if (likely(!IS_ERR(_thr))) \
|
||||
break; \
|
||||
brick_yield(); \
|
||||
_err = PTR_ERR(_thr); \
|
||||
if (_err == -EAGAIN || _err == -EINTR) \
|
||||
if (_err == -EAGAIN || \
|
||||
_err == -ENOMEM || \
|
||||
_err == -EINTR || \
|
||||
_max_retry-- > 0) { \
|
||||
brick_msleep(_nr_retry++); \
|
||||
if (_nr_retry > 1000) \
|
||||
_nr_retry = 1000; \
|
||||
continue; \
|
||||
} \
|
||||
BRICK_ERR("cannot create thread '%s', status = %d\n", _fmt, _err); \
|
||||
_thr = NULL; \
|
||||
break; \
|
||||
|
Loading…
Reference in New Issue
Block a user