mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #913, refine the error mechanism
This commit is contained in:
parent
bb200b5d2d
commit
93710c7489
11 changed files with 38 additions and 31 deletions
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -353,6 +353,10 @@ int srs_initialize_kafka()
|
|||
void srs_dispose_kafka()
|
||||
{
|
||||
SrsKafkaProducer* kafka = dynamic_cast<SrsKafkaProducer*>(_srs_kafka);
|
||||
if (!kafka) {
|
||||
return;
|
||||
}
|
||||
|
||||
kafka->stop();
|
||||
|
||||
srs_freep(kafka);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -417,7 +417,7 @@ public:
|
|||
/**
|
||||
* initialize the http serve mux.
|
||||
*/
|
||||
virtual int initialize();
|
||||
virtual srs_error_t initialize();
|
||||
/**
|
||||
* hijack the http match.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue