From eb1cc02d09b4ab2d913f99fda2e587e1a092e83e Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Mon, 28 Feb 2022 15:34:03 +0800 Subject: [PATCH] sched/group: Move files_initlist/lib_stream_initialize to group_alloc Signed-off-by: Xiang Xiao --- sched/group/group_create.c | 12 ++++++++++++ sched/group/group_setupidlefiles.c | 4 ---- sched/group/group_setupstreams.c | 5 ----- sched/group/group_setuptaskfiles.c | 4 ---- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/sched/group/group_create.c b/sched/group/group_create.c index 6f2aa1b254..f97eba3e67 100644 --- a/sched/group/group_create.c +++ b/sched/group/group_create.c @@ -30,7 +30,9 @@ #include #include +#include #include +#include #include #include #include @@ -201,6 +203,16 @@ int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype) goto errout_with_group; } + /* Initialize file descriptors for the TCB */ + + files_initlist(&group->tg_filelist); + +#ifdef CONFIG_FILE_STREAM + /* Initialize file streams for the task group */ + + lib_stream_initialize(group); +#endif + #ifndef CONFIG_DISABLE_PTHREAD /* Initialize the pthread join semaphore */ diff --git a/sched/group/group_setupidlefiles.c b/sched/group/group_setupidlefiles.c index 24db33ed7c..d0276ee149 100644 --- a/sched/group/group_setupidlefiles.c +++ b/sched/group/group_setupidlefiles.c @@ -65,10 +65,6 @@ int group_setupidlefiles(FAR struct task_tcb_s *tcb) DEBUGASSERT(group != NULL); - /* Initialize file descriptors for the TCB */ - - files_initlist(&group->tg_filelist); - /* Open stdin, dup to get stdout and stderr. This should always * be the first file opened and, hence, should always get file * descriptor 0. diff --git a/sched/group/group_setupstreams.c b/sched/group/group_setupstreams.c index 20c5127bd4..1ad4eadbe2 100644 --- a/sched/group/group_setupstreams.c +++ b/sched/group/group_setupstreams.c @@ -30,7 +30,6 @@ #include #include -#include #include "group/group.h" @@ -57,10 +56,6 @@ int group_setupstreams(FAR struct task_tcb_s *tcb) { DEBUGASSERT(tcb && tcb->cmn.group); - /* Initialize file streams for the task group */ - - lib_stream_initialize(tcb->cmn.group); - /* fdopen to get the stdin, stdout and stderr streams. The following logic * depends on the fact that the library layer will allocate FILEs in order. * diff --git a/sched/group/group_setuptaskfiles.c b/sched/group/group_setuptaskfiles.c index ca9a8e886b..6352e4ff64 100644 --- a/sched/group/group_setuptaskfiles.c +++ b/sched/group/group_setuptaskfiles.c @@ -68,10 +68,6 @@ int group_setuptaskfiles(FAR struct task_tcb_s *tcb) TCB_FLAG_TTYPE_PTHREAD); #endif - /* Initialize file descriptors for the TCB */ - - files_initlist(&group->tg_filelist); - #ifndef CONFIG_FDCLONE_DISABLE DEBUGASSERT(rtcb->group);