Procházet zdrojové kódy

【完善】添加链表操作前关闭中断操作

SummerGift před 6 roky
rodič
revize
28d0f70e7c
1 změnil soubory, kde provedl 12 přidání a 0 odebrání
  1. 12 0
      src/lssdp_service.c

+ 12 - 0
src/lssdp_service.c

@@ -28,6 +28,9 @@ static int lssdp_service_register(struct lssdp_service *h)
     if (h == RT_NULL)
         return -RT_ERROR;
 
+    /* enter interrupt */
+    rt_interrupt_enter();
+
     rt_slist_for_each(head, &_lssdp_list)
     {
         if (rt_strcmp(h->name, ((lssdp_service_t)head)->name) == 0)
@@ -40,6 +43,9 @@ static int lssdp_service_register(struct lssdp_service *h)
     rt_slist_init(&h->list);
     rt_slist_append(&_lssdp_list, &h->list);
 
+    /* leave interrupt */
+    rt_interrupt_leave();
+
     return RT_EOK;
 }
 
@@ -51,6 +57,9 @@ static int lssdp_service_unregister(struct lssdp_service *h)
     if (h == RT_NULL)
         return -RT_ERROR;
 
+    /* enter interrupt */
+    rt_interrupt_enter();
+
     rt_slist_for_each(head, &_lssdp_list)
     {
         if (rt_strcmp(h->name, ((lssdp_service_t)head)->name) == 0)
@@ -61,6 +70,9 @@ static int lssdp_service_unregister(struct lssdp_service *h)
         }
     }
 
+    /* leave interrupt */
+    rt_interrupt_leave();
+
     LOG_E("Can't find service name %s to unregister", h->name);
 
     return -RT_ERROR;