1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Refine code

This commit is contained in:
winlin 2018-08-26 14:29:45 +08:00
parent 1e2cca4712
commit 8e55ef4b60
2 changed files with 40 additions and 2 deletions

View file

@ -35,10 +35,13 @@ using namespace std;
#include <srs_kernel_utility.hpp>
#include <srs_protocol_amf0.hpp>
int64_t srs_gvid = getpid() * 3;
int64_t srs_gvid = 0;
int64_t srs_generate_id()
{
if (srs_gvid == 0) {
srs_gvid = getpid() * 3;
}
return srs_gvid++;
}
@ -227,7 +230,7 @@ srs_error_t SrsStatisticClient::dumps(SrsJsonObject* obj)
return err;
}
SrsStatistic* SrsStatistic::_instance = new SrsStatistic();
SrsStatistic* SrsStatistic::_instance = NULL;
SrsStatistic::SrsStatistic()
{
@ -271,6 +274,9 @@ SrsStatistic::~SrsStatistic()
SrsStatistic* SrsStatistic::instance()
{
if (_instance == NULL) {
_instance = new SrsStatistic();
}
return _instance;
}
@ -285,6 +291,10 @@ SrsStatisticVhost* SrsStatistic::find_vhost(int vid)
SrsStatisticVhost* SrsStatistic::find_vhost(string name)
{
if (rvhosts.empty()) {
return NULL;
}
std::map<string, SrsStatisticVhost*>::iterator it;
if ((it = rvhosts.find(name)) != rvhosts.end()) {
return it->second;