added test to prevent using twice the same config file; changed duplicate config file name causing deserialisation errors and loss of some config files; added printout of hex code for RsItems that fail deserialisation

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8075 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-03-25 22:21:01 +00:00
parent cb6860a08d
commit ae0603a687
3 changed files with 19 additions and 5 deletions

View File

@ -175,7 +175,16 @@ void p3ConfigMgr::addConfiguration(std::string file, pqiConfig *conf)
std::cerr << "\tIgnoring new filename " << filename; std::cerr << "\tIgnoring new filename " << filename;
std::cerr << std::endl; std::cerr << std::endl;
return; return;
} }
// also check that the filename is not already registered for another config
for(std::list<pqiConfig*>::const_iterator it = mConfigs.begin();it!= mConfigs.end();++it)
if( (*it)->filename == filename )
{
std::cerr << "!!!!!!!!!!! Trying to register a config for file \"" << filename << "\" that is already registered" << std::endl;
std::cerr << "!!!!!!!!!!! Please correct the code !" << std::endl;
return ;
}
conf->setFilename(filename); conf->setFilename(filename);
mConfigs.push_back(conf); mConfigs.push_back(conf);

View File

@ -1592,7 +1592,7 @@ int RsServer::StartupRetroShare()
#ifdef ENABLE_GROUTER #ifdef ENABLE_GROUTER
mConfigMgr->addConfiguration("grouter.cfg", gr); mConfigMgr->addConfiguration("grouter.cfg", gr);
#endif #endif
mConfigMgr->addConfiguration("identity.cfg", mGxsIdService); mConfigMgr->addConfiguration("p3identity.cfg", mGxsIdService);
#ifdef RS_USE_BITDHT #ifdef RS_USE_BITDHT
mConfigMgr->addConfiguration("bitdht.cfg", mBitDht); mConfigMgr->addConfiguration("bitdht.cfg", mBitDht);

View File

@ -28,6 +28,7 @@
#include "serialiser/rsserial.h" #include "serialiser/rsserial.h"
#include "util/rsthreads.h" #include "util/rsthreads.h"
#include "util/rsstring.h" #include "util/rsstring.h"
#include "util/rsprint.h"
#include <math.h> #include <math.h>
#include <map> #include <map>
@ -424,7 +425,9 @@ RsItem * RsSerialiser::deserialise(void *data, uint32_t *size)
std::cerr << "RsSerialiser::deserialise() ERROR Failed!"; std::cerr << "RsSerialiser::deserialise() ERROR Failed!";
std::cerr << std::endl; std::cerr << std::endl;
std::cerr << "RsSerialiser::deserialise() pkt_size: " << pkt_size << " vs *size: " << *size; std::cerr << "RsSerialiser::deserialise() pkt_size: " << pkt_size << " vs *size: " << *size;
std::cerr << std::endl; std::cerr << std::endl;
RsItem *item2 = (it->second)->deserialise(data, &pkt_size);
uint32_t failedtype = getRsItemId(data); uint32_t failedtype = getRsItemId(data);
std::cerr << "RsSerialiser::deserialise() FAILED PACKET Size: "; std::cerr << "RsSerialiser::deserialise() FAILED PACKET Size: ";
@ -435,7 +438,8 @@ RsItem * RsSerialiser::deserialise(void *data, uint32_t *size)
std::cerr << " Class: " << std::hex << (uint32_t) getRsItemClass(failedtype) << std::dec; std::cerr << " Class: " << std::hex << (uint32_t) getRsItemClass(failedtype) << std::dec;
std::cerr << " Type: " << std::hex << (uint32_t) getRsItemType(failedtype) << std::dec; std::cerr << " Type: " << std::hex << (uint32_t) getRsItemType(failedtype) << std::dec;
std::cerr << " SubType: " << std::hex << (uint32_t) getRsItemSubType(failedtype) << std::dec; std::cerr << " SubType: " << std::hex << (uint32_t) getRsItemSubType(failedtype) << std::dec;
std::cerr << std::endl; std::cerr << " Data: " << RsUtil::BinToHex((char*)data,pkt_size) << std::endl;
std::cerr << std::endl;
#endif #endif
return NULL; return NULL;
} }
@ -456,7 +460,8 @@ RsItem * RsSerialiser::deserialise(void *data, uint32_t *size)
std::cerr << " Version: " << std::hex << (uint32_t) getRsItemVersion(failedtype) << std::dec; std::cerr << " Version: " << std::hex << (uint32_t) getRsItemVersion(failedtype) << std::dec;
std::cerr << " Class: " << std::hex << (uint32_t) getRsItemClass(failedtype) << std::dec; std::cerr << " Class: " << std::hex << (uint32_t) getRsItemClass(failedtype) << std::dec;
std::cerr << " Type: " << std::hex << (uint32_t) getRsItemType(failedtype) << std::dec; std::cerr << " Type: " << std::hex << (uint32_t) getRsItemType(failedtype) << std::dec;
std::cerr << " SubType: " << std::hex << (uint32_t) getRsItemSubType(failedtype) << std::dec; std::cerr << " SubType: " << std::hex << (uint32_t) getRsItemSubType(failedtype) << std::dec;
std::cerr << " Data: " << RsUtil::BinToHex((char*)data,pkt_size) << std::endl;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
} }