Browse Source

modify the error check of rt_event_recv()

Han Xinrong 4 years ago
parent
commit
a1fe7b1ddf

+ 7 - 1
bsp/nrf5x/libraries/templates/nrf52x/applications/ble_nus_app.c

@@ -603,7 +603,13 @@ static void _stack_thread(void *parameter)
 
 
         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);
-        RT_ASSERT(result == RT_EOK);
+        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)
         {
         {

+ 14 - 2
components/dfs/filesystems/jffs2/src/gcthread.c

@@ -203,7 +203,13 @@ jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c)
                    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);
-     RT_ASSERT(result == RT_EOK);
+     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.
@@ -230,7 +236,13 @@ jffs2_garbage_collect_thread(unsigned long data)
                         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);
-          RT_ASSERT(result == RT_EOK);
+          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;