From 2a50f6190b6c0cc80888c530a60a176d2cc1dc3e Mon Sep 17 00:00:00 2001 From: Britta Heymann <britta_hey@web.de> Date: Fri, 8 Sep 2017 08:44:47 +0200 Subject: [PATCH] Prevent calling getPredFor on broadcasts --- src/routing/ProphetRouter.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/routing/ProphetRouter.java b/src/routing/ProphetRouter.java index 11ce70e2..62a9f224 100644 --- a/src/routing/ProphetRouter.java +++ b/src/routing/ProphetRouter.java @@ -12,6 +12,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import core.BroadcastMessage; import core.DataMessage; import core.MulticastMessage; import routing.util.DatabaseApplicationUtil; @@ -285,8 +286,12 @@ public class ProphetRouter extends ActiveRouter { availableConnections.add(con); for (Message m : msgCollection) { - if (othRouter.hasMessage(m.getId())) { - continue; // skip messages that the other one has + if (othRouter.hasMessage(m.getId()) || m instanceof BroadcastMessage) { + // Ignore both messages that the other one has and all broadcast messages. + // (Broadcasts should be sent via exchangeDeliverableMessages.) + // The latter check may not be caught by the former because of caching (direct messages may be + // sent belatedly; see explanation at ActiveRouter#cachedMessagesForConnected.). + continue; } if (othRouter.getPredFor(m) > getPredFor(m)) { // the other node has higher probability of delivery -- GitLab