From aec8b4d27cecb10887c5d5de5d0d520605064b54 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 2 May 2016 18:10:39 -0400 Subject: [PATCH] fixed bug in counting of incoming data size for sliced packets --- libretroshare/src/pqi/pqistreamer.cc | 8 ++++++-- libretroshare/src/pqi/pqistreamer.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/pqi/pqistreamer.cc b/libretroshare/src/pqi/pqistreamer.cc index acbaffcb7..3cfa64de5 100644 --- a/libretroshare/src/pqi/pqistreamer.cc +++ b/libretroshare/src/pqi/pqistreamer.cc @@ -925,7 +925,10 @@ continue_packet: #ifdef DEBUG_PACKET_SLICING std::cerr << "Inputing partial packet " << RsUtil::BinToHex((char*)block,8) << std::endl; #endif - pkt = addPartialPacket(block,pktlen,slice_packet_id,is_packet_starting,is_packet_ending) ; + uint32_t packet_length = 0 ; + pkt = addPartialPacket(block,pktlen,slice_packet_id,is_packet_starting,is_packet_ending,packet_length) ; + + pktlen = packet_length ; } else pkt = mRsSerialiser->deserialise(block, &pktlen); @@ -968,7 +971,7 @@ continue_packet: return 0; } -RsItem *pqistreamer::addPartialPacket(const void *block,uint32_t len,uint32_t slice_packet_id,bool is_packet_starting,bool is_packet_ending) +RsItem *pqistreamer::addPartialPacket(const void *block, uint32_t len, uint32_t slice_packet_id, bool is_packet_starting, bool is_packet_ending, uint32_t &total_len) { #ifdef DEBUG_PACKET_SLICING std::cerr << "Receiving partial packet. size=" << len << ", ID=" << std::hex << slice_packet_id << std::dec << ", starting:" << is_packet_starting << ", ending:" << is_packet_ending ; @@ -1040,6 +1043,7 @@ RsItem *pqistreamer::addPartialPacket(const void *block,uint32_t len,uint32_t sl #endif RsItem *item = mRsSerialiser->deserialise(rec.mem, &rec.size); + total_len = rec.size ; free(rec.mem) ; mPartialPackets.erase(it) ; return item ; diff --git a/libretroshare/src/pqi/pqistreamer.h b/libretroshare/src/pqi/pqistreamer.h index b50244622..ae94c9c1a 100644 --- a/libretroshare/src/pqi/pqistreamer.h +++ b/libretroshare/src/pqi/pqistreamer.h @@ -164,7 +164,7 @@ class pqistreamer: public PQInterface bool mAcceptsPacketSlicing ; time_t mLastSentPacketSlicingProbe ; void locked_addTrafficClue(const RsItem *pqi, uint32_t pktsize, std::list &lst); - RsItem *addPartialPacket(const void *block, uint32_t len, uint32_t slice_packet_id,bool packet_starting,bool packet_ending); + RsItem *addPartialPacket(const void *block, uint32_t len, uint32_t slice_packet_id,bool packet_starting,bool packet_ending,uint32_t& total_len); std::map mPartialPackets ; };