mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -05:00
GxsTrans delete own timed out mails
Mails sent in the past end never received were lingering in the outgoing queue forever as displayed by statistics. If a mail is older then GXS_STORAGE_PERIOD all nodes delete it from the GXS group so it can never arrive to destination, there is no point in keeping it in the outgoing queue, instead notify sending timed out and delete the mail.
This commit is contained in:
parent
ee9c240fb0
commit
7a237c11d3
@ -1,9 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* libretroshare/src/gxstrans: p3gxstrans.cc *
|
||||
* RetroShare GxsTrans asyncronous redundant small mail trasport on top of GXS *
|
||||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright (C) 2016-2017 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2016-2019 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -22,12 +20,13 @@
|
||||
#include "util/rsdir.h"
|
||||
#include "gxstrans/p3gxstrans.h"
|
||||
#include "util/stacktrace.h"
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
//#define DEBUG_GXSTRANS 1
|
||||
|
||||
typedef unsigned int uint;
|
||||
|
||||
RsGxsTrans *rsGxsTrans = NULL ;
|
||||
/*extern*/ RsGxsTrans* rsGxsTrans = nullptr;
|
||||
|
||||
const uint32_t p3GxsTrans::MAX_DELAY_BETWEEN_CLEANUPS = 900; // every 15 mins. Could be less.
|
||||
|
||||
@ -964,9 +963,9 @@ void p3GxsTrans::locked_processOutgoingRecord(OutgoingRecord& pr)
|
||||
{
|
||||
case RsGxsTransEncryptionMode::CLEAR_TEXT:
|
||||
{
|
||||
std::cerr << "p3GxsTrans::sendMail(...) you are sending a mail "
|
||||
<< "without encryption, everyone can read it!"
|
||||
<< std::endl;
|
||||
RsWarn() << __PRETTY_FUNCTION__ << " you are sending a mail "
|
||||
<< "without encryption, everyone can read it!"
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
case RsGxsTransEncryptionMode::RSA:
|
||||
@ -986,15 +985,15 @@ void p3GxsTrans::locked_processOutgoingRecord(OutgoingRecord& pr)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "p3GxsTrans::sendMail(...) RSA encryption failed! "
|
||||
<< "error_status: " << encryptError << std::endl;
|
||||
RsErr() << __PRETTY_FUNCTION__ << " RSA encryption failed! "
|
||||
<< "error_status: " << encryptError << std::endl;
|
||||
pr.status = GxsTransSendStatus::FAILED_ENCRYPTION;
|
||||
goto processingFailed;
|
||||
}
|
||||
}
|
||||
case RsGxsTransEncryptionMode::UNDEFINED_ENCRYPTION:
|
||||
default:
|
||||
std::cerr << "p3GxsTrans::sendMail(...) attempt to send mail with "
|
||||
RsErr() << __PRETTY_FUNCTION__ << " attempt to send mail with "
|
||||
<< "wrong EncryptionMode: "
|
||||
<< static_cast<uint>(pr.mailItem.cryptoType)
|
||||
<< " dropping mail!" << std::endl;
|
||||
@ -1040,7 +1039,8 @@ void p3GxsTrans::locked_processOutgoingRecord(OutgoingRecord& pr)
|
||||
{
|
||||
RS_STACK_MUTEX(mIngoingMutex);
|
||||
auto range = mIncomingQueue.equal_range(pr.mailItem.mailId);
|
||||
bool changed = false ;
|
||||
bool changed = false;
|
||||
bool received = false;
|
||||
|
||||
for( auto it = range.first; it != range.second; ++it)
|
||||
{
|
||||
@ -1051,14 +1051,21 @@ void p3GxsTrans::locked_processOutgoingRecord(OutgoingRecord& pr)
|
||||
mIncomingQueue.erase(it); delete rt;
|
||||
pr.status = GxsTransSendStatus::RECEIPT_RECEIVED;
|
||||
|
||||
changed = true ;
|
||||
changed = true;
|
||||
received = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!received && time(nullptr) - pr.sent_ts > GXS_STORAGE_PERIOD)
|
||||
{
|
||||
changed = true;
|
||||
pr.status = GxsTransSendStatus::FAILED_TIMED_OUT;
|
||||
}
|
||||
|
||||
if(changed)
|
||||
IndicateConfigChanged();
|
||||
|
||||
// TODO: Resend message if older then treshold
|
||||
break;
|
||||
}
|
||||
case GxsTransSendStatus::RECEIPT_RECEIVED:
|
||||
@ -1067,14 +1074,13 @@ void p3GxsTrans::locked_processOutgoingRecord(OutgoingRecord& pr)
|
||||
processingFailed:
|
||||
case GxsTransSendStatus::FAILED_RECEIPT_SIGNATURE:
|
||||
case GxsTransSendStatus::FAILED_ENCRYPTION:
|
||||
case GxsTransSendStatus::FAILED_TIMED_OUT:
|
||||
default:
|
||||
{
|
||||
std::cout << "p3GxsTrans::processRecord(" << pr.mailItem.mailId
|
||||
<< ") failed with: " << static_cast<uint>(pr.status)
|
||||
RsErr() << __PRETTY_FUNCTION__ << " processing:" << pr.mailItem.mailId
|
||||
<< " failed with: " << static_cast<uint>(pr.status)
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void p3GxsTrans::notifyClientService(const OutgoingRecord& pr)
|
||||
|
@ -1,9 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* libretroshare/src/gxstrans: p3gxstrans.h *
|
||||
* RetroShare GxsTrans asyncronous redundant small mail trasport on top of GXS *
|
||||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright (C) 2016-2017 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2016-2019 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -1,3 +1,21 @@
|
||||
/*******************************************************************************
|
||||
* RetroShare GxsTrans asyncronous redundant small mail trasport on top of GXS *
|
||||
* *
|
||||
* Copyright (C) 2016-2019 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version 3 as *
|
||||
* published by the Free Software Foundation. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public License *
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "retroshare/rstokenservice.h"
|
||||
@ -41,7 +59,8 @@ enum class GxsTransSendStatus : uint8_t
|
||||
/// Records with status >= RECEIPT_RECEIVED get deleted
|
||||
RECEIPT_RECEIVED = 0x0a,
|
||||
FAILED_RECEIPT_SIGNATURE = 0xf0,
|
||||
FAILED_ENCRYPTION = 0xf1
|
||||
FAILED_ENCRYPTION = 0xf1,
|
||||
FAILED_TIMED_OUT = 0xf2
|
||||
};
|
||||
|
||||
typedef uint64_t RsGxsTransId;
|
||||
|
Loading…
Reference in New Issue
Block a user