Repairing one more bug with SyncLogic's diff log
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index 7f052f1..d51a3a6 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -140,11 +140,22 @@
if (stateInDiffLog != m_log.end ())
{
- _LOG_TRACE (">> D " << interestName);
+ DiffStateConstPtr stateDiff = (*stateInDiffLog)->diff ();
+ // string state = lexical_cast<string> (*stateDiff);
+ // erase_all (state, "\n");
+ // _LOG_TRACE (">> D " << interestName << ", state: " << state);
+ // _LOG_DEBUG ("Log size: " << m_log.size ());
+
+ // BOOST_FOREACH (DiffStateConstPtr ds, m_log.get<sequenced> ())
+ // {
+ // string state = lexical_cast<string> (*ds);
+ // erase_all (state, "\n");
+ // _LOG_DEBUG (" " << state << ", " << *ds->getDigest ());
+ // }
m_syncInterestTable.remove (interestName);
m_ccnxHandle->publishData (interestName,
- lexical_cast<string> (*(*stateInDiffLog)->diff ()),
+ lexical_cast<string> (*stateDiff),
m_syncResponseFreshness);
if (m_outstandingInterest == interestName)
{
@@ -254,14 +265,7 @@
}
}
- diffLog->setDigest(m_state.getDigest());
- if (m_log.size () > 0)
- {
- m_log.get<sequenced> ().front ()->setNext (diffLog);
- }
- m_log.erase (m_state.getDigest());
- /// @todo Optimization
- m_log.insert (diffLog);
+ insertToDiffLog (diffLog);
}
catch (Error::SyncXmlDecodingFailure &e)
{
@@ -322,7 +326,7 @@
}
void
-SyncLogic::processPendingSyncInterests (DiffStatePtr diffLog)
+SyncLogic::insertToDiffLog (DiffStatePtr diffLog)
{
//cout << "Process Pending Interests" <<endl;
diffLog->setDigest (m_state.getDigest());
@@ -352,7 +356,7 @@
diff = make_shared<DiffState>();
diff->update(info, seqN);
- processPendingSyncInterests (diff);
+ insertToDiffLog (diff);
}
// _LOG_DEBUG ("PIT size: " << m_syncInterestTable.size ());
@@ -371,7 +375,7 @@
diff = make_shared<DiffState>();
diff->remove(info);
- processPendingSyncInterests (diff);
+ insertToDiffLog (diff);
}
satisfyPendingSyncInterests (diff);
diff --git a/model/sync-logic.h b/model/sync-logic.h
index e966dea..561ff9b 100644
--- a/model/sync-logic.h
+++ b/model/sync-logic.h
@@ -110,7 +110,7 @@
sendSyncInterest ();
void
- processPendingSyncInterests (DiffStatePtr diff);
+ insertToDiffLog (DiffStatePtr diff);
void
satisfyPendingSyncInterests (DiffStatePtr diff);
diff --git a/test/test_app_socket.cc b/test/test_app_socket.cc
index d1b90c0..d35fdaa 100644
--- a/test/test_app_socket.cc
+++ b/test/test_app_socket.cc
@@ -44,7 +44,7 @@
public:
map<string, string> data;
void set(string str1, string str2) {
- _LOG_FUNCTION (this << ", " << str1);
+ // _LOG_FUNCTION (this << ", " << str1);
data.insert(make_pair(str1, str2));
// cout << str1 << ", " << str2 << endl;
}
@@ -88,14 +88,14 @@
string data0 = "Very funny Scotty, now beam down my clothes";
_LOG_DEBUG ("s1 publish");
s1.publish (p1, 0, data0, 10);
- this_thread::sleep (posix_time::milliseconds (250));
+ this_thread::sleep (posix_time::milliseconds (120));
// from code logic, we won't be fetching our own data
a1.set(p1 + "/0/0", data0);
BOOST_CHECK_EQUAL(a1.toString(), a2.toString());
BOOST_CHECK_EQUAL(a2.toString(), a3.toString());
- // // single source, multiple data at once
+ // single source, multiple data at once
string data1 = "Yes, give me that ketchup";
string data2 = "Don't look conspicuous, it draws fire";
@@ -105,13 +105,13 @@
s1.publish (p1, 0, data2, 10);
this_thread::sleep (posix_time::milliseconds (250));
- // // // from code logic, we won't be fetching our own data
+ // from code logic, we won't be fetching our own data
a1.set(p1 + "/0/1", data1);
a1.set(p1 + "/0/2", data2);
BOOST_CHECK_EQUAL(a1.toString(), a2.toString());
BOOST_CHECK_EQUAL(a2.toString(), a3.toString());
- // // another single source
+ // another single source
string data3 = "You surf the Internet, I surf the real world";
string data4 = "I got a fortune cookie once that said 'You like Chinese food'";
string data5 = "Real men wear pink. Why? Because their wives make them";
@@ -132,15 +132,21 @@
BOOST_CHECK_EQUAL(a2.toString(), a3.toString());
// not sure weither this is simultanous data generation from multiple sources
+ _LOG_DEBUG ("Simultaneous publishing");
string data6 = "Shakespeare says: 'Prose before hos.'";
string data7 = "Pick good people, talent never wears out";
s1.publish(p1, 0, data6, 10);
+ // this_thread::sleep (posix_time::milliseconds (1000));
s2.publish(p2, 0, data7, 10);
- this_thread::sleep (posix_time::milliseconds (10000));
+ this_thread::sleep (posix_time::milliseconds (1500));
// from code logic, we won't be fetching our own data
a1.set(p1 + "/0/3", data6);
a2.set(p2 + "/0/2", data7);
+ // a1.set(p1 + "/0/1", data6);
+ // a2.set(p2 + "/0/0", data7);
BOOST_CHECK_EQUAL(a1.toString(), a2.toString());
BOOST_CHECK_EQUAL(a2.toString(), a3.toString());
+
+ _LOG_DEBUG ("Finish");
}