mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-06 21:58:57 -04:00
added packet packing in pqistreamer. To be tested for improvement in bw
This commit is contained in:
parent
893f178ce1
commit
f6a84aa4ad
1 changed files with 97 additions and 74 deletions
|
@ -447,6 +447,7 @@ int pqistreamer::handleoutgoing_locked()
|
|||
// a very simple round robin
|
||||
|
||||
bool sent = true;
|
||||
int nsent = 0 ;
|
||||
while(sent) // catch if all items sent.
|
||||
{
|
||||
sent = false;
|
||||
|
@ -470,17 +471,36 @@ int pqistreamer::handleoutgoing_locked()
|
|||
outSentBytes_locked(sentbytes);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define GROUP_OUTGOING_PACKETS 1
|
||||
// send a out_pkt., else send out_data. unless
|
||||
// there is a pending packet.
|
||||
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() ;
|
||||
|
||||
len = getRsItemSize(mPkt_wpending);
|
||||
}
|
||||
#endif
|
||||
if (mPkt_wpending)
|
||||
{
|
||||
// write packet.
|
||||
len = getRsItemSize(mPkt_wpending);
|
||||
|
||||
#ifdef DEBUG_PQISTREAMER
|
||||
std::cout << "Sending Out Pkt of size " << len << " !" << std::endl;
|
||||
#endif
|
||||
|
@ -499,6 +519,7 @@ int pqistreamer::handleoutgoing_locked()
|
|||
// ensuring exactly the same data is written (openSSL requirement).
|
||||
return -1;
|
||||
}
|
||||
++nsent;
|
||||
|
||||
#ifdef DEBUG_TRANSFERS
|
||||
std::cerr << "pqistreamer::handleoutgoing_locked() Sent Packet len: " << len << " @ " << RsUtil::AccurateTimeString();
|
||||
|
@ -512,6 +533,8 @@ int pqistreamer::handleoutgoing_locked()
|
|||
sent = true;
|
||||
}
|
||||
}
|
||||
if(nsent > 0)
|
||||
std::cerr << "nsent = " << nsent << ", total bytes=" << sentbytes << std::endl;
|
||||
outSentBytes_locked(sentbytes);
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue