From ae0547a0ff4cbf96a62ad78e4aeae2e4546a5b81 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Mon, 2 May 2005 18:52:20 +0000 Subject: [PATCH] Cope with the bug we observed this morning as best we can, shut down the conmgr (and in so doing, the entire server). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3534 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/server/net/ConnectionManager.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/java/com/threerings/presents/server/net/ConnectionManager.java b/src/java/com/threerings/presents/server/net/ConnectionManager.java index f61839052..61e9014ba 100644 --- a/src/java/com/threerings/presents/server/net/ConnectionManager.java +++ b/src/java/com/threerings/presents/server/net/ConnectionManager.java @@ -417,7 +417,22 @@ public class ConnectionManager extends LoopingThread } catch (IOException ioe) { Log.warning("Failure select()ing [ioe=" + ioe + "]."); return; + + } catch (RuntimeException re) { + // this block of code deals with a bug in the _selector that + // we observed on 2005-05-02, instead of looping indefinitely + // after things go pear-shaped, shut us down in an orderly + // fashion + Log.warning("Failure select()ing [re=" + re + "]."); + Log.logStackTrace(re); + if (_runtimeExceptionCount++ >= 20) { + Log.warning("Too many errors, bailing."); + shutdown(); + } + return; } + // clear the runtime error count + _runtimeExceptionCount = 0; // process those events // Log.info("Ready set " + StringUtil.toString(ready) + "."); @@ -804,6 +819,9 @@ public class ConnectionManager extends LoopingThread protected ServerSocketChannel _listener; protected ResultListener _startlist; + /** Counts consecutive runtime errors in select(). */ + protected int _runtimeExceptionCount; + /** Maps selection keys to network event handlers. */ protected HashMap _handlers = new HashMap();