Added a thread per active peer - to reduce RTT and increase throughout.

* Added pqithreadstreamer, tweaked pqistreamer to support derivation.
 * Shifted RTT from p3Service to p3FastService.
 * Disabled lots of debug.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-initdev@6787 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2013-10-02 03:21:04 +00:00
parent a7dd9ad9e3
commit b587301b5a
22 changed files with 658 additions and 1414 deletions

View file

@ -30,6 +30,7 @@
#include "pqi/pqi.h"
#include "util/rsnet.h"
#include <list>
@ -44,12 +45,13 @@ static const int CONNECT_FAILED = 5;
static const int HEARTBEAT_REPEAT_TIME = 5;
#include "pqi/pqiqosstreamer.h"
#include "pqi/pqithreadstreamer.h"
class pqiconnect: public pqiQoSstreamer, public NetInterface
{
public:
pqiconnect(RsSerialiser *rss, NetBinInterface *ni_in)
:pqiQoSstreamer(rss, ni_in->PeerId(), ni_in, 0), // pqistreamer will cleanup NetInterface.
pqiconnect(PQInterface *parent, RsSerialiser *rss, NetBinInterface *ni_in)
:pqiQoSstreamer(parent, rss, ni_in->PeerId(), ni_in, 0), // pqistreamer will cleanup NetInterface.
NetInterface(NULL, ni_in->PeerId()), // No need for callback
ni(ni_in)
{
@ -75,7 +77,6 @@ virtual bool connect_parameter(uint32_t type, std::string value) { return ni ->
virtual bool connect_additional_address(uint32_t type, const struct sockaddr_storage &addr) { return ni -> connect_additional_address(type, addr);}
virtual int getConnectAddress(struct sockaddr_storage &raddr){ return ni->getConnectAddress(raddr); }
// get the contact from the net side!
@ -101,6 +102,25 @@ protected:
class pqipersongrp;
class NotifyData
{
public:
NotifyData()
:mNi(NULL), mState(0)
{
sockaddr_storage_clear(mAddr);
}
NotifyData(NetInterface *ni, int state, const struct sockaddr_storage &addr)
:mNi(ni), mState(state), mAddr(addr) { return; }
NetInterface *mNi;
int mState;
struct sockaddr_storage mAddr;
};
class pqiperson: public PQInterface
{
public:
@ -117,6 +137,8 @@ int connect(uint32_t type, const struct sockaddr_storage &raddr,
uint32_t delay, uint32_t period, uint32_t timeout, uint32_t flags, uint32_t bandwidth,
const std::string &domain_addr, uint16_t domain_port);
int fullstopthreads();
int receiveHeartbeat();
// add in connection method.
int addChildInterface(uint32_t type, pqiconnect *pqi);
@ -130,6 +152,7 @@ virtual int SendItem(RsItem *item)
return SendItem(item,serialized_size) ;
}
virtual RsItem *GetItem();
virtual bool RecvItem(RsItem *item);
virtual int status();
virtual int tick();
@ -144,10 +167,20 @@ virtual float getRate(bool in);
virtual void setMaxRate(bool in, float val);
virtual void setRateCap(float val_in, float val_out);
pqiconnect *getKid(uint32_t type);
private:
void processNotifyEvents();
int handleNotifyEvent_locked(NetInterface *ni, int event, const struct sockaddr_storage &addr);
RsMutex mNotifyMtx; /**** LOCKS Notify Queue ****/
std::list<NotifyData> mNotifyQueue;
RsMutex mPersonMtx; /**** LOCKS below ****/
void setRateCap_locked(float val_in, float val_out);
std::map<uint32_t, pqiconnect *> kids;
bool active;
pqiconnect *activepqi;