mirror of
				https://github.com/ossrs/srs.git
				synced 2025-03-09 15:49:59 +00:00 
			
		
		
		
	For #2424, query the latest available version. 3.0.163
This commit is contained in:
		
							parent
							
								
									cf34ebc32f
								
							
						
					
					
						commit
						2be8589a8a
					
				
					 10 changed files with 268 additions and 3 deletions
				
			
		| 
						 | 
					@ -137,6 +137,8 @@ Other important wiki:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## V3 changes
 | 
					## V3 changes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* <strong>v3.0, 2021-06-26, [3.0 release6(3.0.163)](https://github.com/ossrs/srs/releases/tag/v3.0-r6) released. 123011 lines.</strong>
 | 
				
			||||||
 | 
					* v3.0, 2021-06-26, For [#2424](https://github.com/ossrs/srs/issues/2424), query the latest available version. 3.0.163
 | 
				
			||||||
* v3.0, 2021-05-12, Fix [#2311][bug #2311], Copy the request for stat client. 3.0.162
 | 
					* v3.0, 2021-05-12, Fix [#2311][bug #2311], Copy the request for stat client. 3.0.162
 | 
				
			||||||
* <strong>v3.0, 2021-04-28, [3.0 release5(3.0.161)][r3.0r5] released. 122750 lines.</strong>
 | 
					* <strong>v3.0, 2021-04-28, [3.0 release5(3.0.161)][r3.0r5] released. 122750 lines.</strong>
 | 
				
			||||||
* v3.0, 2021-04-28, Upgrade players. 3.0.161
 | 
					* v3.0, 2021-04-28, Upgrade players. 3.0.161
 | 
				
			||||||
| 
						 | 
					@ -340,6 +342,8 @@ Other important wiki:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## V2 changes
 | 
					## V2 changes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* <strong>v2.0, 2021-06-26, [2.0 release9(2.0.273)](https://github.com/ossrs/srs/releases/tag/v2.0-r9) released. 87552 lines.</strong>
 | 
				
			||||||
 | 
					* v2.0, 2021-06-25, For [#2424](https://github.com/ossrs/srs/issues/2424), query the latest available version. 2.0.273
 | 
				
			||||||
* <strong>v2.0, 2020-01-25, [2.0 release8(2.0.272)][r2.0r8] released. 87292 lines.</strong>
 | 
					* <strong>v2.0, 2020-01-25, [2.0 release8(2.0.272)][r2.0r8] released. 87292 lines.</strong>
 | 
				
			||||||
* v2.0, 2020-01-08, Merge [#1554][bug #1554], support logrotate copytruncate. 2.0.272
 | 
					* v2.0, 2020-01-08, Merge [#1554][bug #1554], support logrotate copytruncate. 2.0.272
 | 
				
			||||||
* v2.0, 2020-01-05, Merge [#1551][bug #1551], fix memory leak in RTSP stack. 2.0.270
 | 
					* v2.0, 2020-01-05, Merge [#1551][bug #1551], fix memory leak in RTSP stack. 2.0.270
 | 
				
			||||||
| 
						 | 
					@ -778,6 +782,7 @@ Other important wiki:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Releases
 | 
					## Releases
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* 2021-06-26, [Release v3.0-r6](https://github.com/ossrs/srs/releases/tag/v3.0-r6), 3.0 release6, 3.0.163, 123011 lines.
 | 
				
			||||||
* 2021-04-28, [Release v3.0-r5][r3.0r5], 3.0 release5, 3.0.161, 122750 lines.
 | 
					* 2021-04-28, [Release v3.0-r5][r3.0r5], 3.0 release5, 3.0.161, 122750 lines.
 | 
				
			||||||
* 2021-04-24, [Release v3.0-r4][r3.0r4], 3.0 release4, 3.0.160, 122750 lines.
 | 
					* 2021-04-24, [Release v3.0-r4][r3.0r4], 3.0 release4, 3.0.160, 122750 lines.
 | 
				
			||||||
* 2021-01-02, [Release v3.0-r3][r3.0r3], 3.0 release3, 3.0.156, 122736 lines.
 | 
					* 2021-01-02, [Release v3.0-r3][r3.0r3], 3.0 release3, 3.0.156, 122736 lines.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -105,6 +105,11 @@ inotify_auto_reload off;
 | 
				
			||||||
# default: on
 | 
					# default: on
 | 
				
			||||||
auto_reload_for_docker on;
 | 
					auto_reload_for_docker on;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Query the latest available version of SRS, write a log to notice user to upgrade.
 | 
				
			||||||
 | 
					# @see https://github.com/ossrs/srs/issues/2424
 | 
				
			||||||
 | 
					# Default: on
 | 
				
			||||||
 | 
					query_latest_version on;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#############################################################################################
 | 
					#############################################################################################
 | 
				
			||||||
# heartbeat/stats sections
 | 
					# heartbeat/stats sections
 | 
				
			||||||
#############################################################################################
 | 
					#############################################################################################
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										2
									
								
								trunk/configure
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								trunk/configure
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -228,7 +228,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
 | 
				
			||||||
            "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client" "srs_app_http_static"
 | 
					            "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client" "srs_app_http_static"
 | 
				
			||||||
            "srs_app_recv_thread" "srs_app_security" "srs_app_statistic" "srs_app_hds"
 | 
					            "srs_app_recv_thread" "srs_app_security" "srs_app_statistic" "srs_app_hds"
 | 
				
			||||||
            "srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener" "srs_app_async_call"
 | 
					            "srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener" "srs_app_async_call"
 | 
				
			||||||
            "srs_app_caster_flv" "srs_app_process" "srs_app_ng_exec"
 | 
					            "srs_app_caster_flv" "srs_app_latest_version" "srs_app_process" "srs_app_ng_exec"
 | 
				
			||||||
            "srs_app_hourglass" "srs_app_dash" "srs_app_fragment" "srs_app_dvr"
 | 
					            "srs_app_hourglass" "srs_app_dash" "srs_app_fragment" "srs_app_dvr"
 | 
				
			||||||
            "srs_app_coworkers")
 | 
					            "srs_app_coworkers")
 | 
				
			||||||
    DEFINES=""
 | 
					    DEFINES=""
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4056,6 +4056,18 @@ bool SrsConfig::get_asprocess()
 | 
				
			||||||
    return SRS_CONF_PERFER_FALSE(conf->arg0());
 | 
					    return SRS_CONF_PERFER_FALSE(conf->arg0());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool SrsConfig::whether_query_latest_version()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    static bool DEFAULT = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SrsConfDirective* conf = root->get("query_latest_version");
 | 
				
			||||||
 | 
					    if (!conf) {
 | 
				
			||||||
 | 
					        return DEFAULT;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return SRS_CONF_PERFER_TRUE(conf->arg0());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool SrsConfig::empty_ip_ok()
 | 
					bool SrsConfig::empty_ip_ok()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    static bool DEFAULT = true;
 | 
					    static bool DEFAULT = true;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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 query the latest available version of SRS.
 | 
				
			||||||
 | 
					    virtual bool whether_query_latest_version();
 | 
				
			||||||
    // Whether empty client IP is ok.
 | 
					    // Whether empty client IP is ok.
 | 
				
			||||||
    virtual bool empty_ip_ok();
 | 
					    virtual bool empty_ip_ok();
 | 
				
			||||||
    // Get the start wait in ms for gracefully quit.
 | 
					    // Get the start wait in ms for gracefully quit.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										166
									
								
								trunk/src/app/srs_app_latest_version.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										166
									
								
								trunk/src/app/srs_app_latest_version.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,166 @@
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					The MIT License (MIT)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Copyright (c) 2013-2015 SRS(ossrs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Permission is hereby granted, free of charge, to any person obtaining a copy of
 | 
				
			||||||
 | 
					this software and associated documentation files (the "Software"), to deal in
 | 
				
			||||||
 | 
					the Software without restriction, including without limitation the rights to
 | 
				
			||||||
 | 
					use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 | 
				
			||||||
 | 
					the Software, and to permit persons to whom the Software is furnished to do so,
 | 
				
			||||||
 | 
					subject to the following conditions:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The above copyright notice and this permission notice shall be included in all
 | 
				
			||||||
 | 
					copies or substantial portions of the Software.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
				
			||||||
 | 
					IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 | 
				
			||||||
 | 
					FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 | 
				
			||||||
 | 
					COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 | 
				
			||||||
 | 
					IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 | 
				
			||||||
 | 
					CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <srs_app_latest_version.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <srs_core_autofree.hpp>
 | 
				
			||||||
 | 
					#include <srs_kernel_error.hpp>
 | 
				
			||||||
 | 
					#include <srs_kernel_log.hpp>
 | 
				
			||||||
 | 
					#include <srs_kernel_utility.hpp>
 | 
				
			||||||
 | 
					#include <srs_protocol_json.hpp>
 | 
				
			||||||
 | 
					#include <srs_protocol_utility.hpp>
 | 
				
			||||||
 | 
					#include <srs_app_config.hpp>
 | 
				
			||||||
 | 
					#include <srs_app_http_conn.hpp>
 | 
				
			||||||
 | 
					#include <srs_app_http_client.hpp>
 | 
				
			||||||
 | 
					#include <srs_app_utility.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#include <sstream>
 | 
				
			||||||
 | 
					using namespace std;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SrsLatestVersion::SrsLatestVersion()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    trd_ = new SrsSTCoroutine("signal", this);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SrsLatestVersion::~SrsLatestVersion()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    srs_freep(trd_);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					srs_error_t SrsLatestVersion::start()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (!_srs_config->whether_query_latest_version()) {
 | 
				
			||||||
 | 
					        return srs_success;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    char buf[10];
 | 
				
			||||||
 | 
					    srs_random_generate(buf, sizeof(buf));
 | 
				
			||||||
 | 
					    for (int i = 0; i < (int)sizeof(buf); i++) {
 | 
				
			||||||
 | 
					        buf[i] = 'a' + uint8_t(buf[i])%25;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    server_id_ = string(buf, sizeof(buf));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return trd_->start();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					srs_error_t SrsLatestVersion::cycle()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    srs_error_t err = srs_success;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    srs_utime_t starttime = srs_update_system_time();
 | 
				
			||||||
 | 
					    if ((err = query_latest_version()) != srs_success) {
 | 
				
			||||||
 | 
					        srs_warn("query err %s", srs_error_desc(err).c_str());
 | 
				
			||||||
 | 
					        srs_freep(err); // Ignore any error.
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    srs_utime_t first_random_wait = 0;
 | 
				
			||||||
 | 
					    srs_random_generate((char*)&first_random_wait, 8);
 | 
				
			||||||
 | 
					    first_random_wait = srs_utime_t(uint64_t((first_random_wait + starttime + getpid())) % (60 * 60)) * SRS_UTIME_SECONDS; // in s.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    srs_trace("Startup query id=%s, eip=%s, match=%s, stable=%s, wait=%ds, cost=%dms", server_id_.c_str(), srs_get_public_internet_address().c_str(), match_version_.c_str(), stable_version_.c_str(), srsu2msi(first_random_wait)/1000, srsu2msi(srs_update_system_time() - starttime));
 | 
				
			||||||
 | 
					    srs_usleep(first_random_wait);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    while (true) {
 | 
				
			||||||
 | 
					        starttime = srs_update_system_time();
 | 
				
			||||||
 | 
					        if ((err = query_latest_version()) != srs_success) {
 | 
				
			||||||
 | 
					            srs_warn("query err %s", srs_error_desc(err).c_str());
 | 
				
			||||||
 | 
					            srs_freep(err); // Ignore any error.
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        srs_trace("Finish query id=%s, eip=%s, match=%s, stable=%s, cost=%dms", server_id_.c_str(), srs_get_public_internet_address().c_str(), match_version_.c_str(), stable_version_.c_str(), srsu2msi(srs_update_system_time() - starttime));
 | 
				
			||||||
 | 
					        srs_usleep(3600 * SRS_UTIME_SECONDS); // Every an hour.
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return err;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					srs_error_t SrsLatestVersion::query_latest_version()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    srs_error_t err = srs_success;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Generate uri and parse to object.
 | 
				
			||||||
 | 
					    stringstream ss;
 | 
				
			||||||
 | 
					    ss << "http://api.ossrs.net/service/v1/releases?"
 | 
				
			||||||
 | 
					          << "version=v" << VERSION_MAJOR << "." << VERSION_MINOR << "." << VERSION_REVISION
 | 
				
			||||||
 | 
					          << "&id=" << server_id_
 | 
				
			||||||
 | 
					          << "&eip=" << srs_get_public_internet_address()
 | 
				
			||||||
 | 
					          << "&ts=" << srsu2ms(srs_get_system_time());
 | 
				
			||||||
 | 
					    string url = ss.str();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SrsHttpUri uri;
 | 
				
			||||||
 | 
					    if ((err = uri.initialize(url)) != srs_success) {
 | 
				
			||||||
 | 
					        return srs_error_wrap(err, "http: post failed. url=%s", url.c_str());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Start HTTP request and read response.
 | 
				
			||||||
 | 
					    SrsHttpClient http;
 | 
				
			||||||
 | 
					    if ((err = http.initialize(uri.get_host(), uri.get_port())) != srs_success) {
 | 
				
			||||||
 | 
					        return err;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ISrsHttpMessage* msg = NULL;
 | 
				
			||||||
 | 
					    if ((err = http.get(uri.get_path(), "", &msg)) != srs_success) {
 | 
				
			||||||
 | 
					        return err;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    SrsAutoFree(ISrsHttpMessage, msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    string res;
 | 
				
			||||||
 | 
					    int code = msg->status_code();
 | 
				
			||||||
 | 
					    if ((err = msg->body_read_all(res)) != srs_success) {
 | 
				
			||||||
 | 
					        return err;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Check the response code and content.
 | 
				
			||||||
 | 
					    if (code != SRS_CONSTS_HTTP_OK) {
 | 
				
			||||||
 | 
					        return srs_error_new(ERROR_HTTP_STATUS_INVALID, "invalid response status=%d", code);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (res.empty()) {
 | 
				
			||||||
 | 
					        return srs_error_new(ERROR_HTTP_DATA_INVALID, "invalid empty response");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Response in json object.
 | 
				
			||||||
 | 
					    SrsJsonAny* jres = SrsJsonAny::loads((char*)res.c_str());
 | 
				
			||||||
 | 
					    if (!jres || !jres->is_object()) {
 | 
				
			||||||
 | 
					        return srs_error_new(ERROR_HTTP_DATA_INVALID, "invalid response %s", res.c_str());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    SrsAutoFree(SrsJsonAny, jres);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SrsJsonObject* obj = jres->to_object();
 | 
				
			||||||
 | 
					    SrsJsonAny* prop = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Parse fields of response.
 | 
				
			||||||
 | 
					    if ((prop = obj->ensure_property_string("match_version")) == NULL) {
 | 
				
			||||||
 | 
					        return srs_error_new(ERROR_RESPONSE_CODE, "no match_version");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    match_version_ = prop->to_str();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ((prop = obj->ensure_property_string("stable_version")) == NULL) {
 | 
				
			||||||
 | 
					        return srs_error_new(ERROR_RESPONSE_CODE, "no stable_version");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    stable_version_ = prop->to_str();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return err;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										58
									
								
								trunk/src/app/srs_app_latest_version.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								trunk/src/app/srs_app_latest_version.hpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,58 @@
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					The MIT License (MIT)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Copyright (c) 2013-2015 SRS(ossrs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Permission is hereby granted, free of charge, to any person obtaining a copy of
 | 
				
			||||||
 | 
					this software and associated documentation files (the "Software"), to deal in
 | 
				
			||||||
 | 
					the Software without restriction, including without limitation the rights to
 | 
				
			||||||
 | 
					use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 | 
				
			||||||
 | 
					the Software, and to permit persons to whom the Software is furnished to do so,
 | 
				
			||||||
 | 
					subject to the following conditions:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The above copyright notice and this permission notice shall be included in all
 | 
				
			||||||
 | 
					copies or substantial portions of the Software.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
				
			||||||
 | 
					IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 | 
				
			||||||
 | 
					FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 | 
				
			||||||
 | 
					COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 | 
				
			||||||
 | 
					IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 | 
				
			||||||
 | 
					CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef SRS_APP_LATEST_VERSION_HPP
 | 
				
			||||||
 | 
					#define SRS_APP_LATEST_VERSION_HPP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					#include <srs_app_latest_version.hpp>
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <srs_core.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <srs_app_thread.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class SrsLatestVersion : public ISrsCoroutineHandler
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    SrsCoroutine* trd_;
 | 
				
			||||||
 | 
					    std::string server_id_;
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    std::string match_version_;
 | 
				
			||||||
 | 
					    std::string stable_version_;
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    SrsLatestVersion();
 | 
				
			||||||
 | 
					    virtual ~SrsLatestVersion();
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    virtual srs_error_t start();
 | 
				
			||||||
 | 
					// interface ISrsEndlessThreadHandler.
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    virtual srs_error_t cycle();
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    srs_error_t query_latest_version();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,6 +54,7 @@ using namespace std;
 | 
				
			||||||
#include <srs_kernel_consts.hpp>
 | 
					#include <srs_kernel_consts.hpp>
 | 
				
			||||||
#include <srs_app_thread.hpp>
 | 
					#include <srs_app_thread.hpp>
 | 
				
			||||||
#include <srs_app_coworkers.hpp>
 | 
					#include <srs_app_coworkers.hpp>
 | 
				
			||||||
 | 
					#include <srs_app_latest_version.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// system interval in srs_utime_t,
 | 
					// system interval in srs_utime_t,
 | 
				
			||||||
// all resolution times should be times togother,
 | 
					// all resolution times should be times togother,
 | 
				
			||||||
| 
						 | 
					@ -623,6 +624,7 @@ SrsServer::SrsServer()
 | 
				
			||||||
    pid_fd = -1;
 | 
					    pid_fd = -1;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    signal_manager = new SrsSignalManager(this);
 | 
					    signal_manager = new SrsSignalManager(this);
 | 
				
			||||||
 | 
					    latest_version_ = new SrsLatestVersion();
 | 
				
			||||||
    conn_manager = new SrsCoroutineManager();
 | 
					    conn_manager = new SrsCoroutineManager();
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    handler = NULL;
 | 
					    handler = NULL;
 | 
				
			||||||
| 
						 | 
					@ -659,6 +661,7 @@ void SrsServer::destroy()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    srs_freep(signal_manager);
 | 
					    srs_freep(signal_manager);
 | 
				
			||||||
 | 
					    srs_freep(latest_version_);
 | 
				
			||||||
    srs_freep(conn_manager);
 | 
					    srs_freep(conn_manager);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -787,7 +790,18 @@ srs_error_t SrsServer::initialize_st()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
srs_error_t SrsServer::initialize_signal()
 | 
					srs_error_t SrsServer::initialize_signal()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return signal_manager->initialize();
 | 
					    srs_error_t err = srs_success;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ((err = signal_manager->initialize()) != srs_success) {
 | 
				
			||||||
 | 
					        return srs_error_wrap(err, "init signal manager");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Start the version query coroutine.
 | 
				
			||||||
 | 
					    if ((err = latest_version_->start()) != srs_success) {
 | 
				
			||||||
 | 
					        return srs_error_wrap(err, "start version query");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
srs_error_t SrsServer::acquire_pid_file()
 | 
					srs_error_t SrsServer::acquire_pid_file()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,6 +51,7 @@ class SrsUdpListener;
 | 
				
			||||||
class SrsTcpListener;
 | 
					class SrsTcpListener;
 | 
				
			||||||
class SrsAppCasterFlv;
 | 
					class SrsAppCasterFlv;
 | 
				
			||||||
class SrsCoroutineManager;
 | 
					class SrsCoroutineManager;
 | 
				
			||||||
 | 
					class SrsLatestVersion;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// The listener type for server to identify the connection,
 | 
					// The listener type for server to identify the connection,
 | 
				
			||||||
// that is, use different type to process the connection.
 | 
					// that is, use different type to process the connection.
 | 
				
			||||||
| 
						 | 
					@ -239,6 +240,8 @@ private:
 | 
				
			||||||
    std::vector<SrsListener*> listeners;
 | 
					    std::vector<SrsListener*> listeners;
 | 
				
			||||||
    // Signal manager which convert gignal to io message.
 | 
					    // Signal manager which convert gignal to io message.
 | 
				
			||||||
    SrsSignalManager* signal_manager;
 | 
					    SrsSignalManager* signal_manager;
 | 
				
			||||||
 | 
					    // To query the latest available version of SRS.
 | 
				
			||||||
 | 
					    SrsLatestVersion* latest_version_;
 | 
				
			||||||
    // Handle in server cycle.
 | 
					    // Handle in server cycle.
 | 
				
			||||||
    ISrsServerCycle* handler;
 | 
					    ISrsServerCycle* handler;
 | 
				
			||||||
    // User send the signal, convert to variable.
 | 
					    // User send the signal, convert to variable.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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 162
 | 
					#define SRS_VERSION3_REVISION 163
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue