net: sockets: Ignore error if there is none

Seen when having multiple network interfaces that the sock_error
was 0 even if the socket was serviced properly. So if SO_ERROR
returns 0, just ignore it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
Jukka Rissanen 2024-10-16 14:54:11 +03:00 committed by Carles Cufí
parent 8e866e95c8
commit 11fae015e0
1 changed files with 6 additions and 3 deletions

View File

@ -140,9 +140,12 @@ static int recv_data(struct net_socket_service_event *pev)
(pev->event.revents & ZSOCK_POLLNVAL)) {
(void)zsock_getsockopt(pev->event.fd, SOL_SOCKET,
SO_ERROR, &sock_error, &optlen);
NET_ERR("Receiver IPv%d socket error (%d)",
family == AF_INET ? 4 : 6, sock_error);
ret = DNS_EAI_SYSTEM;
if (sock_error > 0) {
NET_ERR("Receiver IPv%d socket error (%d)",
family == AF_INET ? 4 : 6, sock_error);
ret = DNS_EAI_SYSTEM;
}
goto unlock;
}