Fix #786, simply don't reuse object. 3.0.20

pull/790/head
winlin 8 years ago
parent 7680ac04ad
commit 308c6fee18

@ -186,6 +186,7 @@ Please select your language:
### V3 changes ### V3 changes
* v3.0, 2017-03-02, Fix [#786][bug #786], simply don't reuse object. 3.0.20
* v3.0, 2017-03-01, For [#110][bug #110], refine thread object. 3.0.19 * v3.0, 2017-03-01, For [#110][bug #110], refine thread object. 3.0.19
* v3.0, 2017-02-12, Fix [#301][bug #301], User must config the codec in right way for HLS. 3.0.18 * v3.0, 2017-02-12, Fix [#301][bug #301], User must config the codec in right way for HLS. 3.0.18
* v3.0, 2017-02-07, fix [#738][bug #738] support DVR general mp4. 3.0.17 * v3.0, 2017-02-07, fix [#738][bug #738] support DVR general mp4. 3.0.17
@ -1384,6 +1385,7 @@ Winlin
[bug #735]: https://github.com/ossrs/srs/issues/735 [bug #735]: https://github.com/ossrs/srs/issues/735
[bug #742]: https://github.com/ossrs/srs/issues/742 [bug #742]: https://github.com/ossrs/srs/issues/742
[bug #738]: https://github.com/ossrs/srs/issues/738 [bug #738]: https://github.com/ossrs/srs/issues/738
[bug #786]: https://github.com/ossrs/srs/issues/786
[bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx
[exo #828]: https://github.com/google/ExoPlayer/pull/828 [exo #828]: https://github.com/google/ExoPlayer/pull/828

@ -48,7 +48,7 @@ SrsConnection::SrsConnection(IConnectionManager* cm, st_netfd_t c, string cip)
expired = false; expired = false;
create_time = srs_get_system_time_ms(); create_time = srs_get_system_time_ms();
skt = new SrsStSocket(c); skt = new SrsStSocket();
kbps = new SrsKbps(); kbps = new SrsKbps();
kbps->set_io(skt, skt); kbps->set_io(skt, skt);
@ -105,6 +105,12 @@ void SrsConnection::dispose()
int SrsConnection::start() int SrsConnection::start()
{ {
int ret = ERROR_SUCCESS;
if ((ret = skt->initialize(stfd)) != ERROR_SUCCESS) {
return ret;
}
return pthread->start(); return pthread->start();
} }

@ -1342,12 +1342,9 @@ int SrsHttpApi::do_cycle()
return ret; return ret;
} }
// underlayer socket
SrsStSocket skt(stfd);
// set the recv timeout, for some clients never disconnect the connection. // set the recv timeout, for some clients never disconnect the connection.
// @see https://github.com/ossrs/srs/issues/398 // @see https://github.com/ossrs/srs/issues/398
skt.set_recv_timeout(SRS_HTTP_RECV_TMMS); skt->set_recv_timeout(SRS_HTTP_RECV_TMMS);
// initialize the cors, which will proxy to mux. // initialize the cors, which will proxy to mux.
bool crossdomain_enabled = _srs_config->get_http_api_crossdomain(); bool crossdomain_enabled = _srs_config->get_http_api_crossdomain();
@ -1360,7 +1357,7 @@ int SrsHttpApi::do_cycle()
ISrsHttpMessage* req = NULL; ISrsHttpMessage* req = NULL;
// get a http message // get a http message
if ((ret = parser->parse_message(&skt, this, &req)) != ERROR_SUCCESS) { if ((ret = parser->parse_message(skt, this, &req)) != ERROR_SUCCESS) {
return ret; return ret;
} }
@ -1371,7 +1368,7 @@ int SrsHttpApi::do_cycle()
SrsAutoFree(ISrsHttpMessage, req); SrsAutoFree(ISrsHttpMessage, req);
// ok, handle http request. // ok, handle http request.
SrsHttpResponseWriter writer(&skt); SrsHttpResponseWriter writer(skt);
if ((ret = process_request(&writer, req)) != ERROR_SUCCESS) { if ((ret = process_request(&writer, req)) != ERROR_SUCCESS) {
return ret; return ret;
} }

@ -302,7 +302,6 @@ SrsRtmpConn::SrsRtmpConn(SrsServer* svr, st_netfd_t c, string cip)
{ {
server = svr; server = svr;
skt = new SrsStSocket(c);
rtmp = new SrsRtmpServer(skt); rtmp = new SrsRtmpServer(skt);
refer = new SrsRefer(); refer = new SrsRefer();
bandwidth = new SrsBandwidth(); bandwidth = new SrsBandwidth();
@ -328,7 +327,6 @@ SrsRtmpConn::~SrsRtmpConn()
srs_freep(info); srs_freep(info);
srs_freep(rtmp); srs_freep(rtmp);
srs_freep(skt);
srs_freep(refer); srs_freep(refer);
srs_freep(bandwidth); srs_freep(bandwidth);
srs_freep(security); srs_freep(security);

@ -139,7 +139,6 @@ class SrsRtmpConn : public virtual SrsConnection, public virtual ISrsReloadHandl
friend class SrsPublishRecvThread; friend class SrsPublishRecvThread;
private: private:
SrsServer* server; SrsServer* server;
SrsStSocket* skt;
SrsRtmpServer* rtmp; SrsRtmpServer* rtmp;
SrsRefer* refer; SrsRefer* refer;
SrsBandwidth* bandwidth; SrsBandwidth* bandwidth;

@ -193,7 +193,7 @@ SrsRtspConn::SrsRtspConn(SrsRtspCaster* c, st_netfd_t fd, std::string o)
caster = c; caster = c;
stfd = fd; stfd = fd;
skt = new SrsStSocket(fd); skt = new SrsStSocket();
rtsp = new SrsRtspStack(skt); rtsp = new SrsRtspStack(skt);
trd = new SrsOneCycleThread("rtsp", this); trd = new SrsOneCycleThread("rtsp", this);
@ -232,6 +232,11 @@ SrsRtspConn::~SrsRtspConn()
int SrsRtspConn::serve() int SrsRtspConn::serve()
{ {
int ret = ERROR_SUCCESS;
if ((ret = skt->initialize(stfd)) != ERROR_SUCCESS) {
return ret;
}
return trd->start(); return trd->start();
} }

@ -208,9 +208,9 @@ namespace internal
} }
} }
SrsStSocket::SrsStSocket(st_netfd_t client_stfd) SrsStSocket::SrsStSocket()
{ {
stfd = client_stfd; stfd = NULL;
stm = rtm = SRS_CONSTS_NO_TMMS; stm = rtm = SRS_CONSTS_NO_TMMS;
rbytes = sbytes = 0; rbytes = sbytes = 0;
} }
@ -219,6 +219,12 @@ SrsStSocket::~SrsStSocket()
{ {
} }
int SrsStSocket::initialize(st_netfd_t fd)
{
stfd = fd;
return ERROR_SUCCESS;
}
bool SrsStSocket::is_never_timeout(int64_t tm) bool SrsStSocket::is_never_timeout(int64_t tm)
{ {
return tm == SRS_CONSTS_NO_TMMS; return tm == SRS_CONSTS_NO_TMMS;
@ -390,8 +396,8 @@ int SrsStSocket::writev(const iovec *iov, int iov_size, ssize_t* nwrite)
SrsTcpClient::SrsTcpClient(string h, int p, int64_t tm) SrsTcpClient::SrsTcpClient(string h, int p, int64_t tm)
{ {
io = NULL;
stfd = NULL; stfd = NULL;
io = new SrsStSocket();
host = h; host = h;
port = p; port = p;
@ -401,6 +407,8 @@ SrsTcpClient::SrsTcpClient(string h, int p, int64_t tm)
SrsTcpClient::~SrsTcpClient() SrsTcpClient::~SrsTcpClient()
{ {
close(); close();
srs_freep(io);
} }
int SrsTcpClient::connect() int SrsTcpClient::connect()
@ -415,8 +423,9 @@ int SrsTcpClient::connect()
return ret; return ret;
} }
srs_assert(io == NULL); if ((ret = io->initialize(stfd)) != ERROR_SUCCESS) {
io = new SrsStSocket(stfd); return ret;
}
return ret; return ret;
} }
@ -428,7 +437,6 @@ void SrsTcpClient::close()
return; return;
} }
srs_freep(io);
srs_close_stfd(stfd); srs_close_stfd(stfd);
} }

@ -182,8 +182,11 @@ private:
// The underlayer st fd. // The underlayer st fd.
st_netfd_t stfd; st_netfd_t stfd;
public: public:
SrsStSocket(st_netfd_t client_stfd); SrsStSocket();
virtual ~SrsStSocket(); virtual ~SrsStSocket();
public:
// Initialize the socket with stfd, user must manage it.
virtual int initialize(st_netfd_t fd);
public: public:
virtual bool is_never_timeout(int64_t tm); virtual bool is_never_timeout(int64_t tm);
virtual void set_recv_timeout(int64_t tm); virtual void set_recv_timeout(int64_t tm);
@ -240,6 +243,7 @@ public:
* @remark We will close the exists connection before do connect. * @remark We will close the exists connection before do connect.
*/ */
virtual int connect(); virtual int connect();
private:
/** /**
* Close the connection to server. * Close the connection to server.
* @remark User should never use the client when close it. * @remark User should never use the client when close it.

@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version // current release version
#define VERSION_MAJOR 3 #define VERSION_MAJOR 3
#define VERSION_MINOR 0 #define VERSION_MINOR 0
#define VERSION_REVISION 19 #define VERSION_REVISION 20
// generated by configure, only macros. // generated by configure, only macros.
#include <srs_auto_headers.hpp> #include <srs_auto_headers.hpp>

Loading…
Cancel
Save