]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Plus/Source/FreeRTOS-Plus-UDP/FreeRTOS_Sockets.c
Ensure the private port number wrap check is inside the critical section in prvGetPri...
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-UDP / FreeRTOS_Sockets.c
index 4ce79b1c4bf447a5e25f4a105be4ec2bb270f814..5c9ff73dec19cd34f32c0a7062b5a87dc86e0ca1 100644 (file)
@@ -932,17 +932,19 @@ uint16_t usReturn;
 \r
        /* Assign the next port in the range. */\r
        taskENTER_CRITICAL();\r
+       {\r
                usNextPortToUse++;\r
-       taskEXIT_CRITICAL();\r
 \r
-       /* Has it overflowed? */\r
-       if( usNextPortToUse == 0U )\r
-       {\r
-               /* Don't go right back to the start of the dynamic/private port\r
-               range numbers as any persistent sockets are likely to have been\r
-               create first so the early port numbers may still be in use. */\r
-               usNextPortToUse = socketAUTO_PORT_ALLOCATION_RESET_NUMBER;\r
+               /* Has it overflowed? */\r
+               if( usNextPortToUse == 0U )\r
+               {\r
+                       /* Don't go right back to the start of the dynamic/private port\r
+                       range numbers as any persistent sockets are likely to have been\r
+                       create first so the early port numbers may still be in use. */\r
+                       usNextPortToUse = socketAUTO_PORT_ALLOCATION_RESET_NUMBER;\r
+               }\r
        }\r
+       taskEXIT_CRITICAL();\r
 \r
        usReturn = FreeRTOS_htons( usNextPortToUse );\r
 \r