apps: Fix the bug that setsockopt didn't check return value
Signed-off-by: weizihan <weizihan@xiaomi.com>
This commit is contained in:
parent
a9f6d66888
commit
9dd3055014
@ -1417,10 +1417,27 @@ int webclient_perform(FAR struct webclient_context *ctx)
|
|||||||
tv.tv_sec = ctx->timeout_sec;
|
tv.tv_sec = ctx->timeout_sec;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
setsockopt(conn->sockfd, SOL_SOCKET, SO_RCVTIMEO,
|
/* Check return value one by one */
|
||||||
(FAR const void *)&tv, sizeof(struct timeval));
|
|
||||||
setsockopt(conn->sockfd, SOL_SOCKET, SO_SNDTIMEO,
|
ret = setsockopt(conn->sockfd, SOL_SOCKET, SO_RCVTIMEO,
|
||||||
(FAR const void *)&tv, sizeof(struct timeval));
|
(FAR const void *)&tv,
|
||||||
|
sizeof(struct timeval));
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
ret = -errno;
|
||||||
|
nerr("ERROR: setsockopt failed: %d\n", ret);
|
||||||
|
goto errout_with_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = setsockopt(conn->sockfd, SOL_SOCKET, SO_SNDTIMEO,
|
||||||
|
(FAR const void *)&tv,
|
||||||
|
sizeof(struct timeval));
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
ret = -errno;
|
||||||
|
nerr("ERROR: setsockopt failed: %d\n", ret);
|
||||||
|
goto errout_with_errno;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user