mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed control port reading
This commit is contained in:
parent
1571446a2e
commit
1c576411fb
@ -30,6 +30,9 @@ RsFdBinInterface::RsFdBinInterface(int file_descriptor)
|
||||
mTotalInBufferBytes=0;
|
||||
mTotalWrittenBytes=0;
|
||||
mTotalOutBufferBytes=0;
|
||||
|
||||
if(file_descriptor!=0)
|
||||
setSocket(file_descriptor);
|
||||
}
|
||||
|
||||
void RsFdBinInterface::setSocket(int s)
|
||||
@ -39,6 +42,11 @@ void RsFdBinInterface::setSocket(int s)
|
||||
RsErr() << "Changing socket to active FsBioInterface! Canceling all pending R/W data." ;
|
||||
close();
|
||||
}
|
||||
int flags = fcntl(s,F_GETFL);
|
||||
|
||||
if(!(flags & O_NONBLOCK))
|
||||
throw std::runtime_error("Trying to use a blocking file descriptor in RsFdBinInterface. This is not going to work!");
|
||||
|
||||
mCLintConnt = s;
|
||||
mIsActive = (s!=0);
|
||||
}
|
||||
|
@ -413,12 +413,14 @@ std::string TorProcess::controlPortFilePath() const
|
||||
bool TorProcess::tryReadControlPort()
|
||||
{
|
||||
FILE *file = RsDirUtil::rs_fopen(controlPortFilePath().c_str(),"r");
|
||||
std::cerr << "Trying to read control port" << std::endl;
|
||||
|
||||
if(file)
|
||||
{
|
||||
char *line = nullptr;
|
||||
size_t tmp_buffsize = 0;
|
||||
|
||||
size_t size = getline(&line,0,file);
|
||||
size_t size = getline(&line,&tmp_buffsize,file);
|
||||
ByteArray data = ByteArray((unsigned char*)line,size).trimmed();
|
||||
free(line);
|
||||
|
||||
@ -428,9 +430,12 @@ bool TorProcess::tryReadControlPort()
|
||||
mControlPort = data.mid(p+1).toInt();
|
||||
|
||||
if (!mControlHost.empty() && mControlPort > 0)
|
||||
{
|
||||
std::cerr << "Read control port = " << mControlPort << std::endl;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#ifdef TO_REMOVE
|
||||
|
Loading…
Reference in New Issue
Block a user