mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
Merge branch '3.0release' into 4.0release
This commit is contained in:
commit
ef2b123325
9 changed files with 68 additions and 15 deletions
|
@ -163,6 +163,8 @@ For previous versions, please read:
|
||||||
|
|
||||||
## V3 changes
|
## V3 changes
|
||||||
|
|
||||||
|
* v3.0, 2020-02-21, For [#1598][bug #1598], support SLB health checking by TCP. 3.0.123
|
||||||
|
* v3.0, 2020-02-21, Fix bug for librtmp client ipv4/ipv6 socket. 3.0.122
|
||||||
* v3.0, 2020-02-18, For [#1579][bug #1579], support start/final wait for gracefully quit. 3.0.121
|
* v3.0, 2020-02-18, For [#1579][bug #1579], support start/final wait for gracefully quit. 3.0.121
|
||||||
* v3.0, 2020-02-18, For [#1579][bug #1579], support force gracefully quit. 3.0.120
|
* v3.0, 2020-02-18, For [#1579][bug #1579], support force gracefully quit. 3.0.120
|
||||||
* v3.0, 2020-02-18, For [#1579][bug #1579], support gracefully quit. 3.0.119
|
* v3.0, 2020-02-18, For [#1579][bug #1579], support gracefully quit. 3.0.119
|
||||||
|
@ -1681,6 +1683,7 @@ Winlin
|
||||||
[bug #1595]: https://github.com/ossrs/srs/issues/1595
|
[bug #1595]: https://github.com/ossrs/srs/issues/1595
|
||||||
[bug #1601]: https://github.com/ossrs/srs/issues/1601
|
[bug #1601]: https://github.com/ossrs/srs/issues/1601
|
||||||
[bug #1579]: https://github.com/ossrs/srs/issues/1579
|
[bug #1579]: https://github.com/ossrs/srs/issues/1579
|
||||||
|
[bug #1598]: https://github.com/ossrs/srs/issues/1598
|
||||||
[bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx
|
[bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx
|
||||||
|
|
||||||
[exo #828]: https://github.com/google/ExoPlayer/pull/828
|
[exo #828]: https://github.com/google/ExoPlayer/pull/828
|
||||||
|
|
|
@ -72,6 +72,10 @@ work_dir ./;
|
||||||
# @reamrk do not support reload.
|
# @reamrk do not support reload.
|
||||||
# default: off
|
# default: off
|
||||||
asprocess off;
|
asprocess off;
|
||||||
|
# Whether client empty IP is ok, for example, health checking by SLB.
|
||||||
|
# If ok(on), we will ignore this connection without warnings or errors.
|
||||||
|
# default: on
|
||||||
|
empty_ip_ok on;
|
||||||
|
|
||||||
# For gracefully quit, wait for a while then close listeners,
|
# For gracefully quit, wait for a while then close listeners,
|
||||||
# because K8S notify SRS with SIGQUIT and update Service simultaneously,
|
# because K8S notify SRS with SIGQUIT and update Service simultaneously,
|
||||||
|
|
|
@ -78,6 +78,10 @@ srs_error_t SrsAppCasterFlv::on_tcp_client(srs_netfd_t stfd)
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
string ip = srs_get_peer_ip(srs_netfd_fileno(stfd));
|
string ip = srs_get_peer_ip(srs_netfd_fileno(stfd));
|
||||||
|
if (ip.empty() && !_srs_config->empty_ip_ok()) {
|
||||||
|
srs_warn("empty ip for fd=%d", srs_netfd_fileno(stfd));
|
||||||
|
}
|
||||||
|
|
||||||
SrsHttpConn* conn = new SrsDynamicHttpConn(this, stfd, http_mux, ip);
|
SrsHttpConn* conn = new SrsDynamicHttpConn(this, stfd, http_mux, ip);
|
||||||
conns.push_back(conn);
|
conns.push_back(conn);
|
||||||
|
|
||||||
|
|
|
@ -3489,7 +3489,7 @@ srs_error_t SrsConfig::check_normal_config()
|
||||||
&& n != "http_server" && n != "stream_caster" && n != "srt_server"
|
&& n != "http_server" && n != "stream_caster" && n != "srt_server"
|
||||||
&& n != "utc_time" && n != "work_dir" && n != "asprocess"
|
&& n != "utc_time" && n != "work_dir" && n != "asprocess"
|
||||||
&& n != "ff_log_level" && n != "grace_final_wait" && n != "force_grace_quit"
|
&& n != "ff_log_level" && n != "grace_final_wait" && n != "force_grace_quit"
|
||||||
&& n != "grace_start_wait"
|
&& n != "grace_start_wait" && n != "empty_ip_ok"
|
||||||
) {
|
) {
|
||||||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal directive %s", n.c_str());
|
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal directive %s", n.c_str());
|
||||||
}
|
}
|
||||||
|
@ -4065,6 +4065,18 @@ bool SrsConfig::get_asprocess()
|
||||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SrsConfig::empty_ip_ok()
|
||||||
|
{
|
||||||
|
static bool DEFAULT = true;
|
||||||
|
|
||||||
|
SrsConfDirective* conf = root->get("empty_ip_ok");
|
||||||
|
if (!conf || conf->arg0().empty()) {
|
||||||
|
return DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SRS_CONF_PERFER_TRUE(conf->arg0());
|
||||||
|
}
|
||||||
|
|
||||||
srs_utime_t SrsConfig::get_grace_start_wait()
|
srs_utime_t SrsConfig::get_grace_start_wait()
|
||||||
{
|
{
|
||||||
static srs_utime_t DEFAULT = 2300 * SRS_UTIME_MILLISECONDS;
|
static srs_utime_t DEFAULT = 2300 * SRS_UTIME_MILLISECONDS;
|
||||||
|
|
|
@ -468,6 +468,8 @@ public:
|
||||||
virtual std::string get_work_dir();
|
virtual std::string get_work_dir();
|
||||||
// Whether use asprocess mode.
|
// Whether use asprocess mode.
|
||||||
virtual bool get_asprocess();
|
virtual bool get_asprocess();
|
||||||
|
// Whether empty client IP is ok.
|
||||||
|
virtual bool empty_ip_ok();
|
||||||
// Get the start wait in ms for gracefully quit.
|
// Get the start wait in ms for gracefully quit.
|
||||||
virtual srs_utime_t get_grace_start_wait();
|
virtual srs_utime_t get_grace_start_wait();
|
||||||
// Get the final wait in ms for gracefully quit.
|
// Get the final wait in ms for gracefully quit.
|
||||||
|
|
|
@ -246,6 +246,9 @@ srs_error_t SrsRtspConn::do_cycle()
|
||||||
|
|
||||||
// retrieve ip of client.
|
// retrieve ip of client.
|
||||||
std::string ip = srs_get_peer_ip(srs_netfd_fileno(stfd));
|
std::string ip = srs_get_peer_ip(srs_netfd_fileno(stfd));
|
||||||
|
if (ip.empty() && !_srs_config->empty_ip_ok()) {
|
||||||
|
srs_warn("empty ip for fd=%d", srs_netfd_fileno(stfd));
|
||||||
|
}
|
||||||
srs_trace("rtsp: serve %s", ip.c_str());
|
srs_trace("rtsp: serve %s", ip.c_str());
|
||||||
|
|
||||||
// consume all rtsp messages.
|
// consume all rtsp messages.
|
||||||
|
|
|
@ -1232,6 +1232,10 @@ srs_error_t SrsServer::accept_client(SrsListenerType type, srs_netfd_t stfd)
|
||||||
SrsConnection* conn = NULL;
|
SrsConnection* conn = NULL;
|
||||||
|
|
||||||
if ((err = fd2conn(type, stfd, &conn)) != srs_success) {
|
if ((err = fd2conn(type, stfd, &conn)) != srs_success) {
|
||||||
|
if (srs_error_code(err) == ERROR_SOCKET_GET_PEER_IP && _srs_config->empty_ip_ok()) {
|
||||||
|
srs_close_stfd(stfd); srs_error_reset(err);
|
||||||
|
return srs_success;
|
||||||
|
}
|
||||||
return srs_error_wrap(err, "fd2conn");
|
return srs_error_wrap(err, "fd2conn");
|
||||||
}
|
}
|
||||||
srs_assert(conn);
|
srs_assert(conn);
|
||||||
|
|
|
@ -24,6 +24,6 @@
|
||||||
#ifndef SRS_CORE_VERSION3_HPP
|
#ifndef SRS_CORE_VERSION3_HPP
|
||||||
#define SRS_CORE_VERSION3_HPP
|
#define SRS_CORE_VERSION3_HPP
|
||||||
|
|
||||||
#define SRS_VERSION3_REVISION 121
|
#define SRS_VERSION3_REVISION 123
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -77,8 +77,11 @@
|
||||||
#ifndef SRS_HIJACK_IO
|
#ifndef SRS_HIJACK_IO
|
||||||
struct SrsBlockSyncSocket
|
struct SrsBlockSyncSocket
|
||||||
{
|
{
|
||||||
SOCKET fd;
|
|
||||||
int family;
|
int family;
|
||||||
|
SOCKET fd;
|
||||||
|
SOCKET fdv4;
|
||||||
|
SOCKET fdv6;
|
||||||
|
// Bytes transmit.
|
||||||
int64_t rbytes;
|
int64_t rbytes;
|
||||||
int64_t sbytes;
|
int64_t sbytes;
|
||||||
// The send/recv timeout in ms.
|
// The send/recv timeout in ms.
|
||||||
|
@ -86,15 +89,26 @@ struct SrsBlockSyncSocket
|
||||||
int64_t stm;
|
int64_t stm;
|
||||||
|
|
||||||
SrsBlockSyncSocket() {
|
SrsBlockSyncSocket() {
|
||||||
|
family = AF_UNSPEC;
|
||||||
stm = rtm = SRS_UTIME_NO_TIMEOUT;
|
stm = rtm = SRS_UTIME_NO_TIMEOUT;
|
||||||
rbytes = sbytes = 0;
|
rbytes = sbytes = 0;
|
||||||
|
|
||||||
SOCKET_RESET(fd);
|
SOCKET_RESET(fd);
|
||||||
|
SOCKET_RESET(fdv4);
|
||||||
|
SOCKET_RESET(fdv6);
|
||||||
SOCKET_SETUP();
|
SOCKET_SETUP();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~SrsBlockSyncSocket() {
|
virtual ~SrsBlockSyncSocket() {
|
||||||
|
if (SOCKET_VALID(fd)) {
|
||||||
SOCKET_CLOSE(fd);
|
SOCKET_CLOSE(fd);
|
||||||
|
}
|
||||||
|
if (SOCKET_VALID(fdv4)) {
|
||||||
|
SOCKET_CLOSE(fdv4);
|
||||||
|
}
|
||||||
|
if (SOCKET_VALID(fdv6)) {
|
||||||
|
SOCKET_CLOSE(fdv6);
|
||||||
|
}
|
||||||
SOCKET_CLEANUP();
|
SOCKET_CLEANUP();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -112,19 +126,17 @@ int srs_hijack_io_create_socket(srs_hijack_io_t ctx, srs_rtmp_t owner)
|
||||||
{
|
{
|
||||||
SrsBlockSyncSocket* skt = (SrsBlockSyncSocket*)ctx;
|
SrsBlockSyncSocket* skt = (SrsBlockSyncSocket*)ctx;
|
||||||
|
|
||||||
skt->family = AF_INET6;
|
skt->family = AF_UNSPEC;
|
||||||
skt->fd = ::socket(skt->family, SOCK_STREAM, 0); // Try IPv6 first.
|
skt->fdv4 = ::socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (!SOCKET_VALID(skt->fd)) {
|
skt->fdv6 = ::socket(AF_INET6, SOCK_STREAM, 0);
|
||||||
skt->family = AF_INET;
|
if (!SOCKET_VALID(skt->fdv4) && !SOCKET_VALID(skt->fdv4)) {
|
||||||
skt->fd = ::socket(skt->family, SOCK_STREAM, 0); // Try IPv4 instead, if IPv6 fails.
|
|
||||||
}
|
|
||||||
if (!SOCKET_VALID(skt->fd)) {
|
|
||||||
return ERROR_SOCKET_CREATE;
|
return ERROR_SOCKET_CREATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No TCP cache.
|
// No TCP cache.
|
||||||
int v = 1;
|
int v = 1;
|
||||||
setsockopt(skt->fd, IPPROTO_TCP, TCP_NODELAY, &v, sizeof(v));
|
setsockopt(skt->fdv4, IPPROTO_TCP, TCP_NODELAY, &v, sizeof(v));
|
||||||
|
setsockopt(skt->fdv6, IPPROTO_TCP, TCP_NODELAY, &v, sizeof(v));
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +149,7 @@ int srs_hijack_io_connect(srs_hijack_io_t ctx, const char* server_ip, int port)
|
||||||
|
|
||||||
addrinfo hints;
|
addrinfo hints;
|
||||||
memset(&hints, 0, sizeof(hints));
|
memset(&hints, 0, sizeof(hints));
|
||||||
hints.ai_family = skt->family;
|
hints.ai_family = AF_UNSPEC;
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
|
||||||
addrinfo* r = NULL;
|
addrinfo* r = NULL;
|
||||||
|
@ -146,6 +158,15 @@ int srs_hijack_io_connect(srs_hijack_io_t ctx, const char* server_ip, int port)
|
||||||
return ERROR_SOCKET_CONNECT;
|
return ERROR_SOCKET_CONNECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skt->family = r->ai_family;
|
||||||
|
if (r->ai_family == AF_INET6) {
|
||||||
|
skt->fd = skt->fdv6;
|
||||||
|
SOCKET_RESET(skt->fdv6);
|
||||||
|
} else {
|
||||||
|
skt->fd = skt->fdv4;
|
||||||
|
SOCKET_RESET(skt->fdv4);
|
||||||
|
}
|
||||||
|
|
||||||
if(::connect(skt->fd, r->ai_addr, r->ai_addrlen) < 0){
|
if(::connect(skt->fd, r->ai_addr, r->ai_addrlen) < 0){
|
||||||
return ERROR_SOCKET_CONNECT;
|
return ERROR_SOCKET_CONNECT;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue