mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-21 20:38:50 -04:00
Made pqiperson more readable evidence some strange code
This commit is contained in:
parent
874f304cd2
commit
b2c27a1fed
2 changed files with 274 additions and 303 deletions
|
@ -83,22 +83,20 @@ protected:
|
|||
|
||||
class pqipersongrp;
|
||||
|
||||
|
||||
class NotifyData
|
||||
{
|
||||
public:
|
||||
NotifyData()
|
||||
:mNi(NULL), mState(0)
|
||||
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; }
|
||||
NotifyData(NetInterface *ni, int state, const sockaddr_storage &addr) :
|
||||
mNi(ni), mState(state), mAddr(addr) {}
|
||||
|
||||
NetInterface *mNi;
|
||||
int mState;
|
||||
struct sockaddr_storage mAddr;
|
||||
sockaddr_storage mAddr;
|
||||
};
|
||||
|
||||
|
||||
|
@ -106,82 +104,76 @@ class pqiperson: public PQInterface
|
|||
{
|
||||
public:
|
||||
pqiperson(const RsPeerId& id, pqipersongrp *ppg);
|
||||
virtual ~pqiperson(); // must clean up children.
|
||||
virtual ~pqiperson(); // must clean up children.
|
||||
|
||||
// control of the connection.
|
||||
int reset();
|
||||
int listen();
|
||||
int stoplistening();
|
||||
int reset();
|
||||
int listen();
|
||||
int stoplistening();
|
||||
|
||||
int connect(uint32_t type, const struct sockaddr_storage &raddr,
|
||||
const struct sockaddr_storage &proxyaddr, const struct sockaddr_storage &srcaddr,
|
||||
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 connect(uint32_t type, const sockaddr_storage &raddr,
|
||||
const sockaddr_storage &proxyaddr, const sockaddr_storage &srcaddr,
|
||||
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 fullstopthreads();
|
||||
int receiveHeartbeat();
|
||||
|
||||
int receiveHeartbeat();
|
||||
// add in connection method.
|
||||
int addChildInterface(uint32_t type, pqiconnect *pqi);
|
||||
int addChildInterface(uint32_t type, pqiconnect *pqi);
|
||||
|
||||
virtual bool getCryptoParams(RsPeerCryptoParams&) ;
|
||||
virtual bool getCryptoParams(RsPeerCryptoParams&);
|
||||
|
||||
// The PQInterface interface.
|
||||
virtual int SendItem(RsItem *,uint32_t& serialized_size);
|
||||
virtual int SendItem(RsItem *item)
|
||||
{
|
||||
std::cerr << "Warning pqiperson::sendItem(RsItem*) should not be called. Plz call SendItem(RsItem *,uint32_t& serialized_size) instead." << std::endl;
|
||||
uint32_t serialized_size ;
|
||||
return SendItem(item,serialized_size) ;
|
||||
}
|
||||
virtual RsItem *GetItem();
|
||||
virtual bool RecvItem(RsItem *item);
|
||||
virtual int SendItem(RsItem *,uint32_t& serialized_size);
|
||||
virtual int SendItem(RsItem *item)
|
||||
{
|
||||
std::cerr << "Warning pqiperson::sendItem(RsItem*) should not be called."
|
||||
<< "Plz call SendItem(RsItem *,uint32_t& serialized_size) instead."
|
||||
<< std::endl;
|
||||
uint32_t serialized_size;
|
||||
return SendItem(item, serialized_size);
|
||||
}
|
||||
|
||||
virtual RsItem *GetItem();
|
||||
virtual bool RecvItem(RsItem *item);
|
||||
|
||||
virtual int status();
|
||||
virtual int tick();
|
||||
virtual int status();
|
||||
virtual int tick();
|
||||
|
||||
// overloaded callback function for the child - notify of a change.
|
||||
virtual int notifyEvent(NetInterface *ni, int event, const struct sockaddr_storage &addr);
|
||||
// overloaded callback function for the child - notify of a change.
|
||||
virtual int notifyEvent(NetInterface *ni, int event, const struct sockaddr_storage &addr);
|
||||
|
||||
// PQInterface for rate control overloaded....
|
||||
virtual int getQueueSize(bool in);
|
||||
virtual void getRates(RsBwRates &rates);
|
||||
virtual float getRate(bool in);
|
||||
virtual void setMaxRate(bool in, float val);
|
||||
virtual void setRateCap(float val_in, float val_out);
|
||||
virtual int gatherStatistics(std::list<RSTrafficClue>& outqueue_lst,std::list<RSTrafficClue>& inqueue_lst) ;
|
||||
// PQInterface for rate control overloaded....
|
||||
virtual int getQueueSize(bool in);
|
||||
virtual void getRates(RsBwRates &rates);
|
||||
virtual float getRate(bool in);
|
||||
virtual void setMaxRate(bool in, float val);
|
||||
virtual void setRateCap(float val_in, float val_out);
|
||||
virtual int gatherStatistics(std::list<RSTrafficClue>& outqueue_lst,
|
||||
std::list<RSTrafficClue>& inqueue_lst);
|
||||
|
||||
private:
|
||||
void processNotifyEvents();
|
||||
int handleNotifyEvent_locked(NetInterface *ni, int event,
|
||||
const sockaddr_storage &addr);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void processNotifyEvents();
|
||||
int handleNotifyEvent_locked(NetInterface *ni, int event, const struct sockaddr_storage &addr);
|
||||
|
||||
RsMutex mNotifyMtx; /**** LOCKS Notify Queue ****/
|
||||
|
||||
RsMutex mNotifyMtx; // LOCKS Notify Queue
|
||||
std::list<NotifyData> mNotifyQueue;
|
||||
|
||||
RsMutex mPersonMtx; /**** LOCKS below ****/
|
||||
RsMutex mPersonMtx; // LOCKS below
|
||||
|
||||
int reset_locked();
|
||||
int reset_locked();
|
||||
|
||||
void setRateCap_locked(float val_in, float val_out);
|
||||
void setRateCap_locked(float val_in, float val_out);
|
||||
|
||||
std::map<uint32_t, pqiconnect *> kids;
|
||||
bool active;
|
||||
pqiconnect *activepqi;
|
||||
bool inConnectAttempt;
|
||||
int waittimes;
|
||||
time_t lastHeartbeatReceived;//use to track connection failure
|
||||
|
||||
private: /* Helper functions */
|
||||
|
||||
|
||||
time_t lastHeartbeatReceived; // use to track connection failure
|
||||
pqipersongrp *pqipg; /* parent for callback */
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue