winlin

for bug #194, remove the poll, it's no-use

... ... @@ -388,8 +388,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
"srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config"
"srs_app_pithy_print" "srs_app_reload" "srs_app_http_api" "srs_app_http_conn" "srs_app_http_hooks"
"srs_app_json" "srs_app_ingest" "srs_app_ffmpeg" "srs_app_utility" "srs_app_dvr" "srs_app_edge"
"srs_app_kbps" "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client" "srs_app_avc_aac"
"srs_app_poll")
"srs_app_kbps" "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client" "srs_app_avc_aac")
APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh
APP_OBJS="${MODULE_OBJS[@]}"
fi
... ...
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_app_poll.hpp>
#include <srs_kernel_error.hpp>
#include <srs_kernel_log.hpp>
SrsPoll::SrsPoll()
{
_stfd = NULL;
_active = false;
}
SrsPoll::~SrsPoll()
{
}
int SrsPoll::initialize(st_netfd_t stfd)
{
int ret = ERROR_SUCCESS;
_stfd = stfd;
return ret;
}
bool SrsPoll::active()
{
return _active;
}
void SrsPoll::set_active(bool v)
{
_active = v;
}
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_APP_POLL_HPP
#define SRS_APP_POLL_HPP
/*
#include <srs_app_poll.hpp>
*/
#include <srs_core.hpp>
#include <map>
#include <srs_app_st.hpp>
#include <srs_app_thread.hpp>
/**
* the poll fd to check whether the specified fd is active.
* we start new thread to covert the fd status to async.
* for performance issue, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194
*/
class SrsPoll
{
private:
st_netfd_t _stfd;
// whether current fd is active.
bool _active;
public:
SrsPoll();
virtual ~SrsPoll();
public:
/**
* initialize the poll.
* @param stfd the fd to poll.
*/
virtual int initialize(st_netfd_t stfd);
/**
* whether fd is active.
*/
virtual bool active();
/**
* the poll will set to fd active when got data to read,
* the connection will set to deactive when data read.
*/
virtual void set_active(bool v);
};
#endif
... ... @@ -48,7 +48,6 @@ using namespace std;
#include <srs_app_utility.hpp>
#include <srs_protocol_msg_array.hpp>
#include <srs_protocol_amf0.hpp>
#include <srs_app_poll.hpp>
// when stream is busy, for example, streaming is already
// publishing, when a new client to request to publish,
... ... @@ -517,16 +516,10 @@ int SrsRtmpConn::playing(SrsSource* source)
SrsAutoFree(SrsConsumer, consumer);
srs_verbose("consumer created success.");
// use poll fd to manage the connection, read when active.
SrsPoll poll_fd;
if ((ret = poll_fd.initialize(stfd)) != ERROR_SUCCESS) {
return ret;
}
// TODO: FIXME: remove following.
//rtmp->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
rtmp->set_recv_timeout(ST_UTIME_NO_TIMEOUT);
rtmp->set_send_timeout(ST_UTIME_NO_TIMEOUT);
rtmp->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
//rtmp->set_recv_timeout(ST_UTIME_NO_TIMEOUT);
//rtmp->set_send_timeout(ST_UTIME_NO_TIMEOUT);
// initialize other components
SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PLAY_USER);
... ... @@ -539,9 +532,7 @@ int SrsRtmpConn::playing(SrsSource* source)
pithy_print.elapse();
// read from client.
if (poll_fd.active()) {
poll_fd.set_active(false);
if (true) {
SrsMessage* msg = NULL;
ret = rtmp->recv_message(&msg);
srs_verbose("play loop recv message. ret=%d", ret);
... ... @@ -574,9 +565,9 @@ int SrsRtmpConn::playing(SrsSource* source)
// no data, sleep a while.
// for the poll_fd maybe not active, and no message.
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/194
if (count <= 0) {
st_usleep(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
}
//if (count <= 0) {
// st_usleep(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
//}
// reportable
if (pithy_print.can_print()) {
... ...
... ... @@ -185,7 +185,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define ERROR_EDGE_VHOST_REMOVED 3039
#define ERROR_HLS_AVC_TRY_OTHERS 3040
#define ERROR_H264_API_NO_PREFIXED 3041
#define ERROR_RTMP_POLL_FD_DUPLICATED 3042
/**
* whether the error code is an system control error.
... ...
... ... @@ -92,8 +92,6 @@ file
..\app\srs_app_kbps.cpp,
..\app\srs_app_log.hpp,
..\app\srs_app_log.cpp,
..\app\srs_app_poll.hpp,
..\app\srs_app_poll.cpp,
..\app\srs_app_refer.hpp,
..\app\srs_app_refer.cpp,
..\app\srs_app_reload.hpp,
... ...