mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 07:59:35 -05:00
Modified (all I hope) remaining pqistream -> pqistore for cache file save/loads.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1223 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
99828dfa41
commit
02fc02d23c
@ -29,7 +29,6 @@
|
|||||||
#include "pqi/p3authmgr.h"
|
#include "pqi/p3authmgr.h"
|
||||||
#include "pqi/pqibin.h"
|
#include "pqi/pqibin.h"
|
||||||
#include "pqi/pqistore.h"
|
#include "pqi/pqistore.h"
|
||||||
#include "pqi/pqistreamer.h"
|
|
||||||
#include "pqi/pqinotify.h"
|
#include "pqi/pqinotify.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
@ -153,11 +152,9 @@ void p3ConfigMgr::saveConfiguration()
|
|||||||
BinMemInterface *membio = new BinMemInterface(1000, bioflags);
|
BinMemInterface *membio = new BinMemInterface(1000, bioflags);
|
||||||
RsSerialiser *rss = new RsSerialiser();
|
RsSerialiser *rss = new RsSerialiser();
|
||||||
rss->addSerialType(new RsGeneralConfigSerialiser());
|
rss->addSerialType(new RsGeneralConfigSerialiser());
|
||||||
pqistreamer stream(rss, "CONFIG", membio, 0);
|
pqistore store(rss, "CONFIG", membio, 0);
|
||||||
|
|
||||||
stream.SendItem(item);
|
store.SendItem(item);
|
||||||
stream.tick();
|
|
||||||
stream.tick();
|
|
||||||
|
|
||||||
/* sign data */
|
/* sign data */
|
||||||
std::string signature;
|
std::string signature;
|
||||||
@ -296,10 +293,8 @@ void p3ConfigMgr::loadConfiguration()
|
|||||||
membio->fseek(0); /* go to start */
|
membio->fseek(0); /* go to start */
|
||||||
RsSerialiser *rss = new RsSerialiser();
|
RsSerialiser *rss = new RsSerialiser();
|
||||||
rss->addSerialType(new RsGeneralConfigSerialiser());
|
rss->addSerialType(new RsGeneralConfigSerialiser());
|
||||||
pqistreamer stream(rss, "CONFIG", membio, 0);
|
pqistore stream(rss, "CONFIG", membio, 0);
|
||||||
|
|
||||||
stream.tick();
|
|
||||||
stream.tick();
|
|
||||||
RsItem *rsitem = stream.GetItem();
|
RsItem *rsitem = stream.GetItem();
|
||||||
|
|
||||||
RsConfigKeyValueSet *item = dynamic_cast<RsConfigKeyValueSet *>(rsitem);
|
RsConfigKeyValueSet *item = dynamic_cast<RsConfigKeyValueSet *>(rsitem);
|
||||||
@ -402,7 +397,7 @@ bool p3Config::loadConfiguration(std::string &loadHash)
|
|||||||
uint32_t stream_flags = BIN_FLAGS_READABLE;
|
uint32_t stream_flags = BIN_FLAGS_READABLE;
|
||||||
|
|
||||||
BinInterface *bio = new BinFileInterface(fname.c_str(), bioflags);
|
BinInterface *bio = new BinFileInterface(fname.c_str(), bioflags);
|
||||||
pqistore stream(setupSerialiser(), bio, stream_flags);
|
pqistore stream(setupSerialiser(), "CONFIG", bio, stream_flags);
|
||||||
RsItem *item = NULL;
|
RsItem *item = NULL;
|
||||||
|
|
||||||
while(NULL != (item = stream.GetItem()))
|
while(NULL != (item = stream.GetItem()))
|
||||||
@ -473,7 +468,7 @@ bool p3Config::saveConfiguration()
|
|||||||
stream_flags |= BIN_FLAGS_NO_DELETE;
|
stream_flags |= BIN_FLAGS_NO_DELETE;
|
||||||
|
|
||||||
BinInterface *bio = new BinFileInterface(fnametmp.c_str(), bioflags);
|
BinInterface *bio = new BinFileInterface(fnametmp.c_str(), bioflags);
|
||||||
pqistore *stream = new pqistore(setupSerialiser(), bio, stream_flags);
|
pqistore *stream = new pqistore(setupSerialiser(), "CONFIG", bio, stream_flags);
|
||||||
|
|
||||||
std::list<RsItem *>::iterator it;
|
std::list<RsItem *>::iterator it;
|
||||||
|
|
||||||
|
@ -50,9 +50,9 @@
|
|||||||
|
|
||||||
const int pqistorezone = 9511;
|
const int pqistorezone = 9511;
|
||||||
|
|
||||||
pqistore::pqistore(RsSerialiser *rss, BinInterface *bio_in, int bio_flags_in)
|
pqistore::pqistore(RsSerialiser *rss, std::string srcId, BinInterface *bio_in, int bio_flags_in)
|
||||||
:PQInterface(""), rsSerialiser(rss), bio(bio_in), bio_flags(bio_flags_in),
|
:PQInterface(""), rsSerialiser(rss), bio(bio_in), bio_flags(bio_flags_in),
|
||||||
nextPkt(NULL)
|
nextPkt(NULL), mSrcId(srcId)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
@ -363,6 +363,7 @@ int pqistore::readPkt(RsItem **item_out)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item->PeerId(mSrcId);
|
||||||
*item_out = item;
|
*item_out = item;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
class pqistore: public PQInterface
|
class pqistore: public PQInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
pqistore(RsSerialiser *rss, BinInterface *bio_in, int bio_flagsin);
|
pqistore(RsSerialiser *rss, std::string srcId, BinInterface *bio_in, int bio_flagsin);
|
||||||
virtual ~pqistore();
|
virtual ~pqistore();
|
||||||
|
|
||||||
// PQInterface
|
// PQInterface
|
||||||
@ -65,6 +65,7 @@ int readPkt(RsItem **item_out);
|
|||||||
|
|
||||||
// Temp Storage for transient data.....
|
// Temp Storage for transient data.....
|
||||||
RsItem *nextPkt;
|
RsItem *nextPkt;
|
||||||
|
std::string mSrcId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include "pqi/pqistore.h"
|
||||||
#include "pqi/pqibin.h"
|
#include "pqi/pqibin.h"
|
||||||
#include "pqi/p3authmgr.h"
|
#include "pqi/p3authmgr.h"
|
||||||
|
|
||||||
@ -142,7 +143,7 @@ bool p3Qblog::loadBlogFile(std::string filename, std::string src)
|
|||||||
|
|
||||||
uint32_t bioflags = BIN_FLAGS_HASH_DATA | BIN_FLAGS_READABLE;
|
uint32_t bioflags = BIN_FLAGS_HASH_DATA | BIN_FLAGS_READABLE;
|
||||||
BinInterface *bio = new BinFileInterface(filename.c_str(), bioflags);
|
BinInterface *bio = new BinFileInterface(filename.c_str(), bioflags);
|
||||||
pqistreamer *stream = new pqistreamer(rsSerialiser, src, bio, 0);
|
pqistore *store = new pqistore(rsSerialiser, src, bio, 0);
|
||||||
|
|
||||||
#ifdef QBLOG_DEBUG
|
#ifdef QBLOG_DEBUG
|
||||||
|
|
||||||
@ -159,8 +160,6 @@ bool p3Qblog::loadBlogFile(std::string filename, std::string src)
|
|||||||
RsItem *item;
|
RsItem *item;
|
||||||
RsQblogMsg *newBlog;
|
RsQblogMsg *newBlog;
|
||||||
|
|
||||||
stream->tick(); // tick to read
|
|
||||||
|
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
time_t min, max;
|
time_t min, max;
|
||||||
|
|
||||||
@ -170,7 +169,7 @@ bool p3Qblog::loadBlogFile(std::string filename, std::string src)
|
|||||||
max = now + BLOG_MAX_FWD_OFFSET;
|
max = now + BLOG_MAX_FWD_OFFSET;
|
||||||
} /********** STACK LOCKED MTX ******/
|
} /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
while(NULL != (item = stream->GetItem()))
|
while(NULL != (item = store->GetItem()))
|
||||||
{
|
{
|
||||||
#ifdef QBLOG_DEBUG
|
#ifdef QBLOG_DEBUG
|
||||||
std::cerr << "p3Qblog::loadBlogFile() Got Item:";
|
std::cerr << "p3Qblog::loadBlogFile() Got Item:";
|
||||||
@ -208,11 +207,9 @@ bool p3Qblog::loadBlogFile(std::string filename, std::string src)
|
|||||||
|
|
||||||
addBlog(newBlog); // add received blog to list
|
addBlog(newBlog); // add received blog to list
|
||||||
}
|
}
|
||||||
|
|
||||||
stream->tick(); // tick to read
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete stream; // stream finished with/return resource
|
delete store; // store finished with/return resource
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +270,7 @@ bool p3Qblog::postBlogs(void)
|
|||||||
|
|
||||||
uint32_t bioflags = BIN_FLAGS_HASH_DATA | BIN_FLAGS_WRITEABLE;
|
uint32_t bioflags = BIN_FLAGS_HASH_DATA | BIN_FLAGS_WRITEABLE;
|
||||||
BinInterface *bio = new BinFileInterface(fname.c_str(), bioflags);
|
BinInterface *bio = new BinFileInterface(fname.c_str(), bioflags);
|
||||||
pqistreamer *stream = new pqistreamer(rsSerialiser, mOwnId, bio,
|
pqistore *store = new pqistore(rsSerialiser, mOwnId, bio,
|
||||||
BIN_FLAGS_NO_DELETE);
|
BIN_FLAGS_NO_DELETE);
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -297,8 +294,7 @@ bool p3Qblog::postBlogs(void)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
stream->SendItem(item);
|
store->SendItem(item);
|
||||||
stream->tick(); /* tick to write */
|
|
||||||
}
|
}
|
||||||
else /* if blogs belong to a friend */
|
else /* if blogs belong to a friend */
|
||||||
{
|
{
|
||||||
@ -313,9 +309,6 @@ bool p3Qblog::postBlogs(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
stream->tick(); /* Tick for final write! */
|
|
||||||
|
|
||||||
/* flag as new info */
|
/* flag as new info */
|
||||||
CacheData data;
|
CacheData data;
|
||||||
|
|
||||||
@ -351,7 +344,7 @@ bool p3Qblog::postBlogs(void)
|
|||||||
refreshCache(data);
|
refreshCache(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete stream;
|
delete store;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,7 +429,7 @@ bool p3ChatService::loadConfiguration(std::string &loadHash)
|
|||||||
rss->addSerialType(new RsChatSerialiser());
|
rss->addSerialType(new RsChatSerialiser());
|
||||||
|
|
||||||
BinFileInterface *in = new BinFileInterface(msgfile.c_str(), BIN_FLAGS_READABLE | BIN_FLAGS_HASH_DATA);
|
BinFileInterface *in = new BinFileInterface(msgfile.c_str(), BIN_FLAGS_READABLE | BIN_FLAGS_HASH_DATA);
|
||||||
pqistore *pa_in = new pqistore(rss, in, BIN_FLAGS_READABLE);
|
pqistore *pa_in = new pqistore(rss, "CHATCONFIG", in, BIN_FLAGS_READABLE);
|
||||||
RsItem *item;
|
RsItem *item;
|
||||||
RsChatMsgItem *mitem;
|
RsChatMsgItem *mitem;
|
||||||
|
|
||||||
@ -481,7 +481,7 @@ bool p3ChatService::saveConfiguration()
|
|||||||
rss->addSerialType(new RsChatSerialiser());
|
rss->addSerialType(new RsChatSerialiser());
|
||||||
|
|
||||||
BinFileInterface *out = new BinFileInterface(msgfiletmp.c_str(), BIN_FLAGS_WRITEABLE | BIN_FLAGS_HASH_DATA);
|
BinFileInterface *out = new BinFileInterface(msgfiletmp.c_str(), BIN_FLAGS_WRITEABLE | BIN_FLAGS_HASH_DATA);
|
||||||
pqistore *pa_out = new pqistore(rss, out, BIN_FLAGS_WRITEABLE);
|
pqistore *pa_out = new pqistore(rss, "CHATCONFIG", out, BIN_FLAGS_WRITEABLE);
|
||||||
|
|
||||||
if(_own_avatar != NULL)
|
if(_own_avatar != NULL)
|
||||||
{
|
{
|
||||||
|
@ -202,7 +202,7 @@ void p3GroupDistrib::loadFileGroups(std::string filename, std::string src, bool
|
|||||||
|
|
||||||
/* create the serialiser to load info */
|
/* create the serialiser to load info */
|
||||||
BinInterface *bio = new BinFileInterface(filename.c_str(), BIN_FLAGS_READABLE);
|
BinInterface *bio = new BinFileInterface(filename.c_str(), BIN_FLAGS_READABLE);
|
||||||
pqistreamer *streamer = createStreamer(bio, src, 0);
|
pqistore *store = createStore(bio, src, 0);
|
||||||
|
|
||||||
std::cerr << "loading file " << filename << std::endl ;
|
std::cerr << "loading file " << filename << std::endl ;
|
||||||
|
|
||||||
@ -210,8 +210,7 @@ void p3GroupDistrib::loadFileGroups(std::string filename, std::string src, bool
|
|||||||
RsDistribGrp *newGrp;
|
RsDistribGrp *newGrp;
|
||||||
RsDistribGrpKey *newKey;
|
RsDistribGrpKey *newKey;
|
||||||
|
|
||||||
streamer->tick();
|
while(NULL != (item = store->GetItem()))
|
||||||
while(NULL != (item = streamer->GetItem()))
|
|
||||||
{
|
{
|
||||||
#ifdef DISTRIB_DEBUG
|
#ifdef DISTRIB_DEBUG
|
||||||
std::cerr << "p3GroupDistrib::loadFileGroups() Got Item:";
|
std::cerr << "p3GroupDistrib::loadFileGroups() Got Item:";
|
||||||
@ -237,11 +236,9 @@ void p3GroupDistrib::loadFileGroups(std::string filename, std::string src, bool
|
|||||||
#endif
|
#endif
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
streamer->tick();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete streamer;
|
delete store;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* clear publication of groups if local cache file found */
|
/* clear publication of groups if local cache file found */
|
||||||
@ -269,15 +266,14 @@ void p3GroupDistrib::loadFileMsgs(std::string filename, uint16_t cacheSubId, std
|
|||||||
|
|
||||||
/* create the serialiser to load msgs */
|
/* create the serialiser to load msgs */
|
||||||
BinInterface *bio = new BinFileInterface(filename.c_str(), BIN_FLAGS_READABLE);
|
BinInterface *bio = new BinFileInterface(filename.c_str(), BIN_FLAGS_READABLE);
|
||||||
pqistreamer *streamer = createStreamer(bio, src, 0);
|
pqistore *store = createStore(bio, src, 0);
|
||||||
|
|
||||||
std::cerr << "loading file " << filename << std::endl ;
|
std::cerr << "loading file " << filename << std::endl ;
|
||||||
|
|
||||||
RsItem *item;
|
RsItem *item;
|
||||||
RsDistribSignedMsg *newMsg;
|
RsDistribSignedMsg *newMsg;
|
||||||
|
|
||||||
streamer->tick();
|
while(NULL != (item = store->GetItem()))
|
||||||
while(NULL != (item = streamer->GetItem()))
|
|
||||||
{
|
{
|
||||||
#ifdef DISTRIB_DEBUG
|
#ifdef DISTRIB_DEBUG
|
||||||
std::cerr << "p3GroupDistrib::loadFileMsgs() Got Item:";
|
std::cerr << "p3GroupDistrib::loadFileMsgs() Got Item:";
|
||||||
@ -299,7 +295,6 @@ void p3GroupDistrib::loadFileMsgs(std::string filename, uint16_t cacheSubId, std
|
|||||||
/* wrong message type */
|
/* wrong message type */
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
streamer->tick();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -335,7 +330,7 @@ void p3GroupDistrib::loadFileMsgs(std::string filename, uint16_t cacheSubId, std
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete streamer;
|
delete store;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -750,7 +745,7 @@ void p3GroupDistrib::locked_publishPendingMsgs()
|
|||||||
std::string filenametmp = path + "/" + tmpname + ".tmp";
|
std::string filenametmp = path + "/" + tmpname + ".tmp";
|
||||||
|
|
||||||
BinInterface *bio = new BinFileInterface(filenametmp.c_str(), BIN_FLAGS_WRITEABLE | BIN_FLAGS_HASH_DATA);
|
BinInterface *bio = new BinFileInterface(filenametmp.c_str(), BIN_FLAGS_WRITEABLE | BIN_FLAGS_HASH_DATA);
|
||||||
pqistreamer *streamer = createStreamer(bio, mOwnId, 0); /* messages are deleted! */
|
pqistore *store = createStore(bio, mOwnId, 0); /* messages are deleted! */
|
||||||
|
|
||||||
bool resave = false;
|
bool resave = false;
|
||||||
std::list<RsDistribSignedMsg *>::iterator it;
|
std::list<RsDistribSignedMsg *>::iterator it;
|
||||||
@ -772,13 +767,10 @@ void p3GroupDistrib::locked_publishPendingMsgs()
|
|||||||
resave = true;
|
resave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
streamer->SendItem(*it); /* deletes it */
|
store->SendItem(*it); /* deletes it */
|
||||||
streamer->tick();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
streamer->tick(); /* once more for good luck! */
|
/* Extract File Information from pqistore */
|
||||||
|
|
||||||
/* Extract File Information from pqistreamer */
|
|
||||||
newCache.path = path;
|
newCache.path = path;
|
||||||
newCache.name = tmpname;
|
newCache.name = tmpname;
|
||||||
|
|
||||||
@ -788,7 +780,7 @@ void p3GroupDistrib::locked_publishPendingMsgs()
|
|||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
mPendingPublish.clear();
|
mPendingPublish.clear();
|
||||||
delete streamer;
|
delete store;
|
||||||
|
|
||||||
if(!RsDirUtil::renameFile(filenametmp,filename))
|
if(!RsDirUtil::renameFile(filenametmp,filename))
|
||||||
{
|
{
|
||||||
@ -843,7 +835,7 @@ void p3GroupDistrib::publishDistribGroups()
|
|||||||
std::string filenametmp = path + "/" + tmpname + ".tmp";
|
std::string filenametmp = path + "/" + tmpname + ".tmp";
|
||||||
|
|
||||||
BinInterface *bio = new BinFileInterface(filenametmp.c_str(), BIN_FLAGS_WRITEABLE | BIN_FLAGS_HASH_DATA);
|
BinInterface *bio = new BinFileInterface(filenametmp.c_str(), BIN_FLAGS_WRITEABLE | BIN_FLAGS_HASH_DATA);
|
||||||
pqistreamer *streamer = createStreamer(bio, mOwnId, BIN_FLAGS_NO_DELETE);
|
pqistore *store = createStore(bio, mOwnId, BIN_FLAGS_NO_DELETE);
|
||||||
|
|
||||||
RsStackMutex stack(distribMtx); /****** STACK MUTEX LOCKED *******/
|
RsStackMutex stack(distribMtx); /****** STACK MUTEX LOCKED *******/
|
||||||
|
|
||||||
@ -866,8 +858,7 @@ void p3GroupDistrib::publishDistribGroups()
|
|||||||
if (grp)
|
if (grp)
|
||||||
{
|
{
|
||||||
/* store in Cache File */
|
/* store in Cache File */
|
||||||
streamer->SendItem(grp); /* no delete */
|
store->SendItem(grp); /* no delete */
|
||||||
streamer->tick();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if they have public keys, publish these too */
|
/* if they have public keys, publish these too */
|
||||||
@ -896,8 +887,7 @@ void p3GroupDistrib::publishDistribGroups()
|
|||||||
pubKey->key.startTS = kit->second.startTS;
|
pubKey->key.startTS = kit->second.startTS;
|
||||||
pubKey->key.endTS = kit->second.endTS;
|
pubKey->key.endTS = kit->second.endTS;
|
||||||
|
|
||||||
streamer->SendItem(pubKey);
|
store->SendItem(pubKey);
|
||||||
streamer->tick();
|
|
||||||
delete pubKey;
|
delete pubKey;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -922,7 +912,7 @@ void p3GroupDistrib::publishDistribGroups()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extract File Information from pqistreamer */
|
/* Extract File Information from pqistore */
|
||||||
newCache.path = path;
|
newCache.path = path;
|
||||||
newCache.name = tmpname;
|
newCache.name = tmpname;
|
||||||
|
|
||||||
@ -931,7 +921,7 @@ void p3GroupDistrib::publishDistribGroups()
|
|||||||
newCache.recvd = time(NULL);
|
newCache.recvd = time(NULL);
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
delete streamer;
|
delete store;
|
||||||
|
|
||||||
if(!RsDirUtil::renameFile(filenametmp,filename))
|
if(!RsDirUtil::renameFile(filenametmp,filename))
|
||||||
{
|
{
|
||||||
@ -1381,15 +1371,15 @@ bool p3GroupDistrib::loadList(std::list<RsItem *> load)
|
|||||||
* As All the child packets are Packed, we should only need RsSerialDistrib() in it.
|
* As All the child packets are Packed, we should only need RsSerialDistrib() in it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pqistreamer *p3GroupDistrib::createStreamer(BinInterface *bio, std::string src, uint32_t bioflags)
|
pqistore *p3GroupDistrib::createStore(BinInterface *bio, std::string src, uint32_t bioflags)
|
||||||
{
|
{
|
||||||
RsSerialiser *rsSerialiser = new RsSerialiser();
|
RsSerialiser *rsSerialiser = new RsSerialiser();
|
||||||
RsSerialType *serialType = new RsDistribSerialiser();
|
RsSerialType *serialType = new RsDistribSerialiser();
|
||||||
rsSerialiser->addSerialType(serialType);
|
rsSerialiser->addSerialType(serialType);
|
||||||
|
|
||||||
pqistreamer *streamer = new pqistreamer(rsSerialiser, src, bio, bioflags);
|
pqistore *store = new pqistore(rsSerialiser, src, bio, bioflags);
|
||||||
|
|
||||||
return streamer;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#define P3_GENERIC_DISTRIB_HEADER
|
#define P3_GENERIC_DISTRIB_HEADER
|
||||||
|
|
||||||
#include "pqi/pqi.h"
|
#include "pqi/pqi.h"
|
||||||
#include "pqi/pqistreamer.h"
|
#include "pqi/pqistore.h"
|
||||||
#include "pqi/p3cfgmgr.h"
|
#include "pqi/p3cfgmgr.h"
|
||||||
#include "pqi/p3authmgr.h"
|
#include "pqi/p3authmgr.h"
|
||||||
#include "services/p3service.h"
|
#include "services/p3service.h"
|
||||||
@ -340,7 +340,7 @@ uint16_t locked_determineCacheSubId();
|
|||||||
virtual RsSerialType *createSerialiser() = 0;
|
virtual RsSerialType *createSerialiser() = 0;
|
||||||
|
|
||||||
/* Used to Create/Load Cache Files only */
|
/* Used to Create/Load Cache Files only */
|
||||||
virtual pqistreamer *createStreamer(BinInterface *bio, std::string src, uint32_t bioflags);
|
virtual pqistore *createStore(BinInterface *bio, std::string src, uint32_t bioflags);
|
||||||
|
|
||||||
virtual bool validateDistribGrp(RsDistribGrp *newGrp);
|
virtual bool validateDistribGrp(RsDistribGrp *newGrp);
|
||||||
virtual bool locked_checkGroupInfo(GroupInfo &info, RsDistribGrp *newGrp);
|
virtual bool locked_checkGroupInfo(GroupInfo &info, RsDistribGrp *newGrp);
|
||||||
|
@ -145,7 +145,7 @@ void p3Ranking::loadRankFile(std::string filename, std::string src)
|
|||||||
|
|
||||||
uint32_t bioflags = BIN_FLAGS_HASH_DATA | BIN_FLAGS_READABLE;
|
uint32_t bioflags = BIN_FLAGS_HASH_DATA | BIN_FLAGS_READABLE;
|
||||||
BinInterface *bio = new BinFileInterface(filename.c_str(), bioflags);
|
BinInterface *bio = new BinFileInterface(filename.c_str(), bioflags);
|
||||||
pqistreamer *stream = new pqistreamer(rsSerialiser, src, bio, 0);
|
pqistore *store = new pqistore(rsSerialiser, src, bio, 0);
|
||||||
|
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
time_t min, max;
|
time_t min, max;
|
||||||
@ -169,8 +169,7 @@ void p3Ranking::loadRankFile(std::string filename, std::string src)
|
|||||||
RsItem *item;
|
RsItem *item;
|
||||||
RsRankLinkMsg *newMsg;
|
RsRankLinkMsg *newMsg;
|
||||||
|
|
||||||
stream->tick(); /* Tick to read! */
|
while(NULL != (item = store->GetItem()))
|
||||||
while(NULL != (item = stream->GetItem()))
|
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef RANK_DEBUG
|
#ifdef RANK_DEBUG
|
||||||
@ -210,11 +209,9 @@ void p3Ranking::loadRankFile(std::string filename, std::string src)
|
|||||||
newMsg->PeerId(newMsg->pid);
|
newMsg->PeerId(newMsg->pid);
|
||||||
addRankMsg(newMsg);
|
addRankMsg(newMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
stream->tick(); /* Tick to read! */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete stream;
|
delete store;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -262,8 +259,7 @@ void p3Ranking::publishMsgs(bool own)
|
|||||||
|
|
||||||
uint32_t bioflags = BIN_FLAGS_HASH_DATA | BIN_FLAGS_WRITEABLE;
|
uint32_t bioflags = BIN_FLAGS_HASH_DATA | BIN_FLAGS_WRITEABLE;
|
||||||
BinInterface *bio = new BinFileInterface(fname.c_str(), bioflags);
|
BinInterface *bio = new BinFileInterface(fname.c_str(), bioflags);
|
||||||
pqistreamer *stream = new pqistreamer(rsSerialiser, mOwnId, bio,
|
pqistore *store = new pqistore(rsSerialiser, mOwnId, bio, BIN_FLAGS_NO_DELETE);
|
||||||
BIN_FLAGS_NO_DELETE);
|
|
||||||
|
|
||||||
{ RsStackMutex stack(mRankMtx); /********** STACK LOCKED MTX ******/
|
{ RsStackMutex stack(mRankMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
@ -288,9 +284,7 @@ void p3Ranking::publishMsgs(bool own)
|
|||||||
item->print(std::cerr, 10);
|
item->print(std::cerr, 10);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
stream->SendItem(item);
|
store->SendItem(item);
|
||||||
stream->tick(); /* Tick to write! */
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -341,8 +335,7 @@ void p3Ranking::publishMsgs(bool own)
|
|||||||
msg->print(std::cerr, 10);
|
msg->print(std::cerr, 10);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
stream->SendItem(msg);
|
store->SendItem(msg);
|
||||||
stream->tick(); /* Tick to write! */
|
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
delete msg;
|
delete msg;
|
||||||
@ -363,16 +356,12 @@ void p3Ranking::publishMsgs(bool own)
|
|||||||
(*ait)->print(std::cerr, 10);
|
(*ait)->print(std::cerr, 10);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
stream->SendItem(*ait);
|
store->SendItem(*ait);
|
||||||
stream->tick(); /* Tick to write! */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} /********** STACK LOCKED MTX ******/
|
} /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
|
||||||
stream->tick(); /* Tick for final write! */
|
|
||||||
|
|
||||||
/* flag as new info */
|
/* flag as new info */
|
||||||
CacheData data;
|
CacheData data;
|
||||||
|
|
||||||
@ -406,7 +395,7 @@ void p3Ranking::publishMsgs(bool own)
|
|||||||
refreshCache(data);
|
refreshCache(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete stream;
|
delete store;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1091,7 +1080,7 @@ std::string p3Ranking::anonRankMsg(std::string rid, std::wstring link, std::wstr
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
pqistreamer *createStreamer(std::string file, std::string src, bool reading)
|
pqistore *createStore(std::string file, std::string src, bool reading)
|
||||||
{
|
{
|
||||||
|
|
||||||
RsSerialiser *rsSerialiser = new RsSerialiser();
|
RsSerialiser *rsSerialiser = new RsSerialiser();
|
||||||
@ -1109,11 +1098,11 @@ pqistreamer *createStreamer(std::string file, std::string src, bool reading)
|
|||||||
|
|
||||||
/* bin flags: READ | WRITE | HASH_DATA */
|
/* bin flags: READ | WRITE | HASH_DATA */
|
||||||
BinInterface *bio = new BinFileInterface(file.c_str(), bioflags);
|
BinInterface *bio = new BinFileInterface(file.c_str(), bioflags);
|
||||||
/* streamer flags: NO_DELETE (yes) | NO_CLOSE (no) */
|
/* store flags: NO_DELETE (yes) | NO_CLOSE (no) */
|
||||||
pqistreamer *streamer = new pqistreamer(rsSerialiser, src, bio,
|
pqistore *store = new pqistore(rsSerialiser, src, bio,
|
||||||
BIN_FLAGS_NO_DELETE);
|
BIN_FLAGS_NO_DELETE);
|
||||||
|
|
||||||
return streamer;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string generateRandomLinkId()
|
std::string generateRandomLinkId()
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include "dbase/cachestrapper.h"
|
#include "dbase/cachestrapper.h"
|
||||||
#include "pqi/pqiservice.h"
|
#include "pqi/pqiservice.h"
|
||||||
#include "pqi/pqistreamer.h"
|
#include "pqi/pqistore.h"
|
||||||
#include "pqi/p3connmgr.h"
|
#include "pqi/p3connmgr.h"
|
||||||
#include "pqi/p3cfgmgr.h"
|
#include "pqi/p3cfgmgr.h"
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ float locked_calcRank(RankGroup &grp); /* returns 0->100 */
|
|||||||
void locked_reSortGroup(RankGroup &grp);
|
void locked_reSortGroup(RankGroup &grp);
|
||||||
|
|
||||||
void sortAllMsgs();
|
void sortAllMsgs();
|
||||||
pqistreamer *createStreamer(std::string file, std::string src, bool reading);
|
pqistore *createStore(std::string file, std::string src, bool reading);
|
||||||
|
|
||||||
|
|
||||||
/****************** p3Config STUFF *******************/
|
/****************** p3Config STUFF *******************/
|
||||||
|
Loading…
Reference in New Issue
Block a user