mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-19 08:03:30 +08:00
Merge pull request #4134 from Hxinrong/rt_event_recvBranch
add error checks of function rt_event_recv()
This commit is contained in:
commit
32cf867837
@ -599,9 +599,20 @@ static void _stack_thread(void *parameter)
|
|||||||
{
|
{
|
||||||
rt_uint32_t event = 0;
|
rt_uint32_t event = 0;
|
||||||
rt_tick_t dispatch_timeout = RT_WAITING_NO;
|
rt_tick_t dispatch_timeout = RT_WAITING_NO;
|
||||||
|
rt_err_t result;
|
||||||
|
|
||||||
rt_event_recv(stack_event, STACK_EV_DISCON | STACK_EV_DISPATCH | STACK_EV_KEY,
|
result = rt_event_recv(stack_event, STACK_EV_DISCON | STACK_EV_DISPATCH | STACK_EV_KEY,
|
||||||
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, next_timeout, &event);
|
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, next_timeout, &event);
|
||||||
|
if (result == -RT_ETIMEOUT)
|
||||||
|
{
|
||||||
|
LOG_E("wait completed timeout");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (result == -RT_ERROR)
|
||||||
|
{
|
||||||
|
LOG_E("event received error");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (evt_dispatch_worker() != RT_EOK)
|
if (evt_dispatch_worker() != RT_EOK)
|
||||||
{
|
{
|
||||||
|
@ -187,7 +187,8 @@ jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c)
|
|||||||
{
|
{
|
||||||
struct super_block *sb=OFNI_BS_2SFFJ(c);
|
struct super_block *sb=OFNI_BS_2SFFJ(c);
|
||||||
cyg_mtab_entry *mte;
|
cyg_mtab_entry *mte;
|
||||||
rt_uint32_t e;
|
rt_uint32_t e;
|
||||||
|
rt_err_t result;
|
||||||
|
|
||||||
//RT_ASSERT(sb->s_gc_thread_handle);
|
//RT_ASSERT(sb->s_gc_thread_handle);
|
||||||
|
|
||||||
@ -198,10 +199,20 @@ jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c)
|
|||||||
|
|
||||||
D1(printk("jffs2_stop_garbage_collect_thread wait\n"));
|
D1(printk("jffs2_stop_garbage_collect_thread wait\n"));
|
||||||
|
|
||||||
rt_event_recv(&sb->s_gc_thread_flags,
|
result = rt_event_recv(&sb->s_gc_thread_flags,
|
||||||
GC_THREAD_FLAG_HAS_EXIT,
|
GC_THREAD_FLAG_HAS_EXIT,
|
||||||
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,
|
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,
|
||||||
RT_WAITING_FOREVER, &e);
|
RT_WAITING_FOREVER, &e);
|
||||||
|
if (result == -RT_ETIMEOUT)
|
||||||
|
{
|
||||||
|
LOG_E("wait completed timeout");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (result == -RT_ERROR)
|
||||||
|
{
|
||||||
|
LOG_E("event received error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Kill and free the resources ... this is safe due to the flag
|
// Kill and free the resources ... this is safe due to the flag
|
||||||
// from the thread.
|
// from the thread.
|
||||||
@ -218,15 +229,26 @@ jffs2_garbage_collect_thread(unsigned long data)
|
|||||||
struct super_block *sb=OFNI_BS_2SFFJ(c);
|
struct super_block *sb=OFNI_BS_2SFFJ(c);
|
||||||
cyg_mtab_entry *mte;
|
cyg_mtab_entry *mte;
|
||||||
rt_uint32_t flag = 0;
|
rt_uint32_t flag = 0;
|
||||||
|
rt_err_t result;
|
||||||
|
|
||||||
D1(printk("jffs2_garbage_collect_thread START\n"));
|
D1(printk("jffs2_garbage_collect_thread START\n"));
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
rt_event_recv(&sb->s_gc_thread_flags,
|
result = rt_event_recv(&sb->s_gc_thread_flags,
|
||||||
GC_THREAD_FLAG_TRIG | GC_THREAD_FLAG_STOP,
|
GC_THREAD_FLAG_TRIG | GC_THREAD_FLAG_STOP,
|
||||||
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,
|
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,
|
||||||
cyg_current_time() + CYGNUM_JFFS2_GS_THREAD_TICKS,
|
cyg_current_time() + CYGNUM_JFFS2_GS_THREAD_TICKS,
|
||||||
&flag);
|
&flag);
|
||||||
|
if (result == -RT_ETIMEOUT)
|
||||||
|
{
|
||||||
|
LOG_E("wait completed timeout");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (result == -RT_ERROR)
|
||||||
|
{
|
||||||
|
LOG_E("event received error");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (flag & GC_THREAD_FLAG_STOP)
|
if (flag & GC_THREAD_FLAG_STOP)
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user