1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00
srs/trunk/src
Winlin d27e530f84 HTTP-FLV: Notify connection to expire when unpublishing. v6.0.152 (#4164)
When stopping the stream, it will wait for the HTTP Streaming to exit.
If the HTTP Streaming goroutine hangs, it will not exit automatically.

```cpp
void SrsHttpStreamServer::http_unmount(SrsRequest* r)
{
    SrsUniquePtr<SrsLiveStream> stream(entry->stream);
    if (stream->entry) stream->entry->enabled = false;
    srs_usleep(...); // Wait for about 120s.
    mux.unhandle(entry->mount, stream.get()); // Free stream.
}

srs_error_t SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
{
    err = do_serve_http(w, r); // If stuck in here for 120s+
    alive_viewers_--; // Crash at here, because stream has been deleted.
```

We should notify http stream connection to interrupt(expire):

```cpp
void SrsHttpStreamServer::http_unmount(SrsRequest* r)
{
    SrsUniquePtr<SrsLiveStream> stream(entry->stream);
    if (stream->entry) stream->entry->enabled = false;
    stream->expire(); // Notify http stream to interrupt.
```

Note that we should notify all viewers pulling stream from this http
stream.

Note that we have tried to fix this issue, but only try to wait for all
viewers to quit, without interrupting the viewers, see
https://github.com/ossrs/srs/pull/4144

---------

Co-authored-by: Jacob Su <suzp1984@gmail.com>
2024-08-31 23:17:07 +08:00
..
app HTTP-FLV: Notify connection to expire when unpublishing. v6.0.152 (#4164) 2024-08-31 23:17:07 +08:00
core HTTP-FLV: Notify connection to expire when unpublishing. v6.0.152 (#4164) 2024-08-31 23:17:07 +08:00
kernel HTTP-TS: Support guess_has_av for audio only stream. v6.0.141 (#4063) 2024-07-24 11:00:18 +08:00
main Fix crash when quiting. v6.0.151 (#4157) 2024-08-24 22:41:21 +08:00
protocol UniquePtr: Support SrsUniquePtr to replace SrsAutoFree. v6.0.136 (#4109) 2024-07-09 10:29:36 +08:00
utest Config: Add more utest for env config. v6.0.147 (#4142) 2024-08-15 11:13:00 +08:00