mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix the export project bug. wakeup connection when dispose server.
This commit is contained in:
parent
969ed7b0ae
commit
1f1776a0d8
5 changed files with 65 additions and 17 deletions
|
@ -80,7 +80,7 @@ function build_module_hpp()
|
||||||
}
|
}
|
||||||
SRS_LIBRTMP_OBJS="${CORE_OBJS[@]}" && build_module_hpp
|
SRS_LIBRTMP_OBJS="${CORE_OBJS[@]}" && build_module_hpp
|
||||||
SRS_LIBRTMP_OBJS="${KERNEL_OBJS[@]}" && build_module_hpp
|
SRS_LIBRTMP_OBJS="${KERNEL_OBJS[@]}" && build_module_hpp
|
||||||
SRS_LIBRTMP_OBJS="${RTMP_OBJS[@]}" && build_module_hpp
|
SRS_LIBRTMP_OBJS="${PROTOCOL_OBJS[@]}" && build_module_hpp
|
||||||
SRS_LIBRTMP_OBJS="${LIBS_OBJS[@]}" && build_module_hpp
|
SRS_LIBRTMP_OBJS="${LIBS_OBJS[@]}" && build_module_hpp
|
||||||
# module to cpp files.
|
# module to cpp files.
|
||||||
function build_module_cpp()
|
function build_module_cpp()
|
||||||
|
@ -99,7 +99,7 @@ function build_module_cpp()
|
||||||
}
|
}
|
||||||
SRS_LIBRTMP_OBJS="${CORE_OBJS[@]}" && build_module_cpp
|
SRS_LIBRTMP_OBJS="${CORE_OBJS[@]}" && build_module_cpp
|
||||||
SRS_LIBRTMP_OBJS="${KERNEL_OBJS[@]}" && build_module_cpp
|
SRS_LIBRTMP_OBJS="${KERNEL_OBJS[@]}" && build_module_cpp
|
||||||
SRS_LIBRTMP_OBJS="${RTMP_OBJS[@]}" && build_module_cpp
|
SRS_LIBRTMP_OBJS="${PROTOCOL_OBJS[@]}" && build_module_cpp
|
||||||
SRS_LIBRTMP_OBJS="${LIBS_OBJS[@]}" && build_module_cpp
|
SRS_LIBRTMP_OBJS="${LIBS_OBJS[@]}" && build_module_cpp
|
||||||
|
|
||||||
# create example.cpp
|
# create example.cpp
|
||||||
|
|
|
@ -88,6 +88,7 @@ SrsRtmpConn::SrsRtmpConn(SrsServer* svr, st_netfd_t c)
|
||||||
duration = 0;
|
duration = 0;
|
||||||
kbps = new SrsKbps();
|
kbps = new SrsKbps();
|
||||||
kbps->set_io(skt, skt);
|
kbps->set_io(skt, skt);
|
||||||
|
wakable = NULL;
|
||||||
|
|
||||||
mw_sleep = SRS_PERF_MW_SLEEP;
|
mw_sleep = SRS_PERF_MW_SLEEP;
|
||||||
mw_enabled = false;
|
mw_enabled = false;
|
||||||
|
@ -110,6 +111,16 @@ SrsRtmpConn::~SrsRtmpConn()
|
||||||
srs_freep(kbps);
|
srs_freep(kbps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsRtmpConn::dispose()
|
||||||
|
{
|
||||||
|
SrsConnection::dispose();
|
||||||
|
|
||||||
|
// wakeup the handler which need to notice.
|
||||||
|
if (wakable) {
|
||||||
|
wakable->wakeup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: return detail message when error for client.
|
// TODO: return detail message when error for client.
|
||||||
int SrsRtmpConn::do_cycle()
|
int SrsRtmpConn::do_cycle()
|
||||||
{
|
{
|
||||||
|
@ -597,7 +608,9 @@ int SrsRtmpConn::playing(SrsSource* source)
|
||||||
}
|
}
|
||||||
|
|
||||||
// delivery messages for clients playing stream.
|
// delivery messages for clients playing stream.
|
||||||
|
wakable = consumer;
|
||||||
ret = do_playing(source, consumer, &trd);
|
ret = do_playing(source, consumer, &trd);
|
||||||
|
wakable = NULL;
|
||||||
|
|
||||||
// stop isolate recv thread
|
// stop isolate recv thread
|
||||||
trd.stop();
|
trd.stop();
|
||||||
|
|
|
@ -53,6 +53,7 @@ class SrsSharedPtrMessage;
|
||||||
class SrsQueueRecvThread;
|
class SrsQueueRecvThread;
|
||||||
class SrsPublishRecvThread;
|
class SrsPublishRecvThread;
|
||||||
class SrsSecurity;
|
class SrsSecurity;
|
||||||
|
class ISrsWakable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the client provides the main logic control for RTMP clients.
|
* the client provides the main logic control for RTMP clients.
|
||||||
|
@ -70,6 +71,8 @@ private:
|
||||||
SrsRefer* refer;
|
SrsRefer* refer;
|
||||||
SrsBandwidth* bandwidth;
|
SrsBandwidth* bandwidth;
|
||||||
SrsSecurity* security;
|
SrsSecurity* security;
|
||||||
|
// the wakable handler, maybe NULL.
|
||||||
|
ISrsWakable* wakable;
|
||||||
// elapse duration in ms
|
// elapse duration in ms
|
||||||
// for live play duration, for instance, rtmpdump to record.
|
// for live play duration, for instance, rtmpdump to record.
|
||||||
// @see https://github.com/simple-rtmp-server/srs/issues/47
|
// @see https://github.com/simple-rtmp-server/srs/issues/47
|
||||||
|
@ -85,6 +88,8 @@ private:
|
||||||
public:
|
public:
|
||||||
SrsRtmpConn(SrsServer* svr, st_netfd_t c);
|
SrsRtmpConn(SrsServer* svr, st_netfd_t c);
|
||||||
virtual ~SrsRtmpConn();
|
virtual ~SrsRtmpConn();
|
||||||
|
public:
|
||||||
|
virtual void dispose();
|
||||||
protected:
|
protected:
|
||||||
virtual int do_cycle();
|
virtual int do_cycle();
|
||||||
// interface ISrsReloadHandler
|
// interface ISrsReloadHandler
|
||||||
|
|
|
@ -423,6 +423,14 @@ void SrsMessageQueue::clear()
|
||||||
av_start_time = av_end_time = -1;
|
av_start_time = av_end_time = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ISrsWakable::ISrsWakable()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ISrsWakable::~ISrsWakable()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
SrsConsumer::SrsConsumer(SrsSource* _source)
|
SrsConsumer::SrsConsumer(SrsSource* _source)
|
||||||
{
|
{
|
||||||
source = _source;
|
source = _source;
|
||||||
|
@ -551,14 +559,6 @@ void SrsConsumer::wait(int nb_msgs, int duration)
|
||||||
// use cond block wait for high performance mode.
|
// use cond block wait for high performance mode.
|
||||||
st_cond_wait(mw_wait);
|
st_cond_wait(mw_wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsConsumer::wakeup()
|
|
||||||
{
|
|
||||||
if (mw_waiting) {
|
|
||||||
st_cond_signal(mw_wait);
|
|
||||||
mw_waiting = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int SrsConsumer::on_play_client_pause(bool is_pause)
|
int SrsConsumer::on_play_client_pause(bool is_pause)
|
||||||
|
@ -571,6 +571,16 @@ int SrsConsumer::on_play_client_pause(bool is_pause)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsConsumer::wakeup()
|
||||||
|
{
|
||||||
|
#ifdef SRS_PERF_QUEUE_COND_WAIT
|
||||||
|
if (mw_waiting) {
|
||||||
|
st_cond_signal(mw_wait);
|
||||||
|
mw_waiting = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
SrsGopCache::SrsGopCache()
|
SrsGopCache::SrsGopCache()
|
||||||
{
|
{
|
||||||
cached_video_count = 0;
|
cached_video_count = 0;
|
||||||
|
|
|
@ -196,10 +196,28 @@ private:
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the wakable used for some object
|
||||||
|
* which is waiting on cond.
|
||||||
|
*/
|
||||||
|
class ISrsWakable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ISrsWakable();
|
||||||
|
virtual ~ISrsWakable();
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* when the consumer(for player) got msg from recv thread,
|
||||||
|
* it must be processed for maybe it's a close msg, so the cond
|
||||||
|
* wait must be wakeup.
|
||||||
|
*/
|
||||||
|
virtual void wakeup() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the consumer for SrsSource, that is a play client.
|
* the consumer for SrsSource, that is a play client.
|
||||||
*/
|
*/
|
||||||
class SrsConsumer
|
class SrsConsumer : public ISrsWakable
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsRtmpJitter* jitter;
|
SrsRtmpJitter* jitter;
|
||||||
|
@ -257,17 +275,19 @@ public:
|
||||||
* @param duration the messgae duration to wait.
|
* @param duration the messgae duration to wait.
|
||||||
*/
|
*/
|
||||||
virtual void wait(int nb_msgs, int duration);
|
virtual void wait(int nb_msgs, int duration);
|
||||||
/**
|
|
||||||
* when the consumer(for player) got msg from recv thread,
|
|
||||||
* it must be processed for maybe it's a close msg, so the cond
|
|
||||||
* wait must be wakeup.
|
|
||||||
*/
|
|
||||||
virtual void wakeup();
|
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* when client send the pause message.
|
* when client send the pause message.
|
||||||
*/
|
*/
|
||||||
virtual int on_play_client_pause(bool is_pause);
|
virtual int on_play_client_pause(bool is_pause);
|
||||||
|
// ISrsWakable
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* when the consumer(for player) got msg from recv thread,
|
||||||
|
* it must be processed for maybe it's a close msg, so the cond
|
||||||
|
* wait must be wakeup.
|
||||||
|
*/
|
||||||
|
virtual void wakeup();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue