winlin

completed the edge reload, to 0.9.79

@@ -763,6 +763,18 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) @@ -763,6 +763,18 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root)
763 SrsConfDirective* old_vhost = old_root->get("vhost", vhost); 763 SrsConfDirective* old_vhost = old_root->get("vhost", vhost);
764 SrsConfDirective* new_vhost = root->get("vhost", vhost); 764 SrsConfDirective* new_vhost = root->get("vhost", vhost);
765 765
  766 + // mode, never supports reload.
  767 + // first, for the origin and edge role change is too complex.
  768 + // second, the vhosts in origin device group normally are all origin,
  769 + // they never change to edge sometimes.
  770 + // third, the origin or upnode device can always be restart,
  771 + // edge will retry and the users connected to edge are ok.
  772 + if (get_vhost_is_edge(old_vhost) != get_vhost_is_edge(new_vhost)) {
  773 + ret = ERROR_RTMP_EDGE_RELOAD;
  774 + srs_error("reload never supports mode changed. ret=%d", ret);
  775 + return ret;
  776 + }
  777 +
766 // DISABLED => ENABLED 778 // DISABLED => ENABLED
767 if (!get_vhost_enabled(old_vhost) && get_vhost_enabled(new_vhost)) { 779 if (!get_vhost_enabled(old_vhost) && get_vhost_enabled(new_vhost)) {
768 srs_trace("vhost %s added, reload it.", vhost.c_str()); 780 srs_trace("vhost %s added, reload it.", vhost.c_str());
@@ -1823,6 +1835,12 @@ int SrsConfig::get_bw_check_limit_kbps(const string &vhost) @@ -1823,6 +1835,12 @@ int SrsConfig::get_bw_check_limit_kbps(const string &vhost)
1823 bool SrsConfig::get_vhost_is_edge(std::string vhost) 1835 bool SrsConfig::get_vhost_is_edge(std::string vhost)
1824 { 1836 {
1825 SrsConfDirective* conf = get_vhost(vhost); 1837 SrsConfDirective* conf = get_vhost(vhost);
  1838 + return get_vhost_is_edge(conf);
  1839 +}
  1840 +
  1841 +bool SrsConfig::get_vhost_is_edge(SrsConfDirective* vhost)
  1842 +{
  1843 + SrsConfDirective* conf = vhost;
1826 1844
1827 if (!conf) { 1845 if (!conf) {
1828 return false; 1846 return false;
@@ -195,6 +195,7 @@ public: @@ -195,6 +195,7 @@ public:
195 // vhost edge section 195 // vhost edge section
196 public: 196 public:
197 virtual bool get_vhost_is_edge(std::string vhost); 197 virtual bool get_vhost_is_edge(std::string vhost);
  198 + virtual bool get_vhost_is_edge(SrsConfDirective* vhost);
198 virtual SrsConfDirective* get_vhost_edge_origin(std::string vhost); 199 virtual SrsConfDirective* get_vhost_edge_origin(std::string vhost);
199 // vhost transcode section 200 // vhost transcode section
200 public: 201 public:
@@ -252,7 +252,6 @@ int SrsEdgeIngester::connect_server() @@ -252,7 +252,6 @@ int SrsEdgeIngester::connect_server()
252 // reopen 252 // reopen
253 close_underlayer_socket(); 253 close_underlayer_socket();
254 254
255 - // TODO: FIXME: support reload  
256 SrsConfDirective* conf = _srs_config->get_vhost_edge_origin(_req->vhost); 255 SrsConfDirective* conf = _srs_config->get_vhost_edge_origin(_req->vhost);
257 srs_assert(conf); 256 srs_assert(conf);
258 257
@@ -494,6 +493,7 @@ int SrsEdgeForwarder::proxy(SrsCommonMessage* msg) @@ -494,6 +493,7 @@ int SrsEdgeForwarder::proxy(SrsCommonMessage* msg)
494 return ret; 493 return ret;
495 } 494 }
496 495
  496 + // TODO: FIXME: use utility to copy msg to shared ptr msg.
497 SrsSharedPtrMessage* copy = new SrsSharedPtrMessage(); 497 SrsSharedPtrMessage* copy = new SrsSharedPtrMessage();
498 SrsAutoFree(SrsSharedPtrMessage, copy, false); 498 SrsAutoFree(SrsSharedPtrMessage, copy, false);
499 if ((ret = copy->initialize(msg)) != ERROR_SUCCESS) { 499 if ((ret = copy->initialize(msg)) != ERROR_SUCCESS) {
@@ -522,7 +522,6 @@ int SrsEdgeForwarder::connect_server() @@ -522,7 +522,6 @@ int SrsEdgeForwarder::connect_server()
522 // reopen 522 // reopen
523 close_underlayer_socket(); 523 close_underlayer_socket();
524 524
525 - // TODO: FIXME: support reload  
526 SrsConfDirective* conf = _srs_config->get_vhost_edge_origin(_req->vhost); 525 SrsConfDirective* conf = _srs_config->get_vhost_edge_origin(_req->vhost);
527 srs_assert(conf); 526 srs_assert(conf);
528 527
@@ -152,7 +152,6 @@ private: @@ -152,7 +152,6 @@ private:
152 * play edge control service. 152 * play edge control service.
153 * downloading edge speed-up. 153 * downloading edge speed-up.
154 */ 154 */
155 -// TODO: FIXME: support reload  
156 class SrsPlayEdge 155 class SrsPlayEdge
157 { 156 {
158 private: 157 private:
@@ -183,7 +182,6 @@ public: @@ -183,7 +182,6 @@ public:
183 * publish edge control service. 182 * publish edge control service.
184 * uploading edge speed-up. 183 * uploading edge speed-up.
185 */ 184 */
186 -// TODO: FIXME: support reload  
187 class SrsPublishEdge 185 class SrsPublishEdge
188 { 186 {
189 private: 187 private:
@@ -34,6 +34,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -34,6 +34,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 /** 34 /**
35 * the handler for config reload. 35 * the handler for config reload.
36 * when reload callback, the config is updated yet. 36 * when reload callback, the config is updated yet.
  37 +*
  38 +* features not support reload,
  39 +* @see: https://github.com/winlinvip/simple-rtmp-server/wiki/Reload#notsupportedfeatures
37 */ 40 */
38 class ISrsReloadHandler 41 class ISrsReloadHandler
39 { 42 {
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR "0" 32 #define VERSION_MAJOR "0"
33 #define VERSION_MINOR "9" 33 #define VERSION_MINOR "9"
34 -#define VERSION_REVISION "78" 34 +#define VERSION_REVISION "79"
35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION 35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "srs" 37 #define RTMP_SIG_SRS_KEY "srs"
@@ -82,6 +82,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -82,6 +82,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
82 // invalid state for client to publish edge stream. 82 // invalid state for client to publish edge stream.
83 #define ERROR_RTMP_EDGE_PUBLISH_STATE 321 83 #define ERROR_RTMP_EDGE_PUBLISH_STATE 321
84 #define ERROR_RTMP_EDGE_PROXY_PULL 322 84 #define ERROR_RTMP_EDGE_PROXY_PULL 322
  85 +#define ERROR_RTMP_EDGE_RELOAD 323
85 86
86 #define ERROR_SYSTEM_STREAM_INIT 400 87 #define ERROR_SYSTEM_STREAM_INIT 400
87 #define ERROR_SYSTEM_PACKET_INVALID 401 88 #define ERROR_SYSTEM_PACKET_INVALID 401