1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Rename SrsCoroutineManager to SrsConnectionManager

This commit is contained in:
winlin 2020-09-11 17:20:41 +08:00
parent d8a158290f
commit 4eae93d27b
10 changed files with 20 additions and 23 deletions

View file

@ -49,7 +49,7 @@ SrsAppCasterFlv::SrsAppCasterFlv(SrsConfDirective* c)
{ {
http_mux = new SrsHttpServeMux(); http_mux = new SrsHttpServeMux();
output = _srs_config->get_stream_caster_output(c); output = _srs_config->get_stream_caster_output(c);
manager = new SrsCoroutineManager(); manager = new SrsConnectionManager();
} }
SrsAppCasterFlv::~SrsAppCasterFlv() SrsAppCasterFlv::~SrsAppCasterFlv()

View file

@ -54,7 +54,7 @@ private:
std::string output; std::string output;
SrsHttpServeMux* http_mux; SrsHttpServeMux* http_mux;
std::vector<SrsHttpConn*> conns; std::vector<SrsHttpConn*> conns;
SrsCoroutineManager* manager; SrsConnectionManager* manager;
public: public:
SrsAppCasterFlv(SrsConfDirective* c); SrsAppCasterFlv(SrsConfDirective* c);
virtual ~SrsAppCasterFlv(); virtual ~SrsAppCasterFlv();

View file

@ -31,13 +31,13 @@ using namespace std;
#include <srs_app_utility.hpp> #include <srs_app_utility.hpp>
#include <srs_kernel_utility.hpp> #include <srs_kernel_utility.hpp>
SrsCoroutineManager::SrsCoroutineManager() SrsConnectionManager::SrsConnectionManager()
{ {
cond = srs_cond_new(); cond = srs_cond_new();
trd = new SrsSTCoroutine("manager", this); trd = new SrsSTCoroutine("manager", this);
} }
SrsCoroutineManager::~SrsCoroutineManager() SrsConnectionManager::~SrsConnectionManager()
{ {
srs_freep(trd); srs_freep(trd);
srs_cond_destroy(cond); srs_cond_destroy(cond);
@ -45,7 +45,7 @@ SrsCoroutineManager::~SrsCoroutineManager()
clear(); clear();
} }
srs_error_t SrsCoroutineManager::start() srs_error_t SrsConnectionManager::start()
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -56,7 +56,7 @@ srs_error_t SrsCoroutineManager::start()
return err; return err;
} }
srs_error_t SrsCoroutineManager::cycle() srs_error_t SrsConnectionManager::cycle()
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -72,7 +72,7 @@ srs_error_t SrsCoroutineManager::cycle()
return err; return err;
} }
void SrsCoroutineManager::remove(ISrsConnection* c) void SrsConnectionManager::remove(ISrsConnection* c)
{ {
if (::find(conns.begin(), conns.end(), c) == conns.end()) { if (::find(conns.begin(), conns.end(), c) == conns.end()) {
conns.push_back(c); conns.push_back(c);
@ -80,7 +80,7 @@ void SrsCoroutineManager::remove(ISrsConnection* c)
srs_cond_signal(cond); srs_cond_signal(cond);
} }
void SrsCoroutineManager::clear() void SrsConnectionManager::clear()
{ {
// To prevent thread switch when delete connection, // To prevent thread switch when delete connection,
// we copy all connections then free one by one. // we copy all connections then free one by one.

View file

@ -36,19 +36,16 @@
class SrsWallClock; class SrsWallClock;
// The coroutine manager use a thread to delete a connection, which will stop the service // The connection manager remove connection and delete it asynchronously.
// thread, for example, when the RTMP connection thread cycle terminated, it will notify class SrsConnectionManager : virtual public ISrsCoroutineHandler, virtual public IConnectionManager
// the manager(the server) to remove the connection from list of server and push it to
// the manager thread to delete it, finally the thread of connection will stop.
class SrsCoroutineManager : virtual public ISrsCoroutineHandler, virtual public IConnectionManager
{ {
private: private:
SrsCoroutine* trd; SrsCoroutine* trd;
std::vector<ISrsConnection*> conns; std::vector<ISrsConnection*> conns;
srs_cond_t cond; srs_cond_t cond;
public: public:
SrsCoroutineManager(); SrsConnectionManager();
virtual ~SrsCoroutineManager(); virtual ~SrsConnectionManager();
public: public:
srs_error_t start(); srs_error_t start();
// Interface ISrsCoroutineHandler // Interface ISrsCoroutineHandler

View file

@ -1890,7 +1890,7 @@ SrsGb28181Manger::SrsGb28181Manger(SrsServer *s, SrsConfDirective* c)
// TODO: FIXME: support reload. // TODO: FIXME: support reload.
server = s; server = s;
config = new SrsGb28181Config(c); config = new SrsGb28181Config(c);
manager = new SrsCoroutineManager(); manager = new SrsConnectionManager();
} }
SrsGb28181Manger::~SrsGb28181Manger() SrsGb28181Manger::~SrsGb28181Manger()

View file

@ -473,7 +473,7 @@ private:
std::map<uint32_t, SrsPsRtpListener*> rtp_pool; std::map<uint32_t, SrsPsRtpListener*> rtp_pool;
std::map<uint32_t, SrsGb28181RtmpMuxer*> rtmpmuxers_ssrc; std::map<uint32_t, SrsGb28181RtmpMuxer*> rtmpmuxers_ssrc;
std::map<std::string, SrsGb28181RtmpMuxer*> rtmpmuxers; std::map<std::string, SrsGb28181RtmpMuxer*> rtmpmuxers;
SrsCoroutineManager* manager; SrsConnectionManager* manager;
SrsGb28181SipService* sip_service; SrsGb28181SipService* sip_service;
SrsServer* server; SrsServer* server;
public: public:

View file

@ -712,7 +712,7 @@ SrsRtspCaster::SrsRtspCaster(SrsConfDirective* c)
output = _srs_config->get_stream_caster_output(c); output = _srs_config->get_stream_caster_output(c);
local_port_min = _srs_config->get_stream_caster_rtp_port_min(c); local_port_min = _srs_config->get_stream_caster_rtp_port_min(c);
local_port_max = _srs_config->get_stream_caster_rtp_port_max(c); local_port_max = _srs_config->get_stream_caster_rtp_port_max(c);
manager = new SrsCoroutineManager(); manager = new SrsConnectionManager();
} }
SrsRtspCaster::~SrsRtspCaster() SrsRtspCaster::~SrsRtspCaster()

View file

@ -51,7 +51,7 @@ class SrsAudioFrame;
class SrsSimpleStream; class SrsSimpleStream;
class SrsPithyPrint; class SrsPithyPrint;
class SrsSimpleRtmpClient; class SrsSimpleRtmpClient;
class SrsCoroutineManager; class SrsConnectionManager;
// A rtp connection which transport a stream. // A rtp connection which transport a stream.
class SrsRtpConn: public ISrsUdpHandler class SrsRtpConn: public ISrsUdpHandler
@ -182,7 +182,7 @@ private:
std::map<int, bool> used_ports; std::map<int, bool> used_ports;
private: private:
std::vector<SrsRtspConn*> clients; std::vector<SrsRtspConn*> clients;
SrsCoroutineManager* manager; SrsConnectionManager* manager;
public: public:
SrsRtspCaster(SrsConfDirective* c); SrsRtspCaster(SrsConfDirective* c);
virtual ~SrsRtspCaster(); virtual ~SrsRtspCaster();

View file

@ -656,7 +656,7 @@ SrsServer::SrsServer()
pid_fd = -1; pid_fd = -1;
signal_manager = new SrsSignalManager(this); signal_manager = new SrsSignalManager(this);
conn_manager = new SrsCoroutineManager(); conn_manager = new SrsConnectionManager();
handler = NULL; handler = NULL;
ppid = ::getppid(); ppid = ::getppid();

View file

@ -53,7 +53,7 @@ class SrsUdpListener;
class SrsTcpListener; class SrsTcpListener;
class SrsAppCasterFlv; class SrsAppCasterFlv;
class SrsRtspCaster; class SrsRtspCaster;
class SrsCoroutineManager; class SrsConnectionManager;
class SrsGb28181Caster; class SrsGb28181Caster;
@ -249,7 +249,7 @@ private:
SrsHttpServer* http_server; SrsHttpServer* http_server;
SrsHttpHeartbeat* http_heartbeat; SrsHttpHeartbeat* http_heartbeat;
SrsIngester* ingester; SrsIngester* ingester;
SrsCoroutineManager* conn_manager; SrsConnectionManager* conn_manager;
private: private:
// The pid file fd, lock the file write when server is running. // The pid file fd, lock the file write when server is running.
// @remark the init.d script should cleanup the pid file, when stop service, // @remark the init.d script should cleanup the pid file, when stop service,