You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2011/06/05 08:37:49 UTC
svn commit: r1131929 -
/incubator/mesos/trunk/src/third_party/libprocess/reliable.cpp
Author: benh
Date: Sun Jun 5 06:37:49 2011
New Revision: 1131929
URL: http://svn.apache.org/viewvc?rev=1131929&view=rev
Log:
Bug fix due to out-of-order reliable message being received.
Modified:
incubator/mesos/trunk/src/third_party/libprocess/reliable.cpp
Modified: incubator/mesos/trunk/src/third_party/libprocess/reliable.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/third_party/libprocess/reliable.cpp?rev=1131929&r1=1131928&r2=1131929&view=diff
==============================================================================
--- incubator/mesos/trunk/src/third_party/libprocess/reliable.cpp (original)
+++ incubator/mesos/trunk/src/third_party/libprocess/reliable.cpp Sun Jun 5 06:37:49 2011
@@ -110,14 +110,9 @@ bool ReliableProcess::duplicate() const
// greater than the last one we saw. Note that we don't add the
// sequence identifier for the current message until the next
// 'receive' invocation (see below).
- if (current != NULL) {
- map<PID, int>::const_iterator it = recvSeqs.find(current->msg.from);
- if (it != recvSeqs.end()) {
- int last = it->second;
- if (current->seq <= last)
- return true;
- }
- }
+ if (current != NULL)
+ if (recvSeqs.count(current->msg.from) > 0)
+ return current->seq <= recvSeqs.find(current->msg.from)->second;
return false;
}
@@ -190,7 +185,7 @@ MSGID ReliableProcess::receive(double se
// can be sure that the current message is the next in the
// sequence (unless it's the first message or a duplicate).
if (!duplicate()) {
- assert((recvSeqs.find(current->msg.from) == recvSeqs.end()) ||
+ assert((recvSeqs.count(current->msg.from) == 0) ||
(recvSeqs[current->msg.from] + 1 == current->seq));
recvSeqs[current->msg.from] = current->seq;
}
@@ -227,9 +222,12 @@ MSGID ReliableProcess::receive(double se
memcpy((char *) current, data, length);
// TODO(benh): Don't ignore out-of-order messages!
- if (recvSeqs.find(current->msg.from) != recvSeqs.end())
- if (recvSeqs[current->msg.from] + 1 < current->seq)
- continue;
+ if (recvSeqs.count(current->msg.from) > 0 &&
+ recvSeqs[current->msg.from] + 1 < current->seq) {
+ free(current);
+ current = NULL;
+ continue;
+ }
// Note that we don't record the sequence number here so that
// our logic in 'duplicate' (see above) is correct. We might