Robustified Socket::Connection, added debugging data for copies/assigns and Socket::Connetion::open() calls for proper socket re-use.
This commit is contained in:
parent
8fe1dbb618
commit
66890c4564
16 changed files with 141 additions and 44 deletions
|
@ -323,7 +323,7 @@ dashAnalyser::dashAnalyser(Util::Config conf) : analysers(conf) {
|
|||
startTime = Util::bootSecs();
|
||||
abortTime = conf.getInteger("abort");
|
||||
|
||||
conn = Socket::Connection(server, port, false);
|
||||
conn.open(server, port, false);
|
||||
|
||||
if(!conn.connected())
|
||||
{
|
||||
|
@ -336,7 +336,7 @@ dashAnalyser::dashAnalyser(Util::Config conf) : analysers(conf) {
|
|||
urlPrependStuff = url.substr(0, url.rfind("/") + 1);
|
||||
DEBUG_MSG(DLVL_INFO, "prepend stuff: %s", urlPrependStuff.c_str());
|
||||
if (!conn) {
|
||||
conn = Socket::Connection(server, port, false);
|
||||
conn.open(server, port, false);
|
||||
}
|
||||
|
||||
pos = 0;
|
||||
|
@ -414,7 +414,7 @@ int dashAnalyser::doAnalyse() {
|
|||
for (unsigned int i = 0; i < streamData.size(); i++) {
|
||||
if (streamData[i].trackID == currentPos.begin()->trackID && streamData[i].adaptationSet == currentPos.begin()->adaptationSet) tempID = i;
|
||||
}
|
||||
if (!conn) { conn = Socket::Connection(server, port, false); }
|
||||
if (!conn) { conn.open(server, port, false); }
|
||||
HTTP::Parser H;
|
||||
H.url = urlPrependStuff;
|
||||
H.url.append(currentPos.begin()->url);
|
||||
|
@ -530,7 +530,7 @@ int main2(int argc, char **argv) {
|
|||
DEBUG_MSG(DLVL_INFO, "url %s server: %s port: %d", url.c_str(), server.c_str(), port);
|
||||
std::string urlPrependStuff = url.substr(0, url.rfind("/") + 1);
|
||||
DEBUG_MSG(DLVL_INFO, "prepend stuff: %s", urlPrependStuff.c_str());
|
||||
if (!conn) { conn = Socket::Connection(server, port, false); }
|
||||
if (!conn) { conn.open(server, port, false); }
|
||||
unsigned int pos = 0;
|
||||
HTTP::Parser H;
|
||||
H.url = url;
|
||||
|
@ -593,7 +593,7 @@ int main2(int argc, char **argv) {
|
|||
for (unsigned int i = 0; i < streamData.size(); i++) {
|
||||
if (streamData[i].trackID == currentPos.begin()->trackID && streamData[i].adaptationSet == currentPos.begin()->adaptationSet) tempID = i;
|
||||
}
|
||||
if (!conn) { conn = Socket::Connection(server, port, false); }
|
||||
if (!conn) { conn.open(server, port, false); }
|
||||
HTTP::Parser H;
|
||||
H.url = urlPrependStuff;
|
||||
H.url.append(currentPos.begin()->url);
|
||||
|
|
|
@ -14,7 +14,7 @@ void AnalyserDTSC::init(Util::Config &conf){
|
|||
|
||||
bool AnalyserDTSC::open(const std::string &filename){
|
||||
if (!Analyser::open(filename)){return false;}
|
||||
conn = Socket::Connection(1, 0);
|
||||
conn.open(1, 0);
|
||||
totalBytes = 0;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ void AnalyserRTSP::incoming(const DTSC::Packet &pkt){
|
|||
|
||||
bool AnalyserRTSP::open(const std::string &filename){
|
||||
if (!Analyser::open(filename)){return false;}
|
||||
myConn = Socket::Connection(1, 0);
|
||||
myConn.open(1, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -369,7 +369,7 @@ int main(int argc, char ** argv) {
|
|||
std::string urlPrependStuff= url.substr(0, url.rfind("/")+1);
|
||||
DEBUG_MSG(DLVL_INFO, "prepend stuff: %s", urlPrependStuff.c_str());
|
||||
if (!conn) {
|
||||
conn = Socket::Connection(server, port, false);
|
||||
conn.open(server, port, false);
|
||||
}
|
||||
unsigned int pos = 0;
|
||||
HTTP::Parser H;
|
||||
|
@ -434,7 +434,7 @@ int main(int argc, char ** argv) {
|
|||
if( streamData[i].trackID == currentPos.begin()->trackID && streamData[i].adaptationSet == currentPos.begin()->adaptationSet ) tempID=i;
|
||||
}
|
||||
if (!conn) {
|
||||
conn = Socket::Connection(server,port, false);
|
||||
conn.open(server,port, false);
|
||||
}
|
||||
HTTP::Parser H;
|
||||
H.url = urlPrependStuff;
|
||||
|
|
|
@ -39,7 +39,7 @@ void Controller::uplinkConnection(void * np) {
|
|||
while (Controller::conf.is_active) {
|
||||
if (!uplink) {
|
||||
INFO_MSG("Connecting to uplink at %s:%u", uplink_host.c_str(), uplink_port);
|
||||
uplink = Socket::Connection(uplink_host, uplink_port, true);
|
||||
uplink.open(uplink_host, uplink_port, true);
|
||||
}
|
||||
if (uplink) {
|
||||
if (uplink.spool()) {
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace Mist {
|
|||
bool inputDTSC::openStreamSource() {
|
||||
std::string source = config->getString("input");
|
||||
if (source == "-"){
|
||||
srcConn = Socket::Connection(fileno(stdout),fileno(stdin));
|
||||
srcConn.open(fileno(stdout),fileno(stdin));
|
||||
return true;
|
||||
}
|
||||
if (source.find("dtsc://") == 0) {
|
||||
|
@ -175,7 +175,7 @@ namespace Mist {
|
|||
if (streamName == "") {
|
||||
streamName = givenStream;
|
||||
}
|
||||
srcConn = Socket::Connection(host, port, true);
|
||||
srcConn.open(host, port, true);
|
||||
if (!srcConn.connected()){
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -44,9 +44,9 @@ namespace Mist{
|
|||
|
||||
int fin = -1, fout = -1;
|
||||
inputProcess = Util::Procs::StartPiped(args, &fin, &fout, 0);
|
||||
myConn = Socket::Connection(-1, fout);
|
||||
myConn.open(-1, fout);
|
||||
}else{
|
||||
myConn = Socket::Connection(fileno(stdout), fileno(stdin));
|
||||
myConn.open(fileno(stdout), fileno(stdin));
|
||||
}
|
||||
myConn.Received().splitter.assign("\000\000\001", 3);
|
||||
myMeta.vod = false;
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace Mist{
|
|||
}
|
||||
|
||||
bool InputRTSP::openStreamSource(){
|
||||
tcpCon = Socket::Connection(url.host, url.getPort(), false);
|
||||
tcpCon.open(url.host, url.getPort(), false);
|
||||
mainConn = &tcpCon;
|
||||
return tcpCon;
|
||||
}
|
||||
|
|
|
@ -212,13 +212,13 @@ namespace Mist {
|
|||
|
||||
int fin = -1, fout = -1;
|
||||
inputProcess = Util::Procs::StartPiped(args, &fin, &fout, 0);
|
||||
tcpCon = Socket::Connection(-1, fout);
|
||||
tcpCon.open(-1, fout);
|
||||
return true;
|
||||
}
|
||||
//streamed file
|
||||
if (inpt.substr(0,9) == "stream://"){
|
||||
inFile = fopen(inpt.c_str()+9, "r");
|
||||
tcpCon = Socket::Connection(-1, fileno(inFile));
|
||||
tcpCon.open(-1, fileno(inFile));
|
||||
standAlone = false;
|
||||
return inFile;
|
||||
}
|
||||
|
|
|
@ -41,8 +41,7 @@ namespace Mist {
|
|||
std::string host = getConnectedHost();
|
||||
dup2(myConn.getSocket(), STDIN_FILENO);
|
||||
dup2(myConn.getSocket(), STDOUT_FILENO);
|
||||
myConn.drop();
|
||||
myConn = Socket::Connection(STDOUT_FILENO, STDIN_FILENO);
|
||||
myConn.open(STDOUT_FILENO, STDIN_FILENO);
|
||||
myConn.setHost(host);
|
||||
}
|
||||
if (config->getString("nostreamtext").size()){
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Mist{
|
|||
|
||||
int fin = -1;
|
||||
Util::Procs::StartPiped(args, &fin, 0, 0);
|
||||
myConn = Socket::Connection(fin, -1);
|
||||
myConn.open(fin, -1);
|
||||
|
||||
wantRequest = false;
|
||||
parseData = true;
|
||||
|
|
|
@ -143,7 +143,7 @@ void pushFirstElement(std::string qId) {
|
|||
proxyToPost(srcConn, srcLocation, dstConn, dstLocation);
|
||||
|
||||
|
||||
srcConn = Socket::Connection(srcHost, srcPort, true);
|
||||
srcConn.open(srcHost, srcPort, true);
|
||||
|
||||
//Set the location to push to for the index containing this segment.
|
||||
//The index will contain (at most) the last PUSH_INDEX_SIZE segments.
|
||||
|
@ -156,7 +156,7 @@ void pushFirstElement(std::string qId) {
|
|||
proxyToPost(srcConn, srcLocation, dstConn, dstLocation);
|
||||
|
||||
|
||||
srcConn = Socket::Connection(srcHost, srcPort, true);
|
||||
srcConn.open(srcHost, srcPort, true);
|
||||
|
||||
//Set the location to push to for the global index containing all qualities.
|
||||
srcLocation = baseURL + "/push/index.m3u8";
|
||||
|
@ -255,7 +255,7 @@ namespace Mist {
|
|||
}
|
||||
//Reconnect when disconnected
|
||||
if (!listConn.connected()){
|
||||
listConn = Socket::Connection(srcHost, srcPort, true);
|
||||
listConn.open(srcHost, srcPort, true);
|
||||
}
|
||||
//Request the push list
|
||||
if (listConn.connected()){
|
||||
|
|
|
@ -43,9 +43,9 @@ namespace Mist{
|
|||
}
|
||||
initialize();
|
||||
INFO_MSG("About to push stream %s out. Host: %s, port: %d, app: %s, stream: %s", streamName.c_str(), pushUrl.host.c_str(), pushUrl.getPort(), app.c_str(), streamOut.c_str());
|
||||
if (pushUrl.protocol == "rtmp"){myConn = Socket::Connection(pushUrl.host, pushUrl.getPort(), false);}
|
||||
if (pushUrl.protocol == "rtmp"){myConn.open(pushUrl.host, pushUrl.getPort(), false);}
|
||||
#ifdef SSL
|
||||
if (pushUrl.protocol == "rtmps"){myConn = Socket::Connection(pushUrl.host, pushUrl.getPort(), false, true);}
|
||||
if (pushUrl.protocol == "rtmps"){myConn.open(pushUrl.host, pushUrl.getPort(), false, true);}
|
||||
#endif
|
||||
if (!myConn){
|
||||
FAIL_MSG("Could not connect to %s:%d!", pushUrl.host.c_str(), pushUrl.getPort());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue