This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 78fb3bc  webclient: handle EINTR in a few places
78fb3bc is described below

commit 78fb3bc2401edb75edbd7fcb29a4c41e7c1907f2
Author: YAMAMOTO Takashi <[email protected]>
AuthorDate: Tue Sep 14 13:47:27 2021 +0900

    webclient: handle EINTR in a few places
---
 netutils/webclient/webclient.c | 39 ++++++++++++++++++++++++++++++---------
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/netutils/webclient/webclient.c b/netutils/webclient/webclient.c
index bc5eb38..570f622 100644
--- a/netutils/webclient/webclient.c
+++ b/netutils/webclient/webclient.c
@@ -265,11 +265,17 @@ static ssize_t conn_send(struct webclient_context *ctx, 
struct conn_s *conn,
     {
       return ctx->tls_ops->send(ctx->tls_ctx, conn->tls_conn, buffer, len);
     }
-  else
+
+  while (true)
     {
       ssize_t ret = send(conn->sockfd, buffer, len, 0);
       if (ret == -1)
         {
+          if (errno == EINTR)
+            {
+              continue;
+            }
+
           if (errno == EAGAIN)
             {
               conn->flags |= CONN_WANT_WRITE;
@@ -293,11 +299,17 @@ static ssize_t conn_recv(struct webclient_context *ctx, 
struct conn_s *conn,
     {
       return ctx->tls_ops->recv(ctx->tls_ctx, conn->tls_conn, buffer, len);
     }
-  else
+
+  while (true)
     {
       ssize_t ret = recv(conn->sockfd, buffer, len, 0);
       if (ret == -1)
         {
+          if (errno == EINTR)
+            {
+              continue;
+            }
+
           if (errno == EAGAIN)
             {
               conn->flags |= CONN_WANT_READ;
@@ -1059,16 +1071,25 @@ int webclient_perform(FAR struct webclient_context *ctx)
                * arbitrary local port that is not in use.
                */
 
-              ret = connect(conn->sockfd, server_address,
-                            server_address_len);
-              if (ret == -1)
+              while (true)
                 {
-                  ret = -errno;
-                  DEBUGASSERT(ret < 0);
-                  if (ret == -EISCONN)
+                  ret = connect(conn->sockfd, server_address,
+                                server_address_len);
+                  if (ret == -1)
                     {
-                      ret = 0;
+                      ret = -errno;
+                      DEBUGASSERT(ret < 0);
+                      if (ret == -EINTR)
+                        {
+                          continue;
+                        }
+
+                      if (ret == -EISCONN)
+                        {
+                          ret = 0;
+                        }
                     }
+                  break;
                 }
             }
 

Reply via email to