diff --git a/libretroshare/src/services/p3disc.cc b/libretroshare/src/services/p3disc.cc index a2d84da5d..366ea7ac0 100644 --- a/libretroshare/src/services/p3disc.cc +++ b/libretroshare/src/services/p3disc.cc @@ -168,20 +168,23 @@ int p3disc::handleIncoming() // if discovery reply then respond if haven't already. if (NULL != (dri = dynamic_cast (item))) { - recvPeerDetails(dri); - nhandled++; + // add item to list for later process + discReplyList.push_back(dri); // no delete } else if (NULL != (dvi = dynamic_cast (item))) { recvPeerVersionMsg(dvi); nhandled++; + delete item; } else if (NULL != (inf = dynamic_cast (item))) /* Ping */ { recvAskInfo(inf); nhandled++; + delete item; } else if (NULL != (dta = dynamic_cast (item))) { recvHeartbeatMsg(dta); nhandled++ ; + delete item; } else { @@ -190,9 +193,18 @@ int p3disc::handleIncoming() item -> print(std::cerr); std::cerr << std::endl; #endif + delete item; } - - delete item; + } + + // process one disc item + if (!discReplyList.empty()) { + std::cerr << "p3disc::handleIncoming() Count of disc items " << discReplyList.size() << std::endl; + RsDiscReply *dri = discReplyList.front(); + discReplyList.pop_front(); + recvPeerDetails(dri); + nhandled++; + delete dri; } #ifdef P3DISC_DEBUG diff --git a/libretroshare/src/services/p3disc.h b/libretroshare/src/services/p3disc.h index bc82954bc..032cad06c 100644 --- a/libretroshare/src/services/p3disc.h +++ b/libretroshare/src/services/p3disc.h @@ -145,6 +145,8 @@ int idServers(); std::map neighbours; std::map versions; + + std::list discReplyList; };