net/sockopt: do not set the errno to SO_ERROR

SO_ERROR is used to report asynchronous errors that are the result
of events within the network stack and not synchronous errors that
are the result of a library call(send/recv/connect)

Synchronous results are reported via errno.

Linux Programmer's Manual
...
NAME
       getsockopt, setsockopt - get and set options on sockets
...
RETURN VALUE
...
       On error, -1 is returned, and errno is set appropriately

Change-Id: I1a1a05a684dff8672aaf47eabee157ac0d275c2d
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2020-05-13 12:08:32 +08:00 committed by patacongo
parent 0bd5dda2a3
commit 608436a75f
2 changed files with 2 additions and 2 deletions

View File

@ -445,7 +445,7 @@ int getsockopt(int sockfd, int level, int option, void *value, socklen_t *value_
ret = psock_getsockopt(psock, level, option, value, value_len);
if (ret < 0)
{
_SO_SETERRNO(psock, -ret);
set_errno(-ret);
return ERROR;
}

View File

@ -470,7 +470,7 @@ int setsockopt(int sockfd, int level, int option, const void *value,
ret = psock_setsockopt(psock, level, option, value, value_len);
if (ret < 0)
{
_SO_SETERRNO(psock, -ret);
set_errno(-ret);
return ERROR;
}