Skip to content

Commit

Permalink
report about termination after actual processing
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Dec 28, 2014
1 parent 7847982 commit 446e5fd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
8 changes: 5 additions & 3 deletions AddressBook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -476,7 +477,8 @@ namespace client
},
30); // wait for 30 seconds
std::unique_lock<std::mutex> 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))
Expand Down
1 change: 1 addition & 0 deletions AddressBook.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
17 changes: 9 additions & 8 deletions Destination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit 446e5fd

Please sign in to comment.