public static void processKeys(Object id, Set<SelectionKey> keySet, SelectorManager2 mgr) {
		Iterator<SelectionKey> iter = keySet.iterator();
		while (iter.hasNext()) {
			SelectionKey key = null;
			try {
				key = iter.next();
				if(log.isLoggable(Level.FINE))
					log.fine(key.attachment()+" ops="+Helper.opType(key.readyOps())
							+" acc="+key.isAcceptable()+" read="+key.isReadable()+" write"+key.isWritable());
				processKey(id, key, mgr);
//			} catch(CancelledKeyException e) {
//				log.log(Level.INFO, "Cancelled key may be normal", e);
			} catch(IOException e) {
				log.log(Level.WARNING, id+""+key.attachment()+"Processing of key failed, closing channel", e);
				try {
					if(key != null) 
						key.channel().close();
				} catch(Throwable ee) {
					log.log(Level.WARNING, id+""+key.attachment()+"Close of channel failed", ee);
				}
			} catch(CancelledKeyException e) {
				//TODO: get rid of this if...else statement by fixing
				//CancelledKeyException on linux so the tests don't fail				
				log.log(Level.FINE, id+""+key.attachment()+"Processing of key failed, but continuing channel manager loop", e);				
			} catch(Throwable e) {
				log.log(Level.WARNING, id+""+key.attachment()+"Processing of key failed, but continuing channel manager loop", e);
				try {
					key.cancel();
				} catch(Throwable ee) {}
			}
		}
		//clear the whole keySet as we processed them all in the while loop.

		//If you do not clear the keySet, keys that have been already processed stay
		//in the selected Key set.  If another key gets added to this set, the selector
		//goes off again and has the stale key plus the new key and the stale key
		//is processed again.
		keySet.clear();
	}