Merge remote-tracking branch 'upstream/master' into v0.6-BugFixing_4

This commit is contained in:
csoler 2020-11-28 21:34:32 +01:00
commit d842c6fe52
49 changed files with 2185 additions and 1930 deletions

View file

@ -1083,6 +1083,8 @@ bool ftServer::sendTurtleItem(const RsPeerId& peerId,const RsFileHash& hash,RsTu
if(!encryptItem(item, hash, encrypted_item))
return false ;
encrypted_item->setPriorityLevel(item->priority_level());
delete item ;
mTurtleRouter->sendTurtleData(peerId,encrypted_item) ;

View file

@ -709,44 +709,46 @@ void RsGxsDataAccess::processRequests()
while (!mRequestQueue.empty())
{
// Extract the first elements from the request queue. cleanup all other elements marked at terminated.
// Extract the first elements from the request queue. cleanup all other elements marked at terminated.
GxsRequest* req = nullptr;
{
RsStackMutex stack(mDataMutex); /******* LOCKED *******/
rstime_t now = time(nullptr); // this is ok while in the loop below
rstime_t now = time(nullptr); // this is ok while in the loop below
while(!mRequestQueue.empty() && req == nullptr)
{
if(now > mRequestQueue.begin()->second->reqTime + MAX_REQUEST_AGE)
{
while(!mRequestQueue.empty() && req == nullptr)
{
if(now > mRequestQueue.begin()->second->reqTime + MAX_REQUEST_AGE)
{
delete mRequestQueue.begin()->second;
mRequestQueue.erase(mRequestQueue.begin());
continue;
}
}
switch( mRequestQueue.begin()->second->status )
{
case PARTIAL:
RsErr() << "Found partial request in mRequestQueue. This is a bug." << std::endl; // fallthrough
case COMPLETE:
case DONE:
case FAILED:
case CANCELLED:
switch( mRequestQueue.begin()->second->status )
{
case PARTIAL:
RsErr() << "Found partial request in mRequestQueue. This is a bug." << std::endl; // fallthrough
case COMPLETE:
case DONE:
case FAILED:
case CANCELLED:
#ifdef DATA_DEBUG
RsDbg() << " request " << mRequestQueue.begin()->second->token << ": status = " << mRequestQueue.begin()->second->status << ": removing from the RequestQueue" << std::endl;
RsDbg() << " request " << mRequestQueue.begin()->second->token << ": status = " << mRequestQueue.begin()->second->status << ": removing from the RequestQueue" << std::endl;
#endif
mRequestQueue.erase(mRequestQueue.begin());
continue;
break;
case PENDING:
req = mRequestQueue.begin()->second;
req->status = PARTIAL;
mRequestQueue.erase(mRequestQueue.begin()); // remove it right away from the waiting queue.
break;
}
delete mRequestQueue.begin()->second;
mRequestQueue.erase(mRequestQueue.begin());
continue;
break;
case PENDING:
req = mRequestQueue.begin()->second;
req->status = PARTIAL;
mRequestQueue.erase(mRequestQueue.begin()); // remove it right away from the waiting queue.
break;
}
}
}
}
} // END OF MUTEX.
if (!req)
break;
@ -813,33 +815,33 @@ void RsGxsDataAccess::processRequests()
else
RsErr() << __PRETTY_FUNCTION__ << " Failed to process request, token: " << req->token << std::endl;
// We cannot easily remove the request here because the queue may have more elements now and mRequestQueue.begin() is not necessarily the same element.
// but we mark it as COMPLETE/FAILED so that it will be removed in the next loop.
// We cannot easily remove the request here because the queue may have more elements now and mRequestQueue.begin() is not necessarily the same element.
// but we mark it as COMPLETE/FAILED so that it will be removed in the next loop.
{
RsStackMutex stack(mDataMutex); /******* LOCKED *******/
if(ok)
{
// When the request is complete, we move it to the complete list, so that the caller can easily retrieve the request data
if(ok)
{
// When the request is complete, we move it to the complete list, so that the caller can easily retrieve the request data
#ifdef DATA_DEBUG
RsDbg() << " Request completed successfully. Marking as COMPLETE." << std::endl;
RsDbg() << " Request completed successfully. Marking as COMPLETE." << std::endl;
#endif
req->status = COMPLETE ;
mCompletedRequests[req->token] = req;
mPublicToken[req->token] = COMPLETE;
}
else
{
mCompletedRequests[req->token] = req;
mPublicToken[req->token] = COMPLETE;
}
else
{
req->status = FAILED;
mPublicToken[req->token] = FAILED;
mPublicToken[req->token] = FAILED;
#ifdef DATA_DEBUG
RsDbg() << " Request failed. Marking as FAILED." << std::endl;
RsDbg() << " Request failed. Marking as FAILED." << std::endl;
#endif
}
}
}
} // END OF MUTEX.
} // END OF MUTEX.
}
}

View file

@ -308,7 +308,7 @@ static const uint32_t GROUP_STATS_UPDATE_DELAY = 240; //
static const uint32_t GROUP_STATS_UPDATE_NB_PEERS = 2; // number of peers to which the group stats are asked
static const uint32_t MAX_ALLOWED_GXS_MESSAGE_SIZE = 199000; // 200,000 bytes including signature and headers
static const uint32_t MIN_DELAY_BETWEEN_GROUP_SEARCH = 40; // dont search same group more than every 40 secs.
static const uint32_t SAFETY_DELAY_FOR_UNSUCCESSFUL_UPDATE = 1800; // avoid re-sending the same msg list to a peer who asks twice for the same update in less than this time
static const uint32_t SAFETY_DELAY_FOR_UNSUCCESSFUL_UPDATE = 0; // avoid re-sending the same msg list to a peer who asks twice for the same update in less than this time
static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_UNKNOWN = 0x00 ;
static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_NO_ERROR = 0x01 ;

View file

@ -1221,9 +1221,12 @@ bool p3GxsTunnelService::locked_sendClearTunnelData(RsGxsTunnelDHPublicKeyItem *
std::cerr << "GxsTunnelService::sendClearTunnelData(): try sending item " << (void*)item << " to peer " << item->PeerId() << std::endl;
#endif
// make a TurtleGenericData item out of it, and send it in clear.
//
// make a RsTurtleGenericData item out of it, and send it in clear.
// this is compatible with nodes older than 0.6.6
RsTurtleGenericDataItem *gitem = new RsTurtleGenericDataItem ;
// force item priority to QOS_PRIORITY_RS_TURTLE_GENERIC_FAST_DATA to make the DH exchange faster on 0.6.6+ nodes
// this will not affect old nodes
gitem->setPriorityLevel(QOS_PRIORITY_RS_TURTLE_GENERIC_FAST_DATA);
RsGxsTunnelSerialiser ser ;

View file

@ -797,13 +797,13 @@ public:
* @jsonapi{development}
* @param[in] sslId Id of the peer of which we want to generate an invite,
* a null id (all 0) is passed, an invite for own node is returned.
* @param[in] includeSignatures true to add key signatures to the invite
* @param[in] includeExtraLocators false to avoid to add extra locators
* @param[in] inviteFlags specify extra data to include in the invite
* @return invite string
*/
virtual std::string GetRetroshareInvite(
const RsPeerId& sslId = RsPeerId(),
RetroshareInviteFlags = RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP ) = 0;
const RsPeerId& sslId = RsPeerId(),
RetroshareInviteFlags inviteFlags =
RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP ) = 0;
/**
* @brief Get RetroShare short invite of the given peer
@ -811,19 +811,19 @@ public:
* @param[out] invite storage for the generated invite
* @param[in] sslId Id of the peer of which we want to generate an invite,
* a null id (all 0) is passed, an invite for own node is returned.
* @param[in] formatRadix true to get in base64 format false to get URL.
* @param[in] bareBones true to get smallest invite, which miss also
* the information necessary to attempt an outgoing connection, but still
* enough to accept an incoming one.
* @param[in] inviteFlags specify extra data to include in the invite and
* format.
* @param[in] baseUrl URL into which to sneak in the RetroShare invite
* radix, this is primarly useful to trick other applications into making
* the invite clickable, or to disguise the RetroShare invite into a
* "normal" looking web link. Used only if formatRadix is false.
* @return false if error occurred, true otherwise
*/
virtual bool getShortInvite(std::string& invite, const RsPeerId& sslId = RsPeerId(),
RetroshareInviteFlags locator_flags = RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::DNS,
const std::string& baseUrl = "https://retroshare.me/" ) = 0;
virtual bool getShortInvite(
std::string& invite, const RsPeerId& sslId = RsPeerId(),
RetroshareInviteFlags inviteFlags =
RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::DNS,
const std::string& baseUrl = "https://retroshare.me/" ) = 0;
/**
* @brief Parse the give short invite to extract contained information

View file

@ -23,7 +23,7 @@
#include <stdint.h>
// This file centralises QoS priorities for all transfer RsItems.
// This file centralises QoS priorities for all transfer RsItems
//
const uint8_t QOS_PRIORITY_UNKNOWN = 0 ;
const uint8_t QOS_PRIORITY_DEFAULT = 3 ;
@ -33,63 +33,66 @@ const uint8_t QOS_PRIORITY_TOP = 9 ;
//
const uint8_t QOS_PRIORITY_RS_TURTLE_OPEN_TUNNEL = 7 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_TUNNEL_OK = 7 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_SEARCH_REQUEST = 7 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_FILE_REQUEST = 5 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_FILE_CRC_REQUEST = 5 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_CHUNK_CRC_REQUEST = 5 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_FILE_MAP_REQUEST = 5 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_SEARCH_REQUEST = 6 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_FILE_REQUEST = 6 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_FILE_MAP_REQUEST = 6 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_FILE_CRC_REQUEST = 6 ; // unused
const uint8_t QOS_PRIORITY_RS_TURTLE_CHUNK_CRC_REQUEST = 6 ; // unused
const uint8_t QOS_PRIORITY_RS_TURTLE_FILE_DATA = 5 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_FILE_CRC = 5 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_CHUNK_CRC = 5 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_FILE_MAP = 5 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_FILE_MAP = 6 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_FILE_CRC = 6 ; // unused
const uint8_t QOS_PRIORITY_RS_TURTLE_CHUNK_CRC = 6 ; // unused
const uint8_t QOS_PRIORITY_RS_TURTLE_SEARCH_RESULT = 4 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_GENERIC_ITEM = 3 ;
//const uint8_t QOS_PRIORITY_RS_TURTLE_FORWARD_FILE_DATA= 3 ; // unused
const uint8_t QOS_PRIORITY_RS_TURTLE_GENERIC_DATA = 5 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_GENERIC_FAST_DATA = 7 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_SEARCH_RESULT = 6 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_GENERIC_DATA = 5 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_GENERIC_ITEM = 3 ;
const uint8_t QOS_PRIORITY_RS_TURTLE_FORWARD_FILE_DATA = 3 ; // unused
// File transfer
//
const uint8_t QOS_PRIORITY_RS_FILE_REQUEST = 5 ;
const uint8_t QOS_PRIORITY_RS_FILE_CRC_REQUEST = 5 ;
const uint8_t QOS_PRIORITY_RS_CHUNK_CRC_REQUEST = 5 ;
const uint8_t QOS_PRIORITY_RS_FILE_MAP_REQUEST = 5 ;
const uint8_t QOS_PRIORITY_RS_FILE_DATA = 5 ;
const uint8_t QOS_PRIORITY_RS_FILE_CRC = 5 ;
const uint8_t QOS_PRIORITY_RS_CHUNK_CRC = 5 ;
const uint8_t QOS_PRIORITY_RS_FILE_MAP = 5 ;
//const uint8_t QOS_PRIORITY_RS_CACHE_ITEM = 3 ; // unused
const uint8_t QOS_PRIORITY_RS_FILE_REQUEST = 6 ;
const uint8_t QOS_PRIORITY_RS_FILE_MAP_REQUEST = 6 ;
const uint8_t QOS_PRIORITY_RS_FILE_CRC_REQUEST = 6 ; // unused
const uint8_t QOS_PRIORITY_RS_CHUNK_CRC_REQUEST = 6 ;
const uint8_t QOS_PRIORITY_RS_FILE_DATA = 5 ;
const uint8_t QOS_PRIORITY_RS_FILE_MAP = 6 ;
const uint8_t QOS_PRIORITY_RS_FILE_CRC = 6 ; // unused
const uint8_t QOS_PRIORITY_RS_CHUNK_CRC = 6 ;
const uint8_t QOS_PRIORITY_RS_CACHE_ITEM = 3 ; // unused
// Discovery
//
const uint8_t QOS_PRIORITY_RS_DISC_HEART_BEAT = 8 ;
const uint8_t QOS_PRIORITY_RS_DISC_ASK_INFO = 2 ;
const uint8_t QOS_PRIORITY_RS_DISC_REPLY = 2 ;
const uint8_t QOS_PRIORITY_RS_DISC_VERSION = 2 ;
const uint8_t QOS_PRIORITY_RS_DISC_HEART_BEAT = 8 ;
const uint8_t QOS_PRIORITY_RS_DISC_ASK_INFO = 2 ;
const uint8_t QOS_PRIORITY_RS_DISC_REPLY = 2 ;
const uint8_t QOS_PRIORITY_RS_DISC_VERSION = 2 ;
const uint8_t QOS_PRIORITY_RS_DISC_CONTACT = 2 ; // CONTACT and PGPLIST must have
const uint8_t QOS_PRIORITY_RS_DISC_PGP_LIST = 2 ; // same priority.
const uint8_t QOS_PRIORITY_RS_DISC_SERVICES = 2 ;
const uint8_t QOS_PRIORITY_RS_DISC_PGP_CERT = 2 ;
const uint8_t QOS_PRIORITY_RS_DISC_CONTACT = 2 ; // CONTACT and PGPLIST must have
const uint8_t QOS_PRIORITY_RS_DISC_PGP_LIST = 2 ; // same priority
const uint8_t QOS_PRIORITY_RS_DISC_SERVICES = 2 ;
const uint8_t QOS_PRIORITY_RS_DISC_PGP_CERT = 2 ;
// File database
//
const uint8_t QOS_PRIORITY_RS_FAST_SYNC_REQUEST = 7 ;
const uint8_t QOS_PRIORITY_RS_SLOW_SYNC_REQUEST = 3 ;
// Heartbeat.
// Heartbeat
//
const uint8_t QOS_PRIORITY_RS_HEARTBEAT_PULSE = 8 ;
const uint8_t QOS_PRIORITY_RS_HEARTBEAT_PULSE = 8 ;
// Chat/Msgs
//
const uint8_t QOS_PRIORITY_RS_CHAT_ITEM = 7 ;
const uint8_t QOS_PRIORITY_RS_CHAT_AVATAR_ITEM = 2 ;
const uint8_t QOS_PRIORITY_RS_MSG_ITEM = 2 ; // depreciated.
const uint8_t QOS_PRIORITY_RS_MAIL_ITEM = 2 ; // new mail service
const uint8_t QOS_PRIORITY_RS_STATUS_ITEM = 2 ;
const uint8_t QOS_PRIORITY_RS_CHAT_ITEM = 7 ;
const uint8_t QOS_PRIORITY_RS_CHAT_AVATAR_ITEM = 2 ;
const uint8_t QOS_PRIORITY_RS_MSG_ITEM = 2 ; // deprecated
const uint8_t QOS_PRIORITY_RS_MAIL_ITEM = 2 ; // new mail service
const uint8_t QOS_PRIORITY_RS_STATUS_ITEM = 2 ;
// RTT
//
@ -97,24 +100,26 @@ const uint8_t QOS_PRIORITY_RS_RTT_PING = 9 ;
// BanList
//
const uint8_t QOS_PRIORITY_RS_BANLIST_ITEM = 3 ;
const uint8_t QOS_PRIORITY_RS_BANLIST_ITEM = 3 ;
// Bandwidth Control.
// Bandwidth Control
//
const uint8_t QOS_PRIORITY_RS_BWCTRL_ALLOWED_ITEM = 9 ;
const uint8_t QOS_PRIORITY_RS_BWCTRL_ALLOWED_ITEM = 9 ;
// Dsdv Routing
// DsDv Routing
//
const uint8_t QOS_PRIORITY_RS_DSDV_ROUTE = 4 ;
const uint8_t QOS_PRIORITY_RS_DSDV_DATA = 2 ;
const uint8_t QOS_PRIORITY_RS_DSDV_ROUTE = 4 ;
const uint8_t QOS_PRIORITY_RS_DSDV_DATA = 2 ;
// GXS
//
const uint8_t QOS_PRIORITY_RS_GXS_NET = 6 ;
// GXS Reputation.
const uint8_t QOS_PRIORITY_RS_GXSREPUTATION_ITEM = 3;
// GXS Reputation
//
const uint8_t QOS_PRIORITY_RS_GXSREPUTATION_ITEM = 3 ;
// Service Info / Control.
const uint8_t QOS_PRIORITY_RS_SERVICE_INFO_ITEM = 8;
// Service Info / Control
//
const uint8_t QOS_PRIORITY_RS_SERVICE_INFO_ITEM = 8 ;

View file

@ -33,11 +33,16 @@
RsItem *RsServiceSerializer::deserialise(void *data, uint32_t *size)
{
if(!data || !size || !*size)
if(!data || !size || *size < 8)
{
RsErr() << __PRETTY_FUNCTION__ << " Called with null paramethers data: "
<< data << " size: " << static_cast<void*>(size) << " *size: "
<< (size ? *size : 0) << " this should never happen!"
RsErr() << __PRETTY_FUNCTION__ << " Called with inconsistent parameters data: " << std::endl;
if(data)
RsErr() << "Data is: " << RsUtil::BinToHex(static_cast<uint8_t*>(data),std::min(50u,*size)) << ((*size>50)?"...":"") << std::endl;
else
RsErr() << "Null Data" << std::endl;
RsErr() << " size: " << static_cast<void*>(size) << " *size: " << (size ? *size : 0) << std::endl
<< " this should never happen!"
<< std::endl;
print_stacktrace();
return nullptr;

View file

@ -324,7 +324,7 @@ class RsTurtleGenericTunnelItem: public RsTurtleItem
class RsTurtleGenericDataItem: public RsTurtleGenericTunnelItem
{
public:
RsTurtleGenericDataItem() : RsTurtleGenericTunnelItem(RS_TURTLE_SUBTYPE_GENERIC_DATA), data_size(0), data_bytes(0) { setPriorityLevel(QOS_PRIORITY_RS_TURTLE_FILE_REQUEST);}
RsTurtleGenericDataItem() : RsTurtleGenericTunnelItem(RS_TURTLE_SUBTYPE_GENERIC_DATA), data_size(0), data_bytes(0) { setPriorityLevel(QOS_PRIORITY_RS_TURTLE_GENERIC_DATA);}
virtual ~RsTurtleGenericDataItem() { if(data_bytes != NULL) free(data_bytes) ; }
virtual bool shouldStampTunnel() const { return true ; }

View file

@ -10,7 +10,13 @@ INCLUDEPATH *= $$clean_path($${RS_SRC_PATH}/libretroshare/src)
equals(TARGET, retroshare):equals(TEMPLATE, lib){
} else {
LIBS *= -L$$clean_path($${RS_BUILD_PATH}/libretroshare/src/lib/) -lretroshare
PRE_TARGETDEPS *= $$clean_path($${RS_BUILD_PATH}/libretroshare/src/lib/libretroshare.a)
win32-g++|win32-clang-g++:!isEmpty(QMAKE_SH):libretroshare_shared {
# Windows msys2
LIBRETROSHARE_TARGET=libretroshare.dll.a
} else {
LIBRETROSHARE_TARGET=libretroshare.a
}
PRE_TARGETDEPS *= $$clean_path($${RS_BUILD_PATH}/libretroshare/src/lib/$${LIBRETROSHARE_TARGET})
}
!include("../../openpgpsdk/src/use_openpgpsdk.pri"):error("Including")

View file

@ -892,6 +892,10 @@ int RsDirUtil::createLockFile(const std::string& lock_file_path, rs_lock_handle_
return 2;
}
// Write to lock file our pid
std::string ourPID = std::to_string(::getpid());
write(lock_handle, ourPID.c_str(), sizeof(char)*ourPID.size() );
return 0;
#else
// Suspended. The user should make sure he's not already using the file descriptor.