From 6c3d9fba65f794ed7a7946148d66ed2e98ae325d Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Sun, 22 Dec 2002 19:16:31 +0000 Subject: [PATCH] More goddamned fiddling to attempt to respond gracefully to any of the wide variety of fucked up situations that might occur: - Client authenticates and disconnects before their client object is resolved. - Client authenticates and requests to end their session before their client is resolved. - Client does one of the two previous actions and then attempts to reestablish a session before the client object is resolved from their first connection attempt. - Client establishes a session in any of the previous or a normal circumstance but their client object fails to resolve. Goddamned distributed programming, race-condition cluster fuck, strange shit happening once in a blue moon business. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2086 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/server/PresentsClient.java | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/java/com/threerings/presents/server/PresentsClient.java b/src/java/com/threerings/presents/server/PresentsClient.java index 748b047fc..296a39304 100644 --- a/src/java/com/threerings/presents/server/PresentsClient.java +++ b/src/java/com/threerings/presents/server/PresentsClient.java @@ -1,9 +1,10 @@ // -// $Id: PresentsClient.java,v 1.48 2002/12/15 18:32:19 mdb Exp $ +// $Id: PresentsClient.java,v 1.49 2002/12/22 19:16:31 mdb Exp $ package com.threerings.presents.server; import java.io.IOException; +import java.net.InetAddress; import java.util.HashMap; import java.util.Iterator; @@ -116,6 +117,16 @@ public class PresentsClient return _username; } + /** + * Returns the address of the connected client or null if this client + * is not connected. + */ + public InetAddress getInetAddress () + { + Connection conn = getConnection(); + return (conn == null) ? null : conn.getInetAddress(); + } + /** * Danger: this method is not for general consumption. This * changes the username of the client, but should only be done very @@ -353,11 +364,15 @@ public class PresentsClient PresentsServer.conmgr.closeConnection(conn); } - // and clean up after ourselves - sessionDidEnd(); + // if we don't have a client object, we failed to resolve in the + // first place, in which case we have to cope as best we can + if (_clobj != null) { + // and clean up after ourselves + sessionDidEnd(); - // release (and destroy) our client object - _cmgr.releaseClientObject(_username); + // release (and destroy) our client object + _cmgr.releaseClientObject(_username); + } // let the client manager know that we're audi 5000 _cmgr.clientDidEndSession(this); @@ -775,8 +790,15 @@ public class PresentsClient // can safely end the session PresentsServer.omgr.postUnit(new Runnable() { public void run () { - // end the session in a civilized manner - client.endSession(); + if (client.getClientObject() == null) { + // refuse to end the session unless the client is + // fully resolved + Log.warning("Refusing logoff request from " + + "still-resolving client " + client + "."); + } else { + // end the session in a civilized manner + client.endSession(); + } } }); }