mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-18 04:14:28 -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());
|
pqioutput(PQL_ALERT, pqissllistenzone, out.str());
|
||||||
std::cerr << out.str() << std::endl;
|
std::cerr << out.str() << std::endl;
|
||||||
|
|
||||||
return -1;
|
exit(1) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -305,11 +305,10 @@ uint32_t RsDiscSerialiser::sizeReply(RsDiscReply *item)
|
|||||||
s += GetTlvStringSize(item->aboutId);
|
s += GetTlvStringSize(item->aboutId);
|
||||||
s += GetTlvStringSize(item->certGPG);
|
s += GetTlvStringSize(item->certGPG);
|
||||||
|
|
||||||
RsPeerConfigSerialiser *rss = new RsPeerConfigSerialiser();
|
RsPeerConfigSerialiser rss ;
|
||||||
for (std::list<RsPeerNetItem>::iterator it = item->rsPeerList.begin(); it != item->rsPeerList.end(); it++){
|
|
||||||
RsPeerNetItem pitem = *it;
|
for (std::list<RsPeerNetItem>::iterator it = item->rsPeerList.begin(); it != item->rsPeerList.end(); it++)
|
||||||
s += rss->size(&pitem);
|
s += rss.size(&(*it)) ;
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
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);
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_CERT_GPG, item->certGPG);
|
||||||
|
|
||||||
//store the ip list
|
//store the ip list
|
||||||
RsPeerConfigSerialiser *rss = new RsPeerConfigSerialiser();
|
RsPeerConfigSerialiser rss ;
|
||||||
std::list<RsPeerNetItem>::iterator pitemIt;
|
std::list<RsPeerNetItem>::iterator pitemIt;
|
||||||
for (pitemIt = item->rsPeerList.begin(); pitemIt!=(item->rsPeerList.end()); pitemIt++) {
|
|
||||||
void *pitemData = malloc(16000);
|
for (pitemIt = item->rsPeerList.begin(); pitemIt!=(item->rsPeerList.end()) && ok; ++pitemIt)
|
||||||
uint32_t size = 16000;
|
{
|
||||||
RsPeerNetItem pitem = *pitemIt;
|
uint32_t size = 0;
|
||||||
ok &= rss->serialise(&pitem, pitemData, &size);
|
ok &= rss.serialise(&(*pitemIt), (void *) (((char *) data) + offset), &size);
|
||||||
memcpy((void *) (((char *) data) + offset), pitemData, size);
|
|
||||||
free(pitemData);
|
|
||||||
offset += size;
|
offset += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset != tlvsize) {
|
if (offset != tlvsize)
|
||||||
|
{
|
||||||
ok = false;
|
ok = false;
|
||||||
#ifdef RSSERIAL_DEBUG
|
#ifdef RSSERIAL_DEBUG
|
||||||
std::cerr << "RsDiscSerialiser::serialiseReply() Size Error! " << std::endl;
|
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);
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_CERT_GPG, item->certGPG);
|
||||||
|
|
||||||
//get the peernet address list
|
//get the peernet address list
|
||||||
RsPeerConfigSerialiser *rss = new RsPeerConfigSerialiser();
|
RsPeerConfigSerialiser rss ;
|
||||||
std::list<RsPeerNetItem> rsPeerNetItemList;
|
|
||||||
while (offset < rssize) {
|
while (offset < rssize)
|
||||||
void *peerNetdata = malloc(16000);
|
{
|
||||||
uint32_t peerNetSize = (*pktsize) - offset;
|
uint32_t peerNetSize = rssize - offset ;
|
||||||
memcpy(peerNetdata, (void *) (((char *) data) + offset), peerNetSize);
|
|
||||||
RsPeerNetItem *rsPeerNetItem = (RsPeerNetItem*)rss->deserialise(peerNetdata, &peerNetSize);
|
RsPeerNetItem *rsPeerNetItem = (RsPeerNetItem*)rss.deserialise((void *) (((char *) data) + offset), &peerNetSize);
|
||||||
offset += peerNetSize;
|
offset += peerNetSize;
|
||||||
|
|
||||||
if(rsPeerNetItem != NULL)
|
if(rsPeerNetItem == NULL)
|
||||||
|
break ;
|
||||||
|
|
||||||
item->rsPeerList.push_back(*rsPeerNetItem);
|
item->rsPeerList.push_back(*rsPeerNetItem);
|
||||||
|
delete rsPeerNetItem ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset != rssize) {
|
if (offset != rssize)
|
||||||
|
{
|
||||||
#ifdef RSSERIAL_DEBUG
|
#ifdef RSSERIAL_DEBUG
|
||||||
std::cerr << "RsDiscSerialiser::deserialiseReply() offset != rssize" << std::endl;
|
std::cerr << "RsDiscSerialiser::deserialiseReply() offset != rssize" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -430,7 +432,8 @@ RsDiscReply *RsDiscSerialiser::deserialiseReply(void *data, uint32_t *pktsize)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok)
|
||||||
|
{
|
||||||
#ifdef RSSERIAL_DEBUG
|
#ifdef RSSERIAL_DEBUG
|
||||||
std::cerr << "RsDiscSerialiser::deserialiseReply() ok = false" << std::endl;
|
std::cerr << "RsDiscSerialiser::deserialiseReply() ok = false" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user