From 24a58005361c714b077be49a4921271b5d10210b Mon Sep 17 00:00:00 2001 From: "Ray J. Greenwell" Date: Wed, 8 Aug 2012 15:04:05 -0700 Subject: [PATCH] More checks for nodes without node objects. When a NodeAction was queried for which nodes were applicable, it filtered out nodes that didn't have a nodeObject. However, when a NodeRequest is similarly queried, null nodeObjects were not filtered out and I guess it was up to the NodeRequest to say "no" to null nodeObjects. This is not part of the API specification for NodeApplicant, and in Spiral Knights we have various requests/actions that simply return true without regard to the contents of the nodeObject. So that's fucking retarded. Do the null check just like it's done for NodeActions. In addition, do an extra check if one of single-node methods is called for an action or request, to make sure that one pre-determined node has a nodeObject set up. If not, log a warning, and return an error response in the NodeRequest case. --- .../presents/peer/server/PeerManager.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java b/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java index 4219c8a80..37c58029d 100644 --- a/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java +++ b/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java @@ -62,6 +62,7 @@ import com.threerings.presents.annotation.PeerInvoker; import com.threerings.presents.client.Client; import com.threerings.presents.client.InvocationService; import com.threerings.presents.data.ClientObject; +import com.threerings.presents.data.InvocationCodes; import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.ObjectAccessException; import com.threerings.presents.dobj.Subscriber; @@ -320,9 +321,9 @@ public abstract class PeerManager String nodeName, String sharedSecret, String hostName, String publicHostName, String region, int port, String nodeNamespace) { - _nodeNamespace = nodeNamespace; _nodeName = nodeName; _sharedSecret = sharedSecret; + _nodeNamespace = nodeNamespace; // wire ourselves into the server _conmgr.addChainedAuthenticator( @@ -494,7 +495,12 @@ public abstract class PeerManager { PeerNode peer = _peers.get(nodeName); if (peer != null) { - peer.nodeobj.peerService.invokeAction(flattenAction(action)); + if (peer.nodeobj != null) { + peer.nodeobj.peerService.invokeAction(flattenAction(action)); + } else { + log.warning("Dropped NodeAction", "nodeName", nodeName, "action", action); + } + } else if (Objects.equal(nodeName, _nodeName)) { invokeAction(null, flattenAction(action)); } @@ -566,7 +572,7 @@ public abstract class PeerManager nodes.add(_nodeobj.nodeName); } for (PeerNode peer : _peers.values()) { - if (applicant.isApplicable(peer.nodeobj)) { + if (peer.nodeobj != null && applicant.isApplicable(peer.nodeobj)) { nodes.add(peer.getNodeName()); } } @@ -1508,7 +1514,14 @@ public abstract class PeerManager { PeerNode peer = _peers.get(nodeName); if (peer != null) { - peer.nodeobj.peerService.invokeRequest(requestBytes, listener); + if (peer.nodeobj != null) { + peer.nodeobj.peerService.invokeRequest(requestBytes, listener); + + } else { + log.warning("Dropped NodeRequest", "nodeName", nodeName); + listener.requestFailed(InvocationCodes.INTERNAL_ERROR); + } + } else if (Objects.equal(nodeName, _nodeName)) { invokeRequest(null, requestBytes, listener); }