STAT: Ignore stat for API, only for HTTP streaming clients.

pull/3160/head
winlin 2 years ago
parent 28154e820c
commit bc569d91a0

@ -400,10 +400,12 @@ srs_error_t SrsHttpxConn::on_message_done(ISrsHttpMessage* r, SrsHttpResponseWri
srs_error_t SrsHttpxConn::on_conn_done(srs_error_t r0)
{
// Update statistic when done.
SrsStatistic* stat = SrsStatistic::instance();
stat->kbps_add_delta(get_id().c_str(), this);
stat->on_disconnect(get_id().c_str());
// Only stat the HTTP streaming clients, ignore all API clients.
bool exists = false;
SrsStatistic::instance()->on_disconnect(get_id().c_str(), &exists);
if (exists) {
SrsStatistic::instance()->kbps_add_delta(get_id().c_str(), this);
}
// Because we use manager to manage this object,
// not the http connection object, so we must remove it here.

@ -425,13 +425,12 @@ srs_error_t SrsStatistic::on_client(std::string id, SrsRequest* req, ISrsExpire*
return err;
}
void SrsStatistic::on_disconnect(std::string id)
void SrsStatistic::on_disconnect(std::string id, bool* exists)
{
std::map<std::string, SrsStatisticClient*>::iterator it;
if ((it = clients.find(id)) == clients.end()) {
return;
}
std::map<std::string, SrsStatisticClient*>::iterator it = clients.find(id);
if (exists) *exists = (it != clients.end());
if (it == clients.end()) return;
SrsStatisticClient* client = it->second;
SrsStatisticStream* stream = client->stream;
SrsStatisticVhost* vhost = stream->vhost;

@ -179,7 +179,7 @@ public:
// @remark the on_disconnect always call, while the on_client is call when
// only got the request object, so the client specified by id maybe not
// exists in stat.
virtual void on_disconnect(std::string id);
virtual void on_disconnect(std::string id, bool* exists = NULL);
private:
// Cleanup the stream if stream is not active and for the last client.
void cleanup_stream(SrsStatisticStream* stream);

Loading…
Cancel
Save