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.
This commit is contained in:
Ray J. Greenwell
2012-08-08 15:04:05 -07:00
parent 78515ffcdb
commit 24a5800536
@@ -62,6 +62,7 @@ import com.threerings.presents.annotation.PeerInvoker;
import com.threerings.presents.client.Client; import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationCodes;
import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.ObjectAccessException; import com.threerings.presents.dobj.ObjectAccessException;
import com.threerings.presents.dobj.Subscriber; import com.threerings.presents.dobj.Subscriber;
@@ -320,9 +321,9 @@ public abstract class PeerManager
String nodeName, String sharedSecret, String hostName, String publicHostName, String nodeName, String sharedSecret, String hostName, String publicHostName,
String region, int port, String nodeNamespace) String region, int port, String nodeNamespace)
{ {
_nodeNamespace = nodeNamespace;
_nodeName = nodeName; _nodeName = nodeName;
_sharedSecret = sharedSecret; _sharedSecret = sharedSecret;
_nodeNamespace = nodeNamespace;
// wire ourselves into the server // wire ourselves into the server
_conmgr.addChainedAuthenticator( _conmgr.addChainedAuthenticator(
@@ -494,7 +495,12 @@ public abstract class PeerManager
{ {
PeerNode peer = _peers.get(nodeName); PeerNode peer = _peers.get(nodeName);
if (peer != null) { if (peer != null) {
if (peer.nodeobj != null) {
peer.nodeobj.peerService.invokeAction(flattenAction(action)); peer.nodeobj.peerService.invokeAction(flattenAction(action));
} else {
log.warning("Dropped NodeAction", "nodeName", nodeName, "action", action);
}
} else if (Objects.equal(nodeName, _nodeName)) { } else if (Objects.equal(nodeName, _nodeName)) {
invokeAction(null, flattenAction(action)); invokeAction(null, flattenAction(action));
} }
@@ -566,7 +572,7 @@ public abstract class PeerManager
nodes.add(_nodeobj.nodeName); nodes.add(_nodeobj.nodeName);
} }
for (PeerNode peer : _peers.values()) { for (PeerNode peer : _peers.values()) {
if (applicant.isApplicable(peer.nodeobj)) { if (peer.nodeobj != null && applicant.isApplicable(peer.nodeobj)) {
nodes.add(peer.getNodeName()); nodes.add(peer.getNodeName());
} }
} }
@@ -1508,7 +1514,14 @@ public abstract class PeerManager
{ {
PeerNode peer = _peers.get(nodeName); PeerNode peer = _peers.get(nodeName);
if (peer != null) { if (peer != null) {
if (peer.nodeobj != null) {
peer.nodeobj.peerService.invokeRequest(requestBytes, listener); peer.nodeobj.peerService.invokeRequest(requestBytes, listener);
} else {
log.warning("Dropped NodeRequest", "nodeName", nodeName);
listener.requestFailed(InvocationCodes.INTERNAL_ERROR);
}
} else if (Objects.equal(nodeName, _nodeName)) { } else if (Objects.equal(nodeName, _nodeName)) {
invokeRequest(null, requestBytes, listener); invokeRequest(null, requestBytes, listener);
} }