Fix error propagation (#86)

Fix error propagation for getsockopt
This commit is contained in:
Sergi Vladykin 2022-07-25 00:20:46 -07:00 committed by GitHub
parent 3085b274e3
commit 871e848045
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -418,7 +418,11 @@ int sc_sock_finish_connect(struct sc_sock *s)
socklen_t len = sizeof(ret);
rc = getsockopt(s->fdt.fd, SOL_SOCKET, SO_ERROR, (void *) &ret, &len);
if (rc != 0 || ret != 0) {
if (rc == 0 && ret != 0) {
errno = ret;
rc = -1;
}
if (rc != 0) {
sc_sock_errstr(s, 0);
return -1;
}