all: adapt to SO_SNDTIMEO_NEW

This commit is contained in:
Thomas Schoebel-Theuer 2021-01-30 09:00:38 +01:00
parent d0c5b5699f
commit 5237ca4b16
3 changed files with 25 additions and 0 deletions

View File

@ -238,6 +238,12 @@ extern int _compat_unlink(
#define __HAS_STRUCT_NET #define __HAS_STRUCT_NET
#endif #endif
/* adapt to a9beb86ae6e55bd92f38453c8623de60b8e5a308
*/
#ifdef SO_SNDTIMEO_NEW
#define MARS_HAS_SO_SNDTIMEO_NEW
#endif
/* for crypto stuff */ /* for crypto stuff */
#include <linux/crypto.h> #include <linux/crypto.h>

View File

@ -672,11 +672,19 @@ static int aio_event_thread(void *data)
mm_segment_t oldfs; mm_segment_t oldfs;
int count; int count;
int i; int i;
#ifdef MARS_HAS_SO_SNDTIMEO_NEW
struct __kernel_timespec timeout = {
.tv_nsec =
tinfo->should_terminate ||
!brick->power.button ? 0 : 100000,
};
#else
struct timespec timeout = { struct timespec timeout = {
.tv_nsec = .tv_nsec =
tinfo->should_terminate || tinfo->should_terminate ||
!brick->power.button ? 0 : 100000, !brick->power.button ? 0 : 100000,
}; };
#endif
if (unlikely(!(void*)output->ctxp)) { if (unlikely(!(void*)output->ctxp)) {
MARS_ERR("Oops, context vanished. queued_sum = %d\n", atomic_read(&tinfo->queued_sum)); MARS_ERR("Oops, context vanished. queued_sum = %d\n", atomic_read(&tinfo->queued_sum));

View File

@ -193,9 +193,15 @@ static int current_debug_nr = 0; // no locking, just for debugging
static static
void _set_socketopts(struct socket *sock, struct mars_tcp_params *params, bool is_server) void _set_socketopts(struct socket *sock, struct mars_tcp_params *params, bool is_server)
{ {
#ifdef MARS_HAS_SO_SNDTIMEO_NEW
struct __kernel_sock_timeval t = {
.tv_sec = params->tcp_timeout,
};
#else
struct timeval t = { struct timeval t = {
.tv_sec = params->tcp_timeout, .tv_sec = params->tcp_timeout,
}; };
#endif
int x_true = 1; int x_true = 1;
/* TODO: improve this by a table-driven approach /* TODO: improve this by a table-driven approach
@ -216,8 +222,13 @@ void _set_socketopts(struct socket *sock, struct mars_tcp_params *params, bool i
_setsockopt(sock, IPPROTO_TCP, TCP_KEEPCNT, params->tcp_keepcnt); _setsockopt(sock, IPPROTO_TCP, TCP_KEEPCNT, params->tcp_keepcnt);
_setsockopt(sock, IPPROTO_TCP, TCP_KEEPINTVL, params->tcp_keepintvl); _setsockopt(sock, IPPROTO_TCP, TCP_KEEPINTVL, params->tcp_keepintvl);
_setsockopt(sock, IPPROTO_TCP, TCP_KEEPIDLE, params->tcp_keepidle); _setsockopt(sock, IPPROTO_TCP, TCP_KEEPIDLE, params->tcp_keepidle);
#ifdef MARS_HAS_SO_SNDTIMEO_NEW
_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO_NEW, t);
_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO_NEW, t);
#else
_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, t); _setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, t);
_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, t); _setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, t);
#endif
} }
int mars_create_socket(struct mars_socket *msock, int mars_create_socket(struct mars_socket *msock,