webclient: handle EINTR in a few places

This commit is contained in:
YAMAMOTO Takashi 2021-09-14 13:47:27 +09:00 committed by Xiang Xiao
parent 2add33e6a3
commit 78fb3bc240

View File

@ -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); 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); ssize_t ret = send(conn->sockfd, buffer, len, 0);
if (ret == -1) if (ret == -1)
{ {
if (errno == EINTR)
{
continue;
}
if (errno == EAGAIN) if (errno == EAGAIN)
{ {
conn->flags |= CONN_WANT_WRITE; 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); 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); ssize_t ret = recv(conn->sockfd, buffer, len, 0);
if (ret == -1) if (ret == -1)
{ {
if (errno == EINTR)
{
continue;
}
if (errno == EAGAIN) if (errno == EAGAIN)
{ {
conn->flags |= CONN_WANT_READ; conn->flags |= CONN_WANT_READ;
@ -1059,17 +1071,26 @@ int webclient_perform(FAR struct webclient_context *ctx)
* arbitrary local port that is not in use. * arbitrary local port that is not in use.
*/ */
while (true)
{
ret = connect(conn->sockfd, server_address, ret = connect(conn->sockfd, server_address,
server_address_len); server_address_len);
if (ret == -1) if (ret == -1)
{ {
ret = -errno; ret = -errno;
DEBUGASSERT(ret < 0); DEBUGASSERT(ret < 0);
if (ret == -EINTR)
{
continue;
}
if (ret == -EISCONN) if (ret == -EISCONN)
{ {
ret = 0; ret = 0;
} }
} }
break;
}
} }
if (ret < 0) if (ret < 0)