1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00
问题:edge模式,推流时异常断开。
    解决方法:增加edge模式推流检测。
This commit is contained in:
zhengfl 2015-07-08 15:43:09 +08:00
parent 120033e0a2
commit f9257b89e7
6 changed files with 46 additions and 15 deletions

View file

@ -423,27 +423,20 @@ int SrsRtmpConn::stream_service_cycle()
}
}
srs_assert(source != NULL);
// check ASAP, to fail it faster if invalid.
if (type != SrsRtmpConnPlay) {
if ((ret = prepare_publish(source, vhost_is_edge)) != ERROR_SUCCESS) {
return ret;
}
}
// update the statistic when source disconveried.
SrsStatistic* stat = SrsStatistic::instance();
if ((ret = stat->on_client(_srs_context->get_id(), req)) != ERROR_SUCCESS) {
srs_error("stat client failed. ret=%d", ret);
return ret;
}
// check ASAP, to fail it faster if invalid.
if (type != SrsRtmpConnPlay && !vhost_is_edge) {
// check publish available
// for edge, never check it, for edge use proxy mode.
if (!source->can_publish()) {
ret = ERROR_SYSTEM_STREAM_BUSY;
srs_warn("stream %s is already publishing. ret=%d",
req->get_stream_url().c_str(), ret);
// to delay request
st_usleep(SRS_STREAM_BUSY_SLEEP_US);
return ret;
}
}
bool enabled_cache = _srs_config->get_gop_cache(req->vhost);
srs_trace("source url=%s, ip=%s, cache=%d, is_edge=%d, source_id=%d[%d]",
@ -1260,6 +1253,31 @@ int SrsRtmpConn::do_token_traverse_auth(SrsRtmpClient* client)
return ret;
}
int SrsRtmpConn::prepare_publish(SrsSource* source, bool vhost_is_edge)
{
int ret = ERROR_SUCCESS;
srs_assert(source);
// check publish available
bool can_publish = false;
if (vhost_is_edge) {
can_publish = source->proxy_can_publish();
} else {
can_publish = source->can_publish();
}
if (!can_publish) {
ret = ERROR_SYSTEM_STREAM_BUSY;
srs_warn("stream %s is already publishing. ret=%d",
req->get_stream_url().c_str(), ret);
// to delay request
st_usleep(SRS_STREAM_BUSY_SLEEP_US);
return ret;
}
return ret;
}
int SrsRtmpConn::http_hooks_on_connect()
{
int ret = ERROR_SUCCESS;