From 446e5fd6659b745f9929d5a085e34fa4485bb856 Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 28 Dec 2014 15:45:58 -0500 Subject: [PATCH] report about termination after actual processing --- AddressBook.cpp | 8 +++++--- AddressBook.h | 1 + Destination.cpp | 17 +++++++++-------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/AddressBook.cpp b/AddressBook.cpp index 23a12180..7dfa6964 100644 --- a/AddressBook.cpp +++ b/AddressBook.cpp @@ -443,9 +443,10 @@ namespace client found = success; newDataReceived.notify_all (); }); - newDataReceived.wait (l); + if (newDataReceived.wait_for (l, std::chrono::seconds (SUBSCRIPTION_REQUEST_TIMEOUT)) == std::cv_status::timeout) + LogPrint (eLogError, "Subscription LeseseSet request timeout expired"); if (found) - leaseSet = i2p::client::context.GetSharedLocalDestination ()->FindLeaseSet (ident); + leaseSet = i2p::client::context.GetSharedLocalDestination ()->FindLeaseSet (ident); } if (leaseSet) { @@ -476,7 +477,8 @@ namespace client }, 30); // wait for 30 seconds std::unique_lock l(newDataReceivedMutex); - newDataReceived.wait (l); + if (newDataReceived.wait_for (l, std::chrono::seconds (SUBSCRIPTION_REQUEST_TIMEOUT)) == std::cv_status::timeout) + LogPrint (eLogError, "Subscription timeout expired"); } // process remaining buffer while (size_t len = stream->ReadSome (buf, 4096)) diff --git a/AddressBook.h b/AddressBook.h index a2ad9adc..47b819db 100644 --- a/AddressBook.h +++ b/AddressBook.h @@ -22,6 +22,7 @@ namespace client const int INITIAL_SUBSCRIPTION_RETRY_TIMEOUT = 1; // in minutes const int CONTINIOUS_SUBSCRIPTION_UPDATE_TIMEOUT = 240; // in minutes const int CONTINIOUS_SUBSCRIPTION_RETRY_TIMEOUT = 5; // in minutes + const int SUBSCRIPTION_REQUEST_TIMEOUT = 60; //in second class AddressBookStorage // interface for storage { diff --git a/Destination.cpp b/Destination.cpp index 9bfc7f24..b3102206 100644 --- a/Destination.cpp +++ b/Destination.cpp @@ -208,14 +208,6 @@ namespace client void ClientDestination::HandleDatabaseStoreMessage (const uint8_t * buf, size_t len) { I2NPDatabaseStoreMsg * msg = (I2NPDatabaseStoreMsg *)buf; - auto it1 = m_LeaseSetRequests.find (msg->key); - if (it1 != m_LeaseSetRequests.end ()) - { - it1->second->requestTimeoutTimer.cancel (); - if (it1->second->requestComplete) it1->second->requestComplete (true); - delete it1->second; - m_LeaseSetRequests.erase (it1); - } size_t offset = sizeof (I2NPDatabaseStoreMsg); if (msg->replyToken) // TODO: offset += 36; @@ -236,6 +228,15 @@ namespace client } else LogPrint (eLogError, "Unexpected client's DatabaseStore type ", msg->type, ". Dropped"); + + auto it1 = m_LeaseSetRequests.find (msg->key); + if (it1 != m_LeaseSetRequests.end ()) + { + it1->second->requestTimeoutTimer.cancel (); + if (it1->second->requestComplete) it1->second->requestComplete (true); + delete it1->second; + m_LeaseSetRequests.erase (it1); + } } void ClientDestination::HandleDatabaseSearchReplyMessage (const uint8_t * buf, size_t len)