- added failure tests for fwrite. Some where missing.

- added a test against the IP 1.0.0.0, which pops up on MacOS (when the peer is not connected to the internet?)
- put some additional debug messages.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5.0@3017 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-05-28 13:57:44 +00:00
parent c87fbfe2cb
commit b9deaf1ea3
4 changed files with 24 additions and 8 deletions

View File

@ -70,7 +70,12 @@ void ftFileCreator::closeFile()
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
if(fd != NULL)
{
#ifdef FILE_DEBUG
std::cerr << "CLOSED FILE " << (void*)fd << " (" << file_name << ")." << std::endl ;
#endif
fclose(fd) ;
}
fd = NULL ;
}
@ -229,7 +234,7 @@ int ftFileCreator::locked_initializeFileAttrs()
if (!fd)
{
std::cerr << "ftFileCreator::initializeFileAttrs() Failed to open (r+b): ";
std::cerr << file_name << std::endl;
std::cerr << file_name << ", errno = " << errno << std::endl;
std::cerr << "ftFileCreator::initializeFileAttrs() opening w+b";
std::cerr << std::endl;
@ -239,12 +244,12 @@ int ftFileCreator::locked_initializeFileAttrs()
if (!fd)
{
std::cerr << "ftFileCreator::initializeFileAttrs()";
std::cerr << " Failed to open (w+b): "<< file_name << std::endl;
std::cerr << " Failed to open (w+b): "<< file_name << ", errno = " << errno << std::endl;
return 0;
}
}
#ifdef FILE_DEBUG
std::cerr << "ftFileCreator::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl;
std::cerr << "OPENNED FILE " << (void*)fd << " (" << file_name << "), for r/w." << std::endl ;
#endif
return 1;

View File

@ -273,8 +273,12 @@ bool p3ConfigMgr::backedUpFileSave(const std::string& fname, const std::string&
return true;
}
fwrite(config_buff,1, size_file, file);
fwrite(sign_buff, 1, size_sign, sign);
if(size_file != fwrite(config_buff,1, size_file, file))
getPqiNotify()->AddSysMessage(0, RS_SYS_WARNING, "Write error", "Error while writing backup configuration file " + fname_backup + "\nIs your disc full or out of quota ?");
if(size_sign != fwrite(sign_buff, 1, size_sign, sign))
getPqiNotify()->AddSysMessage(0, RS_SYS_WARNING, "Write error", "Error while writing main signature file " + sign_fname_backup + "\nIs your disc full or out of quota ?");
fclose(file);
fclose(sign);
@ -751,7 +755,8 @@ bool p3Config::backedUpFileSave(const std::string& cfg_fname, const std::string&
written &= false; // at least one file save should be successful
}
if(size_file > 0){
if(size_file > 0)
{
// now write actual back-up file
cfg_file = fopen(cfg_fname_backup.c_str(), "wb");
@ -762,7 +767,9 @@ bool p3Config::backedUpFileSave(const std::string& cfg_fname, const std::string&
#endif
}
fwrite(buff, 1, size_file, cfg_file);
if(size_file != fwrite(buff, 1, size_file, cfg_file))
getPqiNotify()->AddSysMessage(0, RS_SYS_WARNING, "Write error", "Error while writing backup configuration file " + cfg_fname_backup + "\nIs your disc full or out of quota ?");
fclose(cfg_file);
#ifdef CONFIG_DEBUG

View File

@ -3474,7 +3474,7 @@ void peerConnectState::updateIpAddressList(const IpAddressTimed& ipTimed)
return ;
}
if(ipTimed.ipAddr.sin_addr.s_addr == 0 || ipTimed.ipAddr.sin_port == 0)
if(ipTimed.ipAddr.sin_addr.s_addr == 0 || ipTimed.ipAddr.sin_addr.s_addr == 1 || ipTimed.ipAddr.sin_port == 0)
{
#ifdef CONN_DEBUG
std::cerr << "peerConnectState::updateIpAdressList() ip parameter is 0.0.0.0, or port is 0, ignoring." << std::endl;

View File

@ -331,6 +331,10 @@ int pqistore::readPkt(RsItem **item_out)
// workout how much more to read.
int extralen = getRsItemSize(block) - blen;
if(extralen+blen > maxlen)
std::cerr << "***** ERROR: trying to read a packet of length " << extralen+blen << ", while the maximum length is " << maxlen << std::endl ;
if (extralen > 0)
{
if(extralen > blen + maxlen)