diff --git a/trunk/src/app/srs_app_http_conn.cpp b/trunk/src/app/srs_app_http_conn.cpp index 001395c78..88f5c2626 100644 --- a/trunk/src/app/srs_app_http_conn.cpp +++ b/trunk/src/app/srs_app_http_conn.cpp @@ -265,24 +265,25 @@ SrsHttpServer::~SrsHttpServer() srs_freep(http_static); } -int SrsHttpServer::initialize() +srs_error_t SrsHttpServer::initialize() { int ret = ERROR_SUCCESS; + srs_error_t err = srs_success; // for SRS go-sharp to detect the status of HTTP server of SRS HTTP FLV Cluster. if ((ret = http_static->mux.handle("/api/v1/versions", new SrsGoApiVersion())) != ERROR_SUCCESS) { - return ret; + return srs_error_new(ret, "handle versin"); } - if ((ret = http_stream->initialize()) != ERROR_SUCCESS) { - return ret; + if ((err = http_stream->initialize()) != srs_success) { + return srs_error_wrap(err, "http stream"); } - if ((ret = http_static->initialize()) != ERROR_SUCCESS) { - return ret; + if ((err = http_static->initialize()) != srs_success) { + return srs_error_wrap(err, "http static"); } - return ret; + return err; } int SrsHttpServer::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) diff --git a/trunk/src/app/srs_app_http_conn.hpp b/trunk/src/app/srs_app_http_conn.hpp index 6802095c1..6ee66017f 100644 --- a/trunk/src/app/srs_app_http_conn.hpp +++ b/trunk/src/app/srs_app_http_conn.hpp @@ -125,7 +125,7 @@ public: SrsHttpServer(SrsServer* svr); virtual ~SrsHttpServer(); public: - virtual int initialize(); + virtual srs_error_t initialize(); // ISrsHttpServeMux public: virtual int serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r); diff --git a/trunk/src/app/srs_app_http_static.cpp b/trunk/src/app/srs_app_http_static.cpp index e087e2706..427f05b59 100644 --- a/trunk/src/app/srs_app_http_static.cpp +++ b/trunk/src/app/srs_app_http_static.cpp @@ -208,9 +208,10 @@ SrsHttpStaticServer::~SrsHttpStaticServer() _srs_config->unsubscribe(this); } -int SrsHttpStaticServer::initialize() +srs_error_t SrsHttpStaticServer::initialize() { int ret = ERROR_SUCCESS; + srs_error_t err = srs_success; bool default_root_exists = false; @@ -226,7 +227,7 @@ int SrsHttpStaticServer::initialize() string pmount; string vhost = conf->arg0(); if ((ret = mount_vhost(vhost, pmount)) != ERROR_SUCCESS) { - return ret; + return srs_error_new(ret, "mount vhost"); } if (pmount == "/") { @@ -240,13 +241,12 @@ int SrsHttpStaticServer::initialize() // add root std::string dir = _srs_config->get_http_stream_dir(); if ((ret = mux.handle("/", new SrsVodStream(dir))) != ERROR_SUCCESS) { - srs_error("http: mount root dir=%s failed. ret=%d", dir.c_str(), ret); - return ret; + return srs_error_new(ret, "mount root dir=%s", dir.c_str()); } srs_trace("http: root mount to %s", dir.c_str()); } - return ret; + return err; } int SrsHttpStaticServer::mount_vhost(string vhost, string& pmount) diff --git a/trunk/src/app/srs_app_http_static.hpp b/trunk/src/app/srs_app_http_static.hpp index 24105a8ec..897b5a07d 100644 --- a/trunk/src/app/srs_app_http_static.hpp +++ b/trunk/src/app/srs_app_http_static.hpp @@ -58,7 +58,7 @@ public: SrsHttpStaticServer(SrsServer* svr); virtual ~SrsHttpStaticServer(); public: - virtual int initialize(); + virtual srs_error_t initialize(); private: virtual int mount_vhost(std::string vhost, std::string& pmount); // interface ISrsReloadHandler. diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index a948a9391..5ea1142a6 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -704,16 +704,17 @@ SrsHttpStreamServer::~SrsHttpStreamServer() } } -int SrsHttpStreamServer::initialize() +srs_error_t SrsHttpStreamServer::initialize() { int ret = ERROR_SUCCESS; + srs_error_t err = srs_success; // remux rtmp to flv live streaming if ((ret = initialize_flv_streaming()) != ERROR_SUCCESS) { - return ret; + return srs_error_new(ret, "http flv stream"); } - return ret; + return err; } // TODO: FIXME: rename for HTTP FLV mount. diff --git a/trunk/src/app/srs_app_http_stream.hpp b/trunk/src/app/srs_app_http_stream.hpp index cee0feb71..dbd9e7882 100755 --- a/trunk/src/app/srs_app_http_stream.hpp +++ b/trunk/src/app/srs_app_http_stream.hpp @@ -283,7 +283,7 @@ public: SrsHttpStreamServer(SrsServer* svr); virtual ~SrsHttpStreamServer(); public: - virtual int initialize(); + virtual srs_error_t initialize(); // http flv/ts/mp3/aac stream public: virtual int http_mount(SrsSource* s, SrsRequest* r); diff --git a/trunk/src/app/srs_app_kafka.cpp b/trunk/src/app/srs_app_kafka.cpp index 7d4e103ef..30ef8dddf 100644 --- a/trunk/src/app/srs_app_kafka.cpp +++ b/trunk/src/app/srs_app_kafka.cpp @@ -353,6 +353,10 @@ int srs_initialize_kafka() void srs_dispose_kafka() { SrsKafkaProducer* kafka = dynamic_cast(_srs_kafka); + if (!kafka) { + return; + } + kafka->stop(); srs_freep(kafka); diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index d58aecfec..d3642951d 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -559,7 +559,6 @@ void SrsServer::dispose() srs_error_t SrsServer::initialize(ISrsServerCycle* cycle_handler) { - int ret = ERROR_SUCCESS; srs_error_t err = srs_success; // ensure the time is ok. @@ -575,16 +574,16 @@ srs_error_t SrsServer::initialize(ISrsServerCycle* cycle_handler) signal_manager = new SrsSignalManager(this); handler = cycle_handler; - if(handler && (ret = handler->initialize()) != ERROR_SUCCESS){ - return srs_error_new(ret, "handler initialize"); + if(handler && (err = handler->initialize()) != srs_success){ + return srs_error_wrap(err, "handler initialize"); } - if ((ret = http_api_mux->initialize()) != ERROR_SUCCESS) { - return srs_error_new(ret, "http api initialize"); + if ((err = http_api_mux->initialize()) != srs_success) { + return srs_error_wrap(err, "http api initialize"); } - if ((ret = http_server->initialize()) != ERROR_SUCCESS) { - return srs_error_new(ret, "http server initialize"); + if ((err = http_server->initialize()) != srs_success) { + return srs_error_wrap(err, "http server initialize"); } http_heartbeat = new SrsHttpHeartbeat(); diff --git a/trunk/src/app/srs_app_server.hpp b/trunk/src/app/srs_app_server.hpp index 4b5466da5..8a58e9a9d 100644 --- a/trunk/src/app/srs_app_server.hpp +++ b/trunk/src/app/srs_app_server.hpp @@ -219,7 +219,7 @@ public: /** * initialize the cycle handler. */ - virtual int initialize() = 0; + virtual srs_error_t initialize() = 0; /** * do on_cycle while server doing cycle. */ diff --git a/trunk/src/protocol/srs_http_stack.cpp b/trunk/src/protocol/srs_http_stack.cpp index 17aeb422e..29b37e91a 100644 --- a/trunk/src/protocol/srs_http_stack.cpp +++ b/trunk/src/protocol/srs_http_stack.cpp @@ -533,11 +533,13 @@ SrsHttpServeMux::~SrsHttpServeMux() hijackers.clear(); } -int SrsHttpServeMux::initialize() +srs_error_t SrsHttpServeMux::initialize() { - int ret = ERROR_SUCCESS; - // TODO: FIXME: implements it. - return ret; + srs_error_t err = srs_success; + + // TODO: FIXME: Implements it. + + return err; } void SrsHttpServeMux::hijack(ISrsHttpMatchHijacker* h) diff --git a/trunk/src/protocol/srs_http_stack.hpp b/trunk/src/protocol/srs_http_stack.hpp index 22f1cda54..f3e93356b 100644 --- a/trunk/src/protocol/srs_http_stack.hpp +++ b/trunk/src/protocol/srs_http_stack.hpp @@ -417,7 +417,7 @@ public: /** * initialize the http serve mux. */ - virtual int initialize(); + virtual srs_error_t initialize(); /** * hijack the http match. */