From 2cd580f50061971e9ac22ecdd76c89f313fe80d0 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 14 Apr 2020 11:26:45 +0800 Subject: [PATCH] For #307, disable GSO < linux 4.18.0 --- trunk/src/app/srs_app_config.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index f7f69a381..39ef44a76 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -33,6 +33,10 @@ #include #include #include +#ifdef __linux__ +#include +#include +#endif #include #include @@ -4805,12 +4809,25 @@ bool SrsConfig::get_rtc_server_gso() bool v = SRS_CONF_PERFER_FALSE(conf->arg0()); -#ifdef SRS_AUTO_OSX - if (v) { - srs_warn("GSO is for Linux only"); - } - v = false; + bool gso_disabled = false; +#if !defined(__linux__) + gso_disabled = true; + srs_warn("GSO is for Linux 4.18+ only"); +#else + #if LINUX_VERSION_CODE < KERNEL_VERSION(4,18,0) + utsname un = {0}; + int r0 = uname(&un); + if (r0 || strcmp(un.release, "4.18.0") < 0) { + gso_disabled = true; + } + srs_warn("GSO is for Linux 4.18+ only, r0=%d, %s", r0, un.release); + #endif #endif + + if (v && gso_disabled) { + v = false; + } + return v; }