recursion in ip server(windows) fix 26/29826/1
authorOleksandr Dmytrenko <o.dmytrenko@samsung.com>
Mon, 7 Oct 2019 13:42:42 +0000 (16:42 +0300)
committerOleksandr Dmytrenko <o.dmytrenko@samsung.com>
Mon, 7 Oct 2019 13:42:42 +0000 (16:42 +0300)
1)cause recursion fix:
        ERROR: OIC_CA_IP_SERVER: secure unicast ipv6 sendTo failed: 10014
        DEBUG: OIC_CA_INF_CTR: received error from adapter in interfacecontroller
2)time in cases WSAENOBUFS and WSAEWOULDBLOCK
3)logging fix

Change-Id: I9e680a0bb43a327a77ce4dca7264cad5aaeb8615
Signed-off-by: Oleksandr Dmytrenko <o.dmytrenko@samsung.com>
resource/csdk/connectivity/src/ip_adapter/caipserver.c

index 024505f..fdf958b 100644 (file)
@@ -1436,10 +1436,12 @@ static void sendData(CASocketFd_t fd, const CAEndpoint_t *endpoint,
                            len, true, NULL);
     }
 #else
-    int err = 0;
+    #define SOCKET_ERROR_WAIT 300
     int len = 0;
     size_t sent = 0;
+    int err;
     do {
+        err = 0;
         int dataToSend = ((dlen - sent) > INT_MAX) ? INT_MAX : (int)(dlen - sent);
         len = sendto(fd, ((char*)data) + sent, dataToSend, 0, (struct sockaddr *)&sock, socklen);
         if (OC_SOCKET_ERROR == len)
@@ -1447,14 +1449,17 @@ static void sendData(CASocketFd_t fd, const CAEndpoint_t *endpoint,
             err = WSAGetLastError();
             if ((WSAEWOULDBLOCK != err) && (WSAENOBUFS != err))
             {
+                OIC_LOG_V(ERROR, TAG, "%s%s %s sendTo failed: %i", secure, cast, fam, err);
                  // If logging is not defined/enabled.
                 if (g_ipErrorHandler)
                 {
                     g_ipErrorHandler(endpoint, data, dlen, CA_SEND_FAILED);
                 }
-
-                OIC_LOG_V(ERROR, TAG, "%s%s %s sendTo failed: %i", secure, cast, fam, err);
+                break;
             }
+            OIC_LOG_V(WARNING, TAG, "%s%s %s sendTo failed: %s", secure, cast, fam,
+                err == WSAEWOULDBLOCK ? "Resource temporarily unavailable." : "No buffer space available." );
+            Sleep(SOCKET_ERROR_WAIT);
         }
         else
         {