正在显示
4 个修改的文件
包含
21 行增加
和
7 行删除
@@ -340,6 +340,7 @@ Remark: | @@ -340,6 +340,7 @@ Remark: | ||
340 | 340 | ||
341 | ### SRS 2.0 history | 341 | ### SRS 2.0 history |
342 | 342 | ||
343 | +* v2.0, 2015-05-24, fix [#404](https://github.com/simple-rtmp-server/srs/issues/404) register handler then start http thread. 2.0.167. | ||
343 | * v2.0, 2015-05-23, refine the thread, protocol, kbps code. 2.0.166 | 344 | * v2.0, 2015-05-23, refine the thread, protocol, kbps code. 2.0.166 |
344 | * v2.0, 2015-05-23, fix [#391](https://github.com/simple-rtmp-server/srs/issues/391) copy request for async call. | 345 | * v2.0, 2015-05-23, fix [#391](https://github.com/simple-rtmp-server/srs/issues/391) copy request for async call. |
345 | * v2.0, 2015-05-22, fix [#397](https://github.com/simple-rtmp-server/srs/issues/397) the USER_HZ maybe not 100. 2.0.165 | 346 | * v2.0, 2015-05-22, fix [#397](https://github.com/simple-rtmp-server/srs/issues/397) the USER_HZ maybe not 100. 2.0.165 |
@@ -1854,17 +1854,20 @@ int SrsHttpServer::http_mount(SrsSource* s, SrsRequest* r) | @@ -1854,17 +1854,20 @@ int SrsHttpServer::http_mount(SrsSource* s, SrsRequest* r) | ||
1854 | 1854 | ||
1855 | sflvs[sid] = entry; | 1855 | sflvs[sid] = entry; |
1856 | 1856 | ||
1857 | - // start http stream cache thread | ||
1858 | - if ((ret = entry->cache->start()) != ERROR_SUCCESS) { | ||
1859 | - srs_error("http: start stream cache failed. ret=%d", ret); | ||
1860 | - return ret; | ||
1861 | - } | ||
1862 | - | ||
1863 | // mount the http flv stream. | 1857 | // mount the http flv stream. |
1858 | + // we must register the handler, then start the thread, | ||
1859 | + // for the thread will cause thread switch context. | ||
1860 | + // @see https://github.com/simple-rtmp-server/srs/issues/404 | ||
1864 | if ((ret = mux.handle(mount, entry->stream)) != ERROR_SUCCESS) { | 1861 | if ((ret = mux.handle(mount, entry->stream)) != ERROR_SUCCESS) { |
1865 | srs_error("http: mount flv stream for vhost=%s failed. ret=%d", sid.c_str(), ret); | 1862 | srs_error("http: mount flv stream for vhost=%s failed. ret=%d", sid.c_str(), ret); |
1866 | return ret; | 1863 | return ret; |
1867 | } | 1864 | } |
1865 | + | ||
1866 | + // start http stream cache thread | ||
1867 | + if ((ret = entry->cache->start()) != ERROR_SUCCESS) { | ||
1868 | + srs_error("http: start stream cache failed. ret=%d", ret); | ||
1869 | + return ret; | ||
1870 | + } | ||
1868 | srs_trace("http: mount flv stream for vhost=%s, mount=%s", sid.c_str(), mount.c_str()); | 1871 | srs_trace("http: mount flv stream for vhost=%s, mount=%s", sid.c_str(), mount.c_str()); |
1869 | } else { | 1872 | } else { |
1870 | entry = sflvs[sid]; | 1873 | entry = sflvs[sid]; |
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
31 | // current release version | 31 | // current release version |
32 | #define VERSION_MAJOR 2 | 32 | #define VERSION_MAJOR 2 |
33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
34 | -#define VERSION_REVISION 166 | 34 | +#define VERSION_REVISION 167 |
35 | 35 | ||
36 | // server info. | 36 | // server info. |
37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
@@ -134,7 +134,9 @@ int SrsFlvEncoder::write_metadata(char type, char* data, int size) | @@ -134,7 +134,9 @@ int SrsFlvEncoder::write_metadata(char type, char* data, int size) | ||
134 | tag_stream->write_3bytes(size); | 134 | tag_stream->write_3bytes(size); |
135 | 135 | ||
136 | if ((ret = write_tag(tag_header, sizeof(tag_header), data, size)) != ERROR_SUCCESS) { | 136 | if ((ret = write_tag(tag_header, sizeof(tag_header), data, size)) != ERROR_SUCCESS) { |
137 | + if (!srs_is_client_gracefully_close(ret)) { | ||
137 | srs_error("write flv data tag failed. ret=%d", ret); | 138 | srs_error("write flv data tag failed. ret=%d", ret); |
139 | + } | ||
138 | return ret; | 140 | return ret; |
139 | } | 141 | } |
140 | 142 | ||
@@ -168,7 +170,9 @@ int SrsFlvEncoder::write_audio(int64_t timestamp, char* data, int size) | @@ -168,7 +170,9 @@ int SrsFlvEncoder::write_audio(int64_t timestamp, char* data, int size) | ||
168 | tag_stream->write_1bytes((timestamp >> 24) & 0xFF); | 170 | tag_stream->write_1bytes((timestamp >> 24) & 0xFF); |
169 | 171 | ||
170 | if ((ret = write_tag(tag_header, sizeof(tag_header), data, size)) != ERROR_SUCCESS) { | 172 | if ((ret = write_tag(tag_header, sizeof(tag_header), data, size)) != ERROR_SUCCESS) { |
173 | + if (!srs_is_client_gracefully_close(ret)) { | ||
171 | srs_error("write flv audio tag failed. ret=%d", ret); | 174 | srs_error("write flv audio tag failed. ret=%d", ret); |
175 | + } | ||
172 | return ret; | 176 | return ret; |
173 | } | 177 | } |
174 | 178 | ||
@@ -221,13 +225,17 @@ int SrsFlvEncoder::write_tag(char* header, int header_size, char* tag, int tag_s | @@ -221,13 +225,17 @@ int SrsFlvEncoder::write_tag(char* header, int header_size, char* tag, int tag_s | ||
221 | 225 | ||
222 | // write tag header. | 226 | // write tag header. |
223 | if ((ret = _fs->write(header, header_size, NULL)) != ERROR_SUCCESS) { | 227 | if ((ret = _fs->write(header, header_size, NULL)) != ERROR_SUCCESS) { |
228 | + if (!srs_is_client_gracefully_close(ret)) { | ||
224 | srs_error("write flv tag header failed. ret=%d", ret); | 229 | srs_error("write flv tag header failed. ret=%d", ret); |
230 | + } | ||
225 | return ret; | 231 | return ret; |
226 | } | 232 | } |
227 | 233 | ||
228 | // write tag data. | 234 | // write tag data. |
229 | if ((ret = _fs->write(tag, tag_size, NULL)) != ERROR_SUCCESS) { | 235 | if ((ret = _fs->write(tag, tag_size, NULL)) != ERROR_SUCCESS) { |
236 | + if (!srs_is_client_gracefully_close(ret)) { | ||
230 | srs_error("write flv tag failed. ret=%d", ret); | 237 | srs_error("write flv tag failed. ret=%d", ret); |
238 | + } | ||
231 | return ret; | 239 | return ret; |
232 | } | 240 | } |
233 | 241 | ||
@@ -238,7 +246,9 @@ int SrsFlvEncoder::write_tag(char* header, int header_size, char* tag, int tag_s | @@ -238,7 +246,9 @@ int SrsFlvEncoder::write_tag(char* header, int header_size, char* tag, int tag_s | ||
238 | } | 246 | } |
239 | tag_stream->write_4bytes(tag_size + header_size); | 247 | tag_stream->write_4bytes(tag_size + header_size); |
240 | if ((ret = _fs->write(pre_size, sizeof(pre_size), NULL)) != ERROR_SUCCESS) { | 248 | if ((ret = _fs->write(pre_size, sizeof(pre_size), NULL)) != ERROR_SUCCESS) { |
249 | + if (!srs_is_client_gracefully_close(ret)) { | ||
241 | srs_error("write flv previous tag size failed. ret=%d", ret); | 250 | srs_error("write flv previous tag size failed. ret=%d", ret); |
251 | + } | ||
242 | return ret; | 252 | return ret; |
243 | } | 253 | } |
244 | 254 |
-
请 注册 或 登录 后发表评论