From 10565a1fe75660b86c92eebd45baf65585606b87 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 17 Jun 2010 17:55:58 +0000 Subject: [PATCH] ported trunk commit 3153: put generic turtle packets into data queue in pqistreamer git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5.0@3155 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/pqistreamer.cc | 13 ++++++++++++- libretroshare/src/serialiser/rsserial.h | 10 +++++++++- libretroshare/src/services/p3service.cc | 1 + libretroshare/src/turtle/rsturtleitem.h | 3 +++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/pqi/pqistreamer.cc b/libretroshare/src/pqi/pqistreamer.cc index 10de51993..9210d053f 100644 --- a/libretroshare/src/pqi/pqistreamer.cc +++ b/libretroshare/src/pqi/pqistreamer.cc @@ -31,6 +31,7 @@ #include "pqi/pqistreamer.h" #include "pqi/pqinotify.h" +#include "turtle/rsturtleitem.h" #include "serialiser/rsserial.h" #include "serialiser/rsbaseitems.h" /***** For RsFileData *****/ @@ -321,12 +322,22 @@ int pqistreamer::queue_outpqi(RsItem *pqi) } /* decide which type of packet it is */ - RsFileData *dta = dynamic_cast(pqi); + RsFileData *dta = dynamic_cast(pqi); // This is the old test method bool isCntrl = (dta == NULL); + if(pqi->queueType() == RsItem::DATA_QUEUE) // this is the new test method. More general. + { +#ifdef DEBUG_PQISTREAMER + std::cerr << "PQISTREAMER:: got a data queue packet !!" << std::endl ; +#endif + isCntrl = false ; + } + uint32_t pktsize = rsSerialiser->size(pqi); void *ptr = malloc(pktsize); + if(dynamic_cast(pqi)!=NULL) + std::cerr << "pqistreamer: handlign a turtle item" << std::endl; #ifdef DEBUG_PQISTREAMER std::cerr << "pqistreamer::queue_outpqi() serializing packet with packet size : " << pktsize << std::endl; #endif diff --git a/libretroshare/src/serialiser/rsserial.h b/libretroshare/src/serialiser/rsserial.h index cf0e15f89..cb0fe2881 100644 --- a/libretroshare/src/serialiser/rsserial.h +++ b/libretroshare/src/serialiser/rsserial.h @@ -92,6 +92,9 @@ uint8_t PacketSubType(); RsItem(uint8_t ver, uint16_t service, uint8_t subtype); uint16_t PacketService(); /* combined Packet class/type (mid 16bits) */ +typedef enum { CONTROL_QUEUE, DATA_QUEUE } QueueType ; +virtual QueueType queueType() const { return CONTROL_QUEUE ; } + private: uint32_t type; std::string peerId; @@ -164,7 +167,8 @@ class RsRawItem: public RsItem { public: RsRawItem(uint32_t t, uint32_t size) - :RsItem(t), len(size) { data = malloc(len);} + :RsItem(t), len(size), _queue_type(RsItem::CONTROL_QUEUE) + { data = malloc(len);} virtual ~RsRawItem() { @@ -180,9 +184,13 @@ void * getRawData() { return data; } virtual void clear() { return; } /* what can it do? */ virtual std::ostream &print(std::ostream &out, uint16_t indent = 0); +virtual RsItem::QueueType queueType() const { return _queue_type ;} +void setQueueType(const RsItem::QueueType& t) { _queue_type = t ;} + private: void *data; uint32_t len; + RsItem::QueueType _queue_type ; }; diff --git a/libretroshare/src/services/p3service.cc b/libretroshare/src/services/p3service.cc index d78851d36..6097c325c 100644 --- a/libretroshare/src/services/p3service.cc +++ b/libretroshare/src/services/p3service.cc @@ -198,6 +198,7 @@ RsRawItem *p3Service::send() if (raw) { raw->PeerId(si->PeerId()); + raw->setQueueType(si->queueType()) ; } /* cleanup */ diff --git a/libretroshare/src/turtle/rsturtleitem.h b/libretroshare/src/turtle/rsturtleitem.h index 63623b228..d55532954 100644 --- a/libretroshare/src/turtle/rsturtleitem.h +++ b/libretroshare/src/turtle/rsturtleitem.h @@ -174,6 +174,9 @@ class RsTurtleGenericTunnelItem: public RsTurtleItem /// requests are server packets, whereas file data are client packets. virtual Direction travelingDirection() const = 0 ; + + /// Generic tunnel items (such as file data) are added into the data queue + virtual RsItem::QueueType queueType() const { return RsItem::DATA_QUEUE ; } }; /***********************************************************************************/