Index: C:/workspace/L2_GameServer/java/net/sf/l2j/gameserver/SelectorThread.java =================================================================== --- C:/workspace/L2_GameServer/java/net/sf/l2j/gameserver/SelectorThread.java (revision 1718) +++ C:/workspace/L2_GameServer/java/net/sf/l2j/gameserver/SelectorThread.java (working copy) @@ -73,9 +73,6 @@ */ public final class SelectorThread extends Thread { private static Logger _log = Logger.getLogger(SelectorThread.class.getName()); - private final int SELECT_TIME_MARGIN=20; // decrease of false network stalls reported - // increase if you still get mass disconnects - // max = 100 public static SelectorThread instance; @@ -248,10 +245,7 @@ // wait for read/write, timeout is to be on safe side, // if waking up selector after a message push will fail // this is needed because we are in an infinite loop - long start=System.currentTimeMillis(); int numKeys = _selector.select(50L); - long selector_time=System.currentTimeMillis()-start; - // check for shutdown if (isInterrupted()) @@ -259,15 +253,14 @@ try { _selector.close(); } catch (Throwable t) { _log.log(Level.INFO, "", t); } return; } - - Iterator it = _selector.selectedKeys().iterator(); - if (numKeys==0 && selector_time it = _selector.selectedKeys().iterator(); // iterate over selected keys while (it.hasNext()) { @@ -567,7 +560,10 @@ if (msgCounter > 20 || msg instanceof LeaveWorld) { _selector.wakeup(); if (msgCounter > 1000) - this.setPriority(Thread.NORM_PRIORITY+1); // up + { + _log.warning("SelectorThread: msgCounter="+msgCounter); + this.setPriority(Thread.NORM_PRIORITY+2); // up + } } } @@ -628,7 +624,10 @@ } catch (IOException e) { r = -1; } - if (r < 0 || !sk.isValid()) { + + if(!sk.isValid() && r>=0) _log.warning("mass disc fix: sk.isValid()==false, this would close client connection with data_written="+r); + + if (r < 0 ) { //|| !sk.isValid()) { closeClient(con); return; } @@ -639,7 +638,11 @@ b.flip(); con.writeBuffer = b; con.writeTimeStamp = GameTimeController.getGameTicks(); - sk.interestOps(sk.interestOps() | SelectionKey.OP_WRITE); + if(sk.isValid()) sk.interestOps(sk.interestOps() | SelectionKey.OP_WRITE); + else + { + return; // selection key invalit, what should we do ? just return ? + } } else {