diff --git a/sched/group/group_create.c b/sched/group/group_create.c index fe7533629a61b..87727f84c0312 100644 --- a/sched/group/group_create.c +++ b/sched/group/group_create.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -165,14 +164,6 @@ int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype) group->tg_mxmembers = GROUP_INITIAL_MEMBERS; #endif - /* Alloc task info for group */ - - ret = task_init_info(group); - if (ret < 0) - { - goto errout_with_member; - } - /* Attach the group to the TCB */ tcb->cmn.group = group; @@ -185,11 +176,13 @@ int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype) files_initlist(&group->tg_filelist); -#ifdef CONFIG_FILE_STREAM - /* Initialize file streams for the task group */ + /* Alloc task info for group */ - lib_stream_initialize(group); -#endif + ret = task_init_info(group); + if (ret < 0) + { + goto errout_with_member; + } #ifndef CONFIG_DISABLE_PTHREAD /* Initialize the pthread join mutex */ diff --git a/sched/group/group_leave.c b/sched/group/group_leave.c index 2b1d11fdc0e33..309eeb9169ac6 100644 --- a/sched/group/group_leave.c +++ b/sched/group/group_leave.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #ifdef CONFIG_BINFMT_LOADABLE @@ -156,12 +155,6 @@ static inline void group_release(FAR struct task_group_s *group) pthread_release(group); #endif -#ifdef CONFIG_FILE_STREAM - /* Free resource held by the stream list */ - - lib_stream_release(group); -#endif /* CONFIG_FILE_STREAM */ - /* Free all file-related resources now. We really need to close files as * soon as possible while we still have a functioning task. */ diff --git a/sched/tls/task_initinfo.c b/sched/tls/task_initinfo.c index d7983b9197c32..88ded47c3d66b 100644 --- a/sched/tls/task_initinfo.c +++ b/sched/tls/task_initinfo.c @@ -26,6 +26,7 @@ #include #include +#include #include "tls.h" @@ -64,5 +65,11 @@ int task_init_info(FAR struct task_group_s *group) nxmutex_init(&info->ta_lock); group->tg_info = info; +#ifdef CONFIG_FILE_STREAM + /* Initialize file streams for the task group */ + + lib_stream_initialize(group); +#endif + return OK; } diff --git a/sched/tls/task_uninitinfo.c b/sched/tls/task_uninitinfo.c index 6c28b90559c37..42bf6c23e73cd 100644 --- a/sched/tls/task_uninitinfo.c +++ b/sched/tls/task_uninitinfo.c @@ -24,6 +24,7 @@ #include #include +#include #include "tls.h" @@ -49,6 +50,12 @@ void task_uninit_info(FAR struct task_group_s *group) { FAR struct task_info_s *info = group->tg_info; +#ifdef CONFIG_FILE_STREAM + /* Free resource held by the stream list */ + + lib_stream_release(group); +#endif /* CONFIG_FILE_STREAM */ + nxmutex_destroy(&info->ta_lock); group_free(group, info); }