diff --git a/kernel/compat.h b/kernel/compat.h index dd5090c1..e8b9a311 100644 --- a/kernel/compat.h +++ b/kernel/compat.h @@ -238,6 +238,12 @@ extern int _compat_unlink( #define __HAS_STRUCT_NET #endif +/* adapt to a9beb86ae6e55bd92f38453c8623de60b8e5a308 + */ +#ifdef SO_SNDTIMEO_NEW +#define MARS_HAS_SO_SNDTIMEO_NEW +#endif + /* for crypto stuff */ #include diff --git a/kernel/mars_aio.c b/kernel/mars_aio.c index 4891d3bf..ea70579d 100644 --- a/kernel/mars_aio.c +++ b/kernel/mars_aio.c @@ -672,11 +672,19 @@ static int aio_event_thread(void *data) mm_segment_t oldfs; int count; 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 = { .tv_nsec = tinfo->should_terminate || !brick->power.button ? 0 : 100000, }; +#endif if (unlikely(!(void*)output->ctxp)) { MARS_ERR("Oops, context vanished. queued_sum = %d\n", atomic_read(&tinfo->queued_sum)); diff --git a/kernel/mars_net.c b/kernel/mars_net.c index c93ba6ac..39062afd 100644 --- a/kernel/mars_net.c +++ b/kernel/mars_net.c @@ -193,9 +193,15 @@ static int current_debug_nr = 0; // no locking, just for debugging static 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 = { .tv_sec = params->tcp_timeout, }; +#endif int x_true = 1; /* 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_KEEPINTVL, params->tcp_keepintvl); _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_RCVTIMEO, t); +#endif } int mars_create_socket(struct mars_socket *msock,