Minor compatibility with FreeBSD system

Some additional header are needed to avoid undefined types.
SOL_TCP and IPPROTO_TCP have the same value in Linux but SOL_TCP
is not defined in FreeBSD.
Provide pthread_setname_np using pthread_set_name_np (same parameters).

Patch is based on a patch from Oleg Ginzburg <olevole@olevole.ru>

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Frediano Ziglio 2018-01-10 08:50:06 +00:00
parent aac2460164
commit 7a25e46c8b
5 changed files with 14 additions and 3 deletions

View File

@ -49,7 +49,7 @@ AM_PROG_CC_C_O
AC_C_BIGENDIAN
PKG_PROG_PKG_CONFIG
AC_CHECK_HEADERS([sys/time.h execinfo.h linux/sockios.h])
AC_CHECK_HEADERS([sys/time.h execinfo.h linux/sockios.h pthread_np.h])
AC_CHECK_DECL([TCP_KEEPIDLE], [have_tcp_keepidle="yes"],,
[#include <netinet/tcp.h>])
AS_IF([test "x$have_tcp_keepidle" = "xyes"],

View File

@ -23,6 +23,9 @@
#include <fcntl.h>
#include <stdbool.h>
#include <string.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
@ -54,7 +57,7 @@ bool red_socket_set_keepalive(int fd, bool enable, int timeout)
}
#ifdef HAVE_TCP_KEEPIDLE
if (setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &timeout, sizeof(timeout)) == -1) {
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &timeout, sizeof(timeout)) == -1) {
if (errno != ENOTSUP) {
spice_printerr("setsockopt for keepalive timeout failed, %s", strerror(errno));
return false;

View File

@ -47,6 +47,12 @@
#include "cursor-channel.h"
#include "tree.h"
// compatibility for FreeBSD
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
#define pthread_setname_np pthread_set_name_np
#endif
#define CMD_RING_POLL_TIMEOUT 10 //milli
#define CMD_RING_POLL_RETRIES 1

View File

@ -22,6 +22,8 @@
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>

View File

@ -22,7 +22,7 @@
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <wait.h>
#include <sys/wait.h>
#include <sys/select.h>
#include <sys/types.h>
#include <getopt.h>