forked from I2P_Developers/i2p.i2p
Router: INMP and netdb DSRM selector cleanup
This commit is contained in:
@ -146,6 +146,9 @@ public class InNetMessagePool implements Service {
|
|||||||
* (was queue length, long ago)
|
* (was queue length, long ago)
|
||||||
*/
|
*/
|
||||||
public int add(I2NPMessage messageBody, RouterIdentity fromRouter, Hash fromRouterHash) {
|
public int add(I2NPMessage messageBody, RouterIdentity fromRouter, Hash fromRouterHash) {
|
||||||
|
final MessageHistory history = _context.messageHistory();
|
||||||
|
final boolean doHistory = history.getDoLog();
|
||||||
|
|
||||||
long exp = messageBody.getMessageExpiration();
|
long exp = messageBody.getMessageExpiration();
|
||||||
|
|
||||||
if (_log.shouldDebug())
|
if (_log.shouldDebug())
|
||||||
@ -180,15 +183,13 @@ public class InNetMessagePool implements Service {
|
|||||||
_context.statManager().addRateData("inNetPool.dropped", 1);
|
_context.statManager().addRateData("inNetPool.dropped", 1);
|
||||||
// FIXME not necessarily a duplicate, could be expired too long ago / too far in future
|
// FIXME not necessarily a duplicate, could be expired too long ago / too far in future
|
||||||
_context.statManager().addRateData("inNetPool.duplicate", 1);
|
_context.statManager().addRateData("inNetPool.duplicate", 1);
|
||||||
_context.messageHistory().droppedOtherMessage(messageBody, (fromRouter != null ? fromRouter.calculateHash() : fromRouterHash));
|
if (doHistory) {
|
||||||
_context.messageHistory().messageProcessingError(messageBody.getUniqueId(),
|
history.droppedOtherMessage(messageBody, (fromRouter != null ? fromRouter.calculateHash() : fromRouterHash));
|
||||||
|
history.messageProcessingError(messageBody.getUniqueId(),
|
||||||
messageBody.getClass().getSimpleName(),
|
messageBody.getClass().getSimpleName(),
|
||||||
"Duplicate/expired");
|
"Duplicate/expired");
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
|
||||||
_log.debug("Message received [" + messageBody.getUniqueId()
|
|
||||||
+ " expiring on " + exp + "] is NOT a duplicate or exipired");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean jobFound = false;
|
boolean jobFound = false;
|
||||||
@ -219,12 +220,11 @@ public class InNetMessagePool implements Service {
|
|||||||
fromRouterHash);
|
fromRouterHash);
|
||||||
if (job != null) {
|
if (job != null) {
|
||||||
_context.jobQueue().addJob(job);
|
_context.jobQueue().addJob(job);
|
||||||
jobFound = true;
|
|
||||||
} else {
|
} else {
|
||||||
// ok, we may not have *found* a job, per se, but we could have, the
|
// ok, we may not have *found* a job, per se, but we could have, the
|
||||||
// job may have just executed inline
|
// job may have just executed inline
|
||||||
jobFound = true;
|
|
||||||
}
|
}
|
||||||
|
jobFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -237,7 +237,8 @@ public class InNetMessagePool implements Service {
|
|||||||
// not handled as a reply
|
// not handled as a reply
|
||||||
if (!jobFound) {
|
if (!jobFound) {
|
||||||
// was not handled via HandlerJobBuilder
|
// was not handled via HandlerJobBuilder
|
||||||
_context.messageHistory().droppedOtherMessage(messageBody, (fromRouter != null ? fromRouter.calculateHash() : fromRouterHash));
|
if (doHistory)
|
||||||
|
history.droppedOtherMessage(messageBody, (fromRouter != null ? fromRouter.calculateHash() : fromRouterHash));
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DeliveryStatusMessage.MESSAGE_TYPE:
|
case DeliveryStatusMessage.MESSAGE_TYPE:
|
||||||
@ -253,9 +254,12 @@ public class InNetMessagePool implements Service {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DatabaseSearchReplyMessage.MESSAGE_TYPE:
|
case DatabaseSearchReplyMessage.MESSAGE_TYPE:
|
||||||
if (_log.shouldLog(Log.INFO))
|
// This is normal.
|
||||||
_log.info("Dropping slow db lookup response: " + messageBody);
|
// The three netdb selectors,
|
||||||
_context.statManager().addRateData("inNetPool.droppedDbLookupResponseMessage", 1);
|
// FloodOnlyLookupSelector, IterativeLookupSelector, and SearchMessageSelector
|
||||||
|
// never return true from isMatch() for a DSRM.
|
||||||
|
// IterativeLookupSelector.isMatch() queues a new IterativeLookupJob
|
||||||
|
// to fetch the responses.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DatabaseLookupMessage.MESSAGE_TYPE:
|
case DatabaseLookupMessage.MESSAGE_TYPE:
|
||||||
@ -273,19 +277,23 @@ public class InNetMessagePool implements Service {
|
|||||||
break;
|
break;
|
||||||
} // switch
|
} // switch
|
||||||
} else {
|
} else {
|
||||||
String mtype = messageBody.getClass().getName();
|
if (doHistory) {
|
||||||
_context.messageHistory().receiveMessage(mtype, messageBody.getUniqueId(),
|
String mtype = messageBody.getClass().getName();
|
||||||
|
history.receiveMessage(mtype, messageBody.getUniqueId(),
|
||||||
messageBody.getMessageExpiration(),
|
messageBody.getMessageExpiration(),
|
||||||
fromRouterHash, true);
|
fromRouterHash, true);
|
||||||
|
}
|
||||||
return 0; // no queue
|
return 0; // no queue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String mtype = messageBody.getClass().getName();
|
if (doHistory) {
|
||||||
_context.messageHistory().receiveMessage(mtype, messageBody.getUniqueId(),
|
String mtype = messageBody.getClass().getName();
|
||||||
|
history.receiveMessage(mtype, messageBody.getUniqueId(),
|
||||||
messageBody.getMessageExpiration(),
|
messageBody.getMessageExpiration(),
|
||||||
fromRouterHash, true);
|
fromRouterHash, true);
|
||||||
|
}
|
||||||
return 0; // no queue
|
return 0; // no queue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,15 +44,17 @@ class IterativeLookupSelector implements MessageSelector {
|
|||||||
// is it worth making sure the reply came in on the right tunnel?
|
// is it worth making sure the reply came in on the right tunnel?
|
||||||
if (_search.getKey().equals(dsm.getKey())) {
|
if (_search.getKey().equals(dsm.getKey())) {
|
||||||
_matchFound = true;
|
_matchFound = true;
|
||||||
|
if (_log.shouldDebug())
|
||||||
|
_log.debug(_search.getJobId() + ": DSM match " + this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (type == DatabaseSearchReplyMessage.MESSAGE_TYPE) {
|
} else if (type == DatabaseSearchReplyMessage.MESSAGE_TYPE) {
|
||||||
DatabaseSearchReplyMessage dsrm = (DatabaseSearchReplyMessage)message;
|
DatabaseSearchReplyMessage dsrm = (DatabaseSearchReplyMessage)message;
|
||||||
if (_search.getKey().equals(dsrm.getSearchKey())) {
|
if (_search.getKey().equals(dsrm.getSearchKey())) {
|
||||||
// Got a netDb reply pointing us at other floodfills...
|
// Got a netDb reply pointing us at other floodfills...
|
||||||
if (_log.shouldLog(Log.INFO)) {
|
if (_log.shouldDebug()) {
|
||||||
Hash from = dsrm.getFromHash();
|
Hash from = dsrm.getFromHash();
|
||||||
_log.info(_search.getJobId() + ": Processing DSRM via IterativeLookupJob, apparently from " + from);
|
_log.debug(_search.getJobId() + ": Processing DSRM via IterativeLookupJob, apparently from " + from + ' ' + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// was inline, now in IterativeLookupJob due to deadlocks
|
// was inline, now in IterativeLookupJob due to deadlocks
|
||||||
|
@ -65,10 +65,6 @@ class SearchMessageSelector implements MessageSelector {
|
|||||||
public long getExpiration() { return _exp; }
|
public long getExpiration() { return _exp; }
|
||||||
|
|
||||||
public boolean isMatch(I2NPMessage message) {
|
public boolean isMatch(I2NPMessage message) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
|
||||||
_log.debug("[" + _id + "] isMatch("+message.getClass().getName()
|
|
||||||
+ ") [want dbStore or dbSearchReply from " + _peer
|
|
||||||
+ " for " + _state.getTarget() + "]");
|
|
||||||
int type = message.getType();
|
int type = message.getType();
|
||||||
if (type == DatabaseStoreMessage.MESSAGE_TYPE) {
|
if (type == DatabaseStoreMessage.MESSAGE_TYPE) {
|
||||||
DatabaseStoreMessage msg = (DatabaseStoreMessage)message;
|
DatabaseStoreMessage msg = (DatabaseStoreMessage)message;
|
||||||
@ -79,10 +75,6 @@ class SearchMessageSelector implements MessageSelector {
|
|||||||
+ "but DBStore doesn't include that info");
|
+ "but DBStore doesn't include that info");
|
||||||
_found = true;
|
_found = true;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
|
||||||
_log.debug("[" + _id + "] DBStore of a key we're not looking for");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} else if (type == DatabaseSearchReplyMessage.MESSAGE_TYPE) {
|
} else if (type == DatabaseSearchReplyMessage.MESSAGE_TYPE) {
|
||||||
DatabaseSearchReplyMessage msg = (DatabaseSearchReplyMessage)message;
|
DatabaseSearchReplyMessage msg = (DatabaseSearchReplyMessage)message;
|
||||||
@ -93,21 +85,9 @@ class SearchMessageSelector implements MessageSelector {
|
|||||||
+ "checking with for a key we're looking for");
|
+ "checking with for a key we're looking for");
|
||||||
_found = true;
|
_found = true;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
|
||||||
_log.debug("[" + _id + "] Was a DBSearchReply from who we're checking "
|
|
||||||
+ "with but NOT for the key we're looking for");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
|
||||||
_log.debug("[" + _id + "] DBSearchReply from someone we are not checking with ["
|
|
||||||
+ msg.getFromHash() + ", not " + _state.getTarget() + "]");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
//_log.debug("Not a DbStore or DbSearchReply");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,6 @@ class StoreMessageSelector implements MessageSelector {
|
|||||||
public long getExpiration() { return _expiration; }
|
public long getExpiration() { return _expiration; }
|
||||||
|
|
||||||
public boolean isMatch(I2NPMessage message) {
|
public boolean isMatch(I2NPMessage message) {
|
||||||
//if (_log.shouldDebug())
|
|
||||||
// _log.debug(_storeJobId + ": isMatch(" + message.getClass().getSimpleName() + ") [want DSM from "
|
|
||||||
// + _peer + ']');
|
|
||||||
if (message.getType() == DeliveryStatusMessage.MESSAGE_TYPE) {
|
if (message.getType() == DeliveryStatusMessage.MESSAGE_TYPE) {
|
||||||
DeliveryStatusMessage msg = (DeliveryStatusMessage)message;
|
DeliveryStatusMessage msg = (DeliveryStatusMessage)message;
|
||||||
if (msg.getMessageId() == _waitingForId) {
|
if (msg.getMessageId() == _waitingForId) {
|
||||||
@ -49,17 +46,9 @@ class StoreMessageSelector implements MessageSelector {
|
|||||||
_log.info(_storeJobId + ": Found match for the key we're waiting for: " + _waitingForId);
|
_log.info(_storeJobId + ": Found match for the key we're waiting for: " + _waitingForId);
|
||||||
_found = true;
|
_found = true;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
//if (_log.shouldDebug())
|
|
||||||
// _log.debug(_storeJobId + ": DeliveryStatusMessage of " + msg.getMessageId() +
|
|
||||||
// " but waiting for " + _waitingForId);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
//if (_log.shouldLog(Log.DEBUG))
|
|
||||||
// _log.debug(_storeJobId + ": Not a DeliveryStatusMessage");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user