Nixed premature optimization wherein a frequent premature optimizer, who we

will not name, was trying to allow certain authentications to proceed directly
on the authenticator thread instead of making a round trip through the
invoker. This resulted in those authentications trying to post their results
from the authenticator thread, which is bad because all downstream messages
should be posted from the distributed object thread.

The only authentications that would "benefit" from this optimization were peer
authentications of which there would be extremely few (currently one in our
largest installation) compared to the hundreds of thousands of normal
authentications, which have to make the invoker thread round trip as a matter
of course.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4655 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2007-04-07 19:57:51 +00:00
parent 558d9ec2dc
commit 9d5cf32ce0
3 changed files with 12 additions and 39 deletions
@@ -38,14 +38,14 @@ import com.threerings.presents.peer.net.PeerCreds;
import static com.threerings.presents.Log.log; import static com.threerings.presents.Log.log;
/** /**
* Handles authentication of peer servers and passes non-peer authentication * Handles authentication of peer servers and passes non-peer authentication requests through to a
* requests through to a normal authenticator. * normal authenticator.
*/ */
public class PeerAuthenticator extends Authenticator public class PeerAuthenticator extends Authenticator
{ {
/** /**
* Creates an authenticator that will handle peer authentications and pass * Creates an authenticator that will handle peer authentications and pass non-peer
* non-peer authentications through to the supplied delegate. * authentications through to the supplied delegate.
*/ */
public PeerAuthenticator (PeerManager nodemgr, Authenticator delegate) public PeerAuthenticator (PeerManager nodemgr, Authenticator delegate)
{ {
@@ -67,18 +67,8 @@ public class PeerAuthenticator extends Authenticator
} }
} }
@Override
protected Invoker getInvoker ()
{
// The processing of peer authentication happens inline,
// but other authentication will use the _delegate which will
// probably use an Invoker.
return null;
}
// from abstract Authenticator // from abstract Authenticator
protected void processAuthentication ( protected void processAuthentication (AuthingConnection conn, AuthResponse rsp)
AuthingConnection conn, AuthResponse rsp)
throws PersistenceException throws PersistenceException
{ {
// here, we are ONLY authenticating peers // here, we are ONLY authenticating peers
@@ -89,8 +79,7 @@ public class PeerAuthenticator extends Authenticator
rsp.getData().code = AuthResponseData.SUCCESS; rsp.getData().code = AuthResponseData.SUCCESS;
} else { } else {
log.warning("Received invalid peer auth request? " + log.warning("Received invalid peer auth request? [creds=" + pcreds + "].");
"[creds=" + pcreds + "].");
rsp.getData().code = AuthCodes.SERVER_ERROR; rsp.getData().code = AuthCodes.SERVER_ERROR;
} }
} }
@@ -32,20 +32,12 @@ import com.threerings.presents.server.net.AuthingConnection;
import static com.threerings.presents.Log.log; import static com.threerings.presents.Log.log;
/** /**
* A simple authenticator implementation that simply accepts all * A simple authenticator implementation that simply accepts all authentication requests.
* authentication requests.
*/ */
public class DummyAuthenticator extends Authenticator public class DummyAuthenticator extends Authenticator
{ {
@Override
protected Invoker getInvoker ()
{
return null; // not needed
}
// from abstract Authenticator // from abstract Authenticator
protected void processAuthentication ( protected void processAuthentication (AuthingConnection conn, AuthResponse rsp)
AuthingConnection conn, AuthResponse rsp)
throws PersistenceException throws PersistenceException
{ {
log.info("Accepting request: " + conn.getAuthRequest()); log.info("Accepting request: " + conn.getAuthRequest());
@@ -36,8 +36,8 @@ import com.threerings.presents.server.net.AuthingConnection;
import static com.threerings.presents.Log.log; import static com.threerings.presents.Log.log;
/** /**
* A simple server that does nothing more than spit out a canned error * A simple server that does nothing more than spit out a canned error response to everyone who
* response to everyone who logs in. * logs in.
*/ */
public class Rejector extends PresentsServer public class Rejector extends PresentsServer
{ {
@@ -80,20 +80,12 @@ public class Rejector extends PresentsServer
} }
/** /**
* An authenticator implementation that refuses all authentication * An authenticator implementation that refuses all authentication requests.
* requests.
*/ */
protected class RejectingAuthenticator extends Authenticator protected class RejectingAuthenticator extends Authenticator
{ {
@Override
protected Invoker getInvoker ()
{
return null;
}
// from abstract Authenticator // from abstract Authenticator
protected void processAuthentication ( protected void processAuthentication (AuthingConnection conn, AuthResponse rsp)
AuthingConnection conn, AuthResponse rsp)
throws PersistenceException throws PersistenceException
{ {
log.info("Rejecting request: " + conn.getAuthRequest()); log.info("Rejecting request: " + conn.getAuthRequest());