mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-17 20:04:22 -05:00
Ported branch commits:
2951: cleaned up some desastrous code in rsdiscitems.cc 2952: put back an exit when the local address+port are already in use. Otherwise this corrupts file lists, config files etc. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2953 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8673924374
commit
4b9b15be27
@ -213,7 +213,7 @@ int pqissllistenbase::setuplisten()
|
||||
pqioutput(PQL_ALERT, pqissllistenzone, out.str());
|
||||
std::cerr << out.str() << std::endl;
|
||||
|
||||
return -1;
|
||||
exit(1) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -305,11 +305,10 @@ uint32_t RsDiscSerialiser::sizeReply(RsDiscReply *item)
|
||||
s += GetTlvStringSize(item->aboutId);
|
||||
s += GetTlvStringSize(item->certGPG);
|
||||
|
||||
RsPeerConfigSerialiser *rss = new RsPeerConfigSerialiser();
|
||||
for (std::list<RsPeerNetItem>::iterator it = item->rsPeerList.begin(); it != item->rsPeerList.end(); it++){
|
||||
RsPeerNetItem pitem = *it;
|
||||
s += rss->size(&pitem);
|
||||
}
|
||||
RsPeerConfigSerialiser rss ;
|
||||
|
||||
for (std::list<RsPeerNetItem>::iterator it = item->rsPeerList.begin(); it != item->rsPeerList.end(); it++)
|
||||
s += rss.size(&(*it)) ;
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -342,19 +341,18 @@ bool RsDiscSerialiser::serialiseReply(RsDiscReply *item, void *data, uint32_
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_CERT_GPG, item->certGPG);
|
||||
|
||||
//store the ip list
|
||||
RsPeerConfigSerialiser *rss = new RsPeerConfigSerialiser();
|
||||
RsPeerConfigSerialiser rss ;
|
||||
std::list<RsPeerNetItem>::iterator pitemIt;
|
||||
for (pitemIt = item->rsPeerList.begin(); pitemIt!=(item->rsPeerList.end()); pitemIt++) {
|
||||
void *pitemData = malloc(16000);
|
||||
uint32_t size = 16000;
|
||||
RsPeerNetItem pitem = *pitemIt;
|
||||
ok &= rss->serialise(&pitem, pitemData, &size);
|
||||
memcpy((void *) (((char *) data) + offset), pitemData, size);
|
||||
free(pitemData);
|
||||
|
||||
for (pitemIt = item->rsPeerList.begin(); pitemIt!=(item->rsPeerList.end()) && ok; ++pitemIt)
|
||||
{
|
||||
uint32_t size = 0;
|
||||
ok &= rss.serialise(&(*pitemIt), (void *) (((char *) data) + offset), &size);
|
||||
offset += size;
|
||||
}
|
||||
|
||||
if (offset != tlvsize) {
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsDiscSerialiser::serialiseReply() Size Error! " << std::endl;
|
||||
@ -408,20 +406,24 @@ RsDiscReply *RsDiscSerialiser::deserialiseReply(void *data, uint32_t *pktsize)
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_CERT_GPG, item->certGPG);
|
||||
|
||||
//get the peernet address list
|
||||
RsPeerConfigSerialiser *rss = new RsPeerConfigSerialiser();
|
||||
std::list<RsPeerNetItem> rsPeerNetItemList;
|
||||
while (offset < rssize) {
|
||||
void *peerNetdata = malloc(16000);
|
||||
uint32_t peerNetSize = (*pktsize) - offset;
|
||||
memcpy(peerNetdata, (void *) (((char *) data) + offset), peerNetSize);
|
||||
RsPeerNetItem *rsPeerNetItem = (RsPeerNetItem*)rss->deserialise(peerNetdata, &peerNetSize);
|
||||
RsPeerConfigSerialiser rss ;
|
||||
|
||||
while (offset < rssize)
|
||||
{
|
||||
uint32_t peerNetSize = rssize - offset ;
|
||||
|
||||
RsPeerNetItem *rsPeerNetItem = (RsPeerNetItem*)rss.deserialise((void *) (((char *) data) + offset), &peerNetSize);
|
||||
offset += peerNetSize;
|
||||
|
||||
if(rsPeerNetItem != NULL)
|
||||
if(rsPeerNetItem == NULL)
|
||||
break ;
|
||||
|
||||
item->rsPeerList.push_back(*rsPeerNetItem);
|
||||
delete rsPeerNetItem ;
|
||||
}
|
||||
|
||||
if (offset != rssize) {
|
||||
if (offset != rssize)
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsDiscSerialiser::deserialiseReply() offset != rssize" << std::endl;
|
||||
#endif
|
||||
@ -430,7 +432,8 @@ RsDiscReply *RsDiscSerialiser::deserialiseReply(void *data, uint32_t *pktsize)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
if (!ok)
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsDiscSerialiser::deserialiseReply() ok = false" << std::endl;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user