Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Added extra isActive() during establishment check, improved log rotat…
Browse files Browse the repository at this point in the history
…ion.
  • Loading branch information
SpaceManiac committed May 28, 2014
1 parent fe51140 commit 9287485
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/main/java/net/glowstone/ConsoleManager.java
Expand Up @@ -390,7 +390,8 @@ private void checkRotate() {
String newFilename = calculateFilename();
if (!filename.equals(newFilename)) {
filename = newFilename;
logger.log(Level.INFO, "Log rotating to {0}...", filename);
// note that the console handler doesn't see this message
super.publish(new LogRecord(Level.INFO, "Log rotating to: " + filename));
updateOutput();
}
}
Expand All @@ -407,7 +408,7 @@ public synchronized void publish(LogRecord record) {
}
checkRotate();
super.publish(record);
flush();
super.flush();
}

@Override
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/net/glowstone/net/GlowSession.java
Expand Up @@ -216,6 +216,15 @@ public void setPlayer(GlowPlayer player) {

// login event
this.player = player;
// isActive check here in case player disconnected after authentication,
// but before the GlowPlayer initialization was completed
if (!isActive()) {
// todo: we might be racing with the network thread here,
// could cause onDisconnect() logic to happen twice
onDisconnect();
return;
}

PlayerLoginEvent event = EventFactory.onPlayerLogin(player);
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
disconnect(event.getKickMessage(), true);
Expand Down Expand Up @@ -401,10 +410,8 @@ public void onInboundThrowable(Throwable t) {

@Override
public void onOutboundThrowable(Throwable t) {
if (t.getClass() == IOException.class && "Broken pipe".equals(t.getMessage())) {
GlowServer.logger.log(Level.WARNING, "Error in network output: Broken pipe");
} else if (t.getClass() == ClosedChannelException.class) {
GlowServer.logger.log(Level.WARNING, "Error in network output: Closed channel");
if (t instanceof IOException && !isActive()) {
GlowServer.logger.log(Level.WARNING, "Error in output for inactive session: " + t);
} else {
GlowServer.logger.log(Level.SEVERE, "Error in network output", t);
}
Expand Down
Expand Up @@ -153,6 +153,8 @@ public void run() {
session.getServer().getScheduler().runTask(null, new Runnable() {
@Override
public void run() {
// isActive check here to break out early if player has disconnected
// while waiting to be logged in
if (session.isActive()) {
session.setPlayer(new GlowPlayer(session, name, uuid, properties));
}
Expand Down

0 comments on commit 9287485

Please sign in to comment.