mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added packet packing in pqistreamer. To be tested for improvement in bw
This commit is contained in:
parent
893f178ce1
commit
f6a84aa4ad
@ -447,6 +447,7 @@ int pqistreamer::handleoutgoing_locked()
|
|||||||
// a very simple round robin
|
// a very simple round robin
|
||||||
|
|
||||||
bool sent = true;
|
bool sent = true;
|
||||||
|
int nsent = 0 ;
|
||||||
while(sent) // catch if all items sent.
|
while(sent) // catch if all items sent.
|
||||||
{
|
{
|
||||||
sent = false;
|
sent = false;
|
||||||
@ -470,17 +471,36 @@ int pqistreamer::handleoutgoing_locked()
|
|||||||
outSentBytes_locked(sentbytes);
|
outSentBytes_locked(sentbytes);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#define GROUP_OUTGOING_PACKETS 1
|
||||||
// send a out_pkt., else send out_data. unless
|
// send a out_pkt., else send out_data. unless
|
||||||
// there is a pending packet.
|
// there is a pending packet.
|
||||||
if (!mPkt_wpending)
|
if (!mPkt_wpending)
|
||||||
|
#ifdef GROUP_OUTGOING_PACKETS
|
||||||
|
{
|
||||||
|
void *dta;
|
||||||
|
len = 0 ;
|
||||||
|
int k=0;
|
||||||
|
while(len < maxbytes && (dta = locked_pop_out_data())!=NULL )
|
||||||
|
{
|
||||||
|
uint32_t s = getRsItemSize(dta);
|
||||||
|
mPkt_wpending = realloc(mPkt_wpending,s+len) ;
|
||||||
|
memcpy(mPkt_wpending+len,dta,s) ;
|
||||||
|
free(dta);
|
||||||
|
len += s ;
|
||||||
|
++k ;
|
||||||
|
}
|
||||||
|
if(k > 1)
|
||||||
|
std::cerr << "Packed " << k << " packets into " << len << " bytes." << std::endl;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
{
|
||||||
mPkt_wpending = locked_pop_out_data() ;
|
mPkt_wpending = locked_pop_out_data() ;
|
||||||
|
len = getRsItemSize(mPkt_wpending);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (mPkt_wpending)
|
if (mPkt_wpending)
|
||||||
{
|
{
|
||||||
// write packet.
|
// write packet.
|
||||||
len = getRsItemSize(mPkt_wpending);
|
|
||||||
|
|
||||||
#ifdef DEBUG_PQISTREAMER
|
#ifdef DEBUG_PQISTREAMER
|
||||||
std::cout << "Sending Out Pkt of size " << len << " !" << std::endl;
|
std::cout << "Sending Out Pkt of size " << len << " !" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -499,6 +519,7 @@ int pqistreamer::handleoutgoing_locked()
|
|||||||
// ensuring exactly the same data is written (openSSL requirement).
|
// ensuring exactly the same data is written (openSSL requirement).
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
++nsent;
|
||||||
|
|
||||||
#ifdef DEBUG_TRANSFERS
|
#ifdef DEBUG_TRANSFERS
|
||||||
std::cerr << "pqistreamer::handleoutgoing_locked() Sent Packet len: " << len << " @ " << RsUtil::AccurateTimeString();
|
std::cerr << "pqistreamer::handleoutgoing_locked() Sent Packet len: " << len << " @ " << RsUtil::AccurateTimeString();
|
||||||
@ -512,6 +533,8 @@ int pqistreamer::handleoutgoing_locked()
|
|||||||
sent = true;
|
sent = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(nsent > 0)
|
||||||
|
std::cerr << "nsent = " << nsent << ", total bytes=" << sentbytes << std::endl;
|
||||||
outSentBytes_locked(sentbytes);
|
outSentBytes_locked(sentbytes);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user