mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-04 09:05:34 -05:00
cleanups of debugging.
catch case where sql insert fails. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7325 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
faa7a8e7b1
commit
2232e8e583
@ -28,7 +28,9 @@
|
||||
#include "pqi/authgpg.h"
|
||||
//#include "retroshare/rspeers.h"
|
||||
|
||||
#define GXS_SECURITY_DEBUG
|
||||
/****
|
||||
* #define GXS_SECURITY_DEBUG 1
|
||||
***/
|
||||
|
||||
GxsSecurity::GxsSecurity()
|
||||
{
|
||||
|
@ -25,7 +25,9 @@
|
||||
|
||||
#include "gxs/gxstokenqueue.h"
|
||||
|
||||
#define GXS_DEBUG 1
|
||||
/*******
|
||||
* #define GXS_DEBUG 1
|
||||
******/
|
||||
|
||||
bool GxsTokenQueue::queueRequest(uint32_t token, uint32_t req_type)
|
||||
{
|
||||
|
@ -535,8 +535,20 @@ int RsDataService::storeMessage(std::map<RsNxsMsg *, RsGxsMsgMetaData *> &msg)
|
||||
RsNxsMsg* msgPtr = mit->first;
|
||||
RsGxsMsgMetaData* msgMetaPtr = mit->second;
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG
|
||||
std::cerr << "RsDataService::storeMessage() ";
|
||||
std::cerr << " GroupId: " << msgMetaPtr->mGroupId.toStdString();
|
||||
std::cerr << " MessageId: " << msgMetaPtr->mMsgId.toStdString();
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
// skip msg item if size if greater than
|
||||
if(!validSize(msgPtr)) continue;
|
||||
if(!validSize(msgPtr))
|
||||
{
|
||||
std::cerr << "RsDataService::storeMessage() ERROR invalid size";
|
||||
std::cerr << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
// create or access file in binary
|
||||
std::string msgFile = mServiceDir + "/" + msgPtr->grpId.toStdString() + "-msgs";
|
||||
@ -587,7 +599,15 @@ int RsDataService::storeMessage(std::map<RsNxsMsg *, RsGxsMsgMetaData *> &msg)
|
||||
ostrm.close();
|
||||
delete[] msgData;
|
||||
|
||||
mDb->sqlInsert(MSG_TABLE_NAME, "", cv);
|
||||
if (!mDb->sqlInsert(MSG_TABLE_NAME, "", cv))
|
||||
{
|
||||
std::cerr << "RsDataService::storeMessage() sqlInsert Failed";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "\t For GroupId: " << msgMetaPtr->mGroupId.toStdString();
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "\t & MessageId: " << msgMetaPtr->mMsgId.toStdString();
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// finish transaction
|
||||
@ -633,6 +653,13 @@ int RsDataService::storeGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
||||
// if data is larger than max item size do not add
|
||||
if(!validSize(grpPtr)) continue;
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG
|
||||
std::cerr << "RsDataService::storeGroup() GrpId: " << grpPtr->grpId.toStdString();
|
||||
std::cerr << " CircleType: " << (uint32_t) grpMetaPtr->mCircleType;
|
||||
std::cerr << " CircleId: " << grpMetaPtr->mCircleId.toStdString();
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::string grpFile = mServiceDir + "/" + grpPtr->grpId.toStdString();
|
||||
std::fstream ostrm(grpFile.c_str(), std::ios::binary | std::ios::app | std::ios::out);
|
||||
ostrm.seekg(0, std::ios::end); // go to end to append
|
||||
@ -689,7 +716,13 @@ int RsDataService::storeGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
||||
ostrm.write(grpData, grpPtr->grp.TlvSize());
|
||||
ostrm.close();
|
||||
|
||||
mDb->sqlInsert(GRP_TABLE_NAME, "", cv);
|
||||
if (!mDb->sqlInsert(GRP_TABLE_NAME, "", cv))
|
||||
{
|
||||
std::cerr << "RsDataService::storeGroup() sqlInsert Failed";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "\t For GroupId: " << grpMetaPtr->mGroupId.toStdString();
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
// finish transaction
|
||||
bool ret = mDb->execSQL("COMMIT;");
|
||||
@ -873,6 +906,13 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
||||
{
|
||||
RsNxsGrp* grpPtr = grp[mit->first];
|
||||
grpPtr->metaData = metaMap[mit->first];
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG
|
||||
std::cerr << "RsDataService::retrieveNxsGrps() GrpId: " << mit->first.toStdString();
|
||||
std::cerr << " CircleType: " << (uint32_t) grpPtr->metaData->mCircleType;
|
||||
std::cerr << " CircleId: " << grpPtr->metaData->mCircleId.toStdString();
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1252,19 +1252,15 @@ bool RsGenExchange::getMsgData(const uint32_t &token, GxsMsgDataMap &msgItems)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << "RsGenExchange::getMsgData() deserialisation/dynamic_cast ERROR";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << "RsGenExchange::getMsgData() deserialisation ERROR";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
delete msg;
|
||||
}
|
||||
@ -1385,6 +1381,11 @@ void RsGenExchange::notifyNewGroups(std::vector<RsNxsGrp *> &groups)
|
||||
// TODO: move this to nxs layer to save bandwidth
|
||||
if(received == mReceivedGrps.end())
|
||||
{
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << "RsGenExchange::notifyNewGroups() Received GrpId: " << grp->grpId;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
GxsPendingItem<RsNxsGrp*, RsGxsGroupId> gpsi(grp, grp->grpId);
|
||||
mReceivedGrps.push_back(gpsi);
|
||||
}
|
||||
@ -1412,10 +1413,21 @@ void RsGenExchange::notifyNewMessages(std::vector<RsNxsMsg *>& messages)
|
||||
|
||||
// if we have msg already just delete it
|
||||
if(it == mMsgPendingValidate.end())
|
||||
{
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << "RsGenExchange::notifyNewMessages() Received Msg: ";
|
||||
std::cerr << " GrpId: " << msg->grpId;
|
||||
std::cerr << " MsgId: " << msg->msgId;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mReceivedMsgs.push_back(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete msg;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1690,8 +1702,10 @@ void RsGenExchange::publishMsgs()
|
||||
|
||||
for(; mit != mMsgsToPublish.end(); mit++)
|
||||
{
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << "RsGenExchange::publishMsgs() Publishing a Message";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
RsNxsMsg* msg = new RsNxsMsg(mServType);
|
||||
RsGxsMsgItem* msgItem = mit->second;
|
||||
@ -1822,16 +1836,12 @@ void RsGenExchange::publishMsgs()
|
||||
mDataAccess->updatePublicRequestStatus(mit->first,
|
||||
RsTokenService::GXS_REQUEST_V2_STATUS_FAILED);
|
||||
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << "RsGenExchange::publishMsgs() failed to publish msg " << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << "RsGenExchange::publishMsgs() failed to serialise msg " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
delete[] mData;
|
||||
@ -2064,6 +2074,14 @@ void RsGenExchange::publishGrps()
|
||||
|
||||
create = createGroup(grp, privatekeySet, publicKeySet);
|
||||
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << "RsGenExchange::publishGrps() ";
|
||||
std::cerr << " GrpId: " << grp->grpId;
|
||||
std::cerr << " CircleType: " << (uint32_t) grp->metaData->mCircleType;
|
||||
std::cerr << " CircleId: " << grp->metaData->mCircleId.toStdString();
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if(create == CREATE_SUCCESS)
|
||||
{
|
||||
|
||||
|
@ -51,6 +51,7 @@
|
||||
#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002
|
||||
#define RS_TOKREQ_ANSTYPE_DATA 0x0003
|
||||
|
||||
|
||||
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_FAILED = 0;
|
||||
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_PENDING = 1;
|
||||
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_PARTIAL = 2;
|
||||
@ -58,6 +59,11 @@
|
||||
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE = 4;
|
||||
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_DONE = 5; // ONCE ALL DATA RETRIEVED.
|
||||
|
||||
|
||||
/***********
|
||||
* #define DATA_DEBUG 1
|
||||
**********/
|
||||
|
||||
RsGxsDataAccess::RsGxsDataAccess(RsGeneralDataService* ds)
|
||||
: mDataStore(ds), mDataMutex("RsGxsDataAccess"), mNextToken(0)
|
||||
{
|
||||
@ -103,7 +109,10 @@ bool RsGxsDataAccess::requestGroupInfo(uint32_t &token, uint32_t ansType, const
|
||||
}else
|
||||
{
|
||||
generateToken(token);
|
||||
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::requestGroupInfo() gets Token: " << token << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
setReq(req, token, ansType, opts);
|
||||
@ -142,7 +151,9 @@ bool RsGxsDataAccess::requestGroupInfo(uint32_t &token, uint32_t ansType, const
|
||||
}else
|
||||
{
|
||||
generateToken(token);
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::requestGroupInfo() gets Token: " << token << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
setReq(req, token, ansType, opts);
|
||||
@ -213,7 +224,9 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
|
||||
}else
|
||||
{
|
||||
generateToken(token);
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::requestMsgInfo() gets Token: " << token << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
setReq(req, token, ansType, opts);
|
||||
@ -263,7 +276,9 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
|
||||
}else
|
||||
{
|
||||
generateToken(token);
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::requestMsgInfo() gets Token: " << token << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
setReq(req, token, ansType, opts);
|
||||
@ -706,9 +721,11 @@ void RsGxsDataAccess::processRequests()
|
||||
GxsRequest* req = it->second;
|
||||
if (req->status == GXS_REQUEST_V2_STATUS_PENDING)
|
||||
{
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::processRequests() Processing Token: " << req->token << " Status: "
|
||||
<< req->status << " ReqType: " << req->reqType << " Age: "
|
||||
<< now - req->reqTime << std::endl;
|
||||
#endif
|
||||
|
||||
req->status = GXS_REQUEST_V2_STATUS_PARTIAL;
|
||||
|
||||
@ -744,10 +761,8 @@ void RsGxsDataAccess::processRequests()
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef GXSDATA_SERVE_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::processRequests() Failed to process request, token: "
|
||||
<< req->token << std::endl;
|
||||
#endif
|
||||
|
||||
req->status = GXS_REQUEST_V2_STATUS_FAILED;
|
||||
}
|
||||
@ -758,15 +773,19 @@ void RsGxsDataAccess::processRequests()
|
||||
}
|
||||
else if (req->status == GXS_REQUEST_V2_STATUS_DONE)
|
||||
{
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::processrequests() Clearing Done Request Token: "
|
||||
<< req->token;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
toClear.push_back(req->token);
|
||||
}
|
||||
else if (now - req->reqTime > MAX_REQUEST_AGE)
|
||||
{
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::processrequests() Clearing Old Request Token: " << req->token;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
toClear.push_back(req->token);
|
||||
}
|
||||
}
|
||||
|
@ -2263,13 +2263,12 @@ bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpM
|
||||
const RsGxsCircleId& circleId = grpMeta.mCircleId;
|
||||
if(circleId.isNull())
|
||||
{
|
||||
std::cerr << "RsGxsNetService::canSendGrpId() ERROR; EXTERNAL_CIRCLE missing NULL CircleId";
|
||||
std::cerr << "RsGxsNetService::canSendGrpId() ERROR; EXTERNAL_CIRCLE missing NULL CircleId: ";
|
||||
std::cerr << grpMeta.mGroupId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
// should just be shared. ? no - this happens for
|
||||
// Circle Groups which lose their CircleIds.
|
||||
// return true;
|
||||
// ERROR, will never be shared.
|
||||
return false;
|
||||
}
|
||||
|
||||
if(mCircles->isLoaded(circleId))
|
||||
|
@ -34,7 +34,6 @@
|
||||
//#define RETRODB_DEBUG
|
||||
#define ENABLE_ENCRYPTED_DB
|
||||
|
||||
|
||||
const int RetroDb::OPEN_READONLY = SQLITE_OPEN_READONLY;
|
||||
const int RetroDb::OPEN_READWRITE = SQLITE_OPEN_READWRITE;
|
||||
const int RetroDb::OPEN_READWRITE_CREATE = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
|
||||
@ -237,14 +236,13 @@ bool RetroDb::sqlInsert(const std::string &table, const std::string& /* nullColu
|
||||
// complete insertion query
|
||||
std::string sqlQuery = "INSERT INTO " + qColumns + " " + qValues;
|
||||
|
||||
execSQL_bind(sqlQuery, paramBindings);
|
||||
bool ok = execSQL_bind(sqlQuery, paramBindings);
|
||||
|
||||
#ifdef RETRODB_DEBUG
|
||||
std::cerr << "RetroDb::sqlInsert(): " << sqlQuery << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
return true;
|
||||
return ok;
|
||||
}
|
||||
|
||||
std::string RetroDb::getKey() const
|
||||
@ -265,7 +263,7 @@ bool RetroDb::execSQL_bind(const std::string &query, std::list<RetroBind*> ¶
|
||||
|
||||
// check if there are any errors
|
||||
if(rc != SQLITE_OK){
|
||||
std::cerr << "RetroDb::execSQL(): Error preparing statement\n";
|
||||
std::cerr << "RetroDb::execSQL_bind(): Error preparing statement\n";
|
||||
std::cerr << "Error code: " << sqlite3_errmsg(mDb)
|
||||
<< std::endl;
|
||||
return false;
|
||||
@ -318,12 +316,13 @@ bool RetroDb::execSQL_bind(const std::string &query, std::list<RetroBind*> ¶
|
||||
if(!ok){
|
||||
|
||||
if(rc == SQLITE_BUSY){
|
||||
std::cerr << "RetroDb::execSQL()\n" ;
|
||||
std::cerr << "RetroDb::execSQL_bind()\n" ;
|
||||
std::cerr << "SQL timed out!" << std::endl;
|
||||
}else{
|
||||
std::cerr << "RetroDb::execSQL(): Error executing statement (code: " << rc << ")\n";
|
||||
std::cerr << "RetroDb::execSQL_bind(): Error executing statement (code: " << rc << ")\n";
|
||||
std::cerr << "Sqlite Error msg: " << sqlite3_errmsg(mDb)
|
||||
<< std::endl;
|
||||
std::cerr << "RetroDb::execSQL_bind() Query: " << query << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -750,4 +749,3 @@ const void* RetroCursor::getData(int columnIndex, uint32_t &datSize){
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user