Explorar o código

fix: 销毁socket函数线程锁问题

ryancw hai 1 ano
pai
achega
e74cb8e47e
Modificáronse 1 ficheiros con 6 adicións e 4 borrados
  1. 6 4
      W5500Client/RyanW5500Socket.c

+ 6 - 4
W5500Client/RyanW5500Socket.c

@@ -308,15 +308,17 @@ static void RyanW5500ListenSocketDestory(RyanW5500Socket *sock)
 
 static int RyanW5500SocketDestory(RyanW5500Socket *sock)
 {
-
     RT_ASSERT(NULL != sock);
 
-    if (sock->magic != WIZ_SOCKET_MAGIC)
-        return -1;
-
     rlog_d("销毁套接字");
     rt_mutex_take(RyanW5500Entry.socketMutexHandle, RT_WAITING_FOREVER); //
 
+    if (sock->magic != WIZ_SOCKET_MAGIC)
+    {
+        rt_mutex_release(RyanW5500Entry.socketMutexHandle); // 释放互斥锁
+        return -1;
+    }
+
     if (sock->recvLock)
         rt_mutex_delete(sock->recvLock);