mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-26 14:41:25 +00:00
Fix compatibility with ENOTSUP and Darwin
Darwin uses also the constant EOPNOTSUPP for the same reasons. In some versions EOPNOTSUPP is defined as ENOTSUP. Check both values, not only ENOTSUP. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
parent
90453ddf06
commit
4f82cec197
@ -39,6 +39,12 @@
|
||||
#define TCP_KEEPIDLE TCP_KEEPALIVE
|
||||
#endif
|
||||
|
||||
#if defined(EOPNOTSUPP) && EOPNOTSUPP != ENOTSUP
|
||||
#define NOTSUP_ERROR(err) ((err) == ENOTSUP || (err) == EOPNOTSUPP)
|
||||
#else
|
||||
#define NOTSUP_ERROR(err) ((err) == ENOTSUP)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* red_socket_set_keepalive:
|
||||
* @fd: a socket file descriptor
|
||||
@ -51,7 +57,7 @@ bool red_socket_set_keepalive(int fd, bool enable, int timeout)
|
||||
int keepalive = !!enable;
|
||||
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof(keepalive)) == -1) {
|
||||
if (errno != ENOTSUP) {
|
||||
if (!NOTSUP_ERROR(errno)) {
|
||||
g_warning("setsockopt for keepalive failed, %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
@ -63,7 +69,7 @@ bool red_socket_set_keepalive(int fd, bool enable, int timeout)
|
||||
|
||||
#ifdef TCP_KEEPIDLE
|
||||
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &timeout, sizeof(timeout)) == -1) {
|
||||
if (errno != ENOTSUP) {
|
||||
if (!NOTSUP_ERROR(errno)) {
|
||||
g_warning("setsockopt for keepalive timeout failed, %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
@ -86,7 +92,7 @@ bool red_socket_set_no_delay(int fd, bool no_delay)
|
||||
|
||||
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY,
|
||||
&optval, sizeof(optval)) != 0) {
|
||||
if (errno != ENOTSUP && errno != ENOPROTOOPT) {
|
||||
if (!NOTSUP_ERROR(errno) && errno != ENOPROTOOPT) {
|
||||
spice_warning("setsockopt failed, %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user