infra: restart failed kthread creation

This commit is contained in:
Thomas Schoebel-Theuer 2019-11-22 10:00:15 +01:00
parent e54cab1f95
commit ddff7757d6
1 changed files with 15 additions and 6 deletions

View File

@ -656,15 +656,24 @@ typedef enum {
#define brick_thread_create(_thread_fn, _data, _fmt, _args...) \
({ \
brick_thread_t *_thr; \
brick_thread_t *_thr = NULL; \
int _max_retry = 3; \
\
while (_max_retry-- > 0) { \
int _err; \
\
flush_signals(current); \
_thr = kthread_create(_thread_fn, _data, _fmt, ##_args); \
if (unlikely(IS_ERR(_thr))) { \
int _err = PTR_ERR(_thr); \
if (likely(!IS_ERR(_thr))) \
break; \
_err = PTR_ERR(_thr); \
if (_err == -EAGAIN || _err == -EINTR) \
continue; \
BRICK_ERR("cannot create thread '%s', status = %d\n", _fmt, _err); \
_thr = NULL; \
} else { \
break; \
} \
if (_thr) { \
struct say_channel *ch = get_binding(current); \
if (ch) \
bind_to_channel(ch, _thr); \