Skip to content

Commit

Permalink
Alternative method.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaneMcC committed Feb 4, 2016
1 parent a23c571 commit 4f8a72a
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions irc/src/com/dmdirc/parser/irc/IRCParser.java
Expand Up @@ -231,8 +231,8 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
private final Map<String, CapabilityState> capabilities = new HashMap<>();
/** Handler for whois responses. */
private final WhoisResponseHandler whoisHandler;
/** Semaphore for calls to resetState. */
private final Semaphore resetStateSem = new Semaphore(1);
/** Used to synchronize calls to resetState. */
private final Object resetStateSync = new Object();

/**
* Default constructor, ServerInfo and MyInfo need to be added separately (using IRC.me and IRC.server).
Expand Down Expand Up @@ -594,9 +594,9 @@ protected void callConnectError(final ParserError errorInfo) {
protected void callSocketClosed() {
// Don't allow state resetting whilst there may be handlers requiring
// state.
resetStateSem.acquireUninterruptibly();
getCallbackManager().publish(new SocketCloseEvent(this, new Date()));
resetStateSem.release();
synchronized (resetStateSync) {
getCallbackManager().publish(new SocketCloseEvent(this, new Date()));
}
}

/**
Expand Down Expand Up @@ -649,38 +649,38 @@ protected synchronized void callPost005() {
//---------------------------------------------------------------------------
/** Reset internal state (use before doConnect). */
private void resetState() {
resetStateSem.acquireUninterruptibly();
// Reset General State info
got001 = false;
post005 = false;
// Clear the hash tables
channelList.clear();
clientList.clear();
h005Info.clear();
prefixModes.clear();
chanModesOther.clear();
chanModesBool.clear();
userModes.clear();
chanPrefix = DEFAULT_CHAN_PREFIX;
// Clear output queue.
if (out != null) {
out.clearQueue();
}
setServerName("");
networkName = "";
lastLine = null;
myself = new IRCClientInfo(this, userModes, "myself").setFake(true);
synchronized (resetStateSync) {
// Reset General State info
got001 = false;
post005 = false;
// Clear the hash tables
channelList.clear();
clientList.clear();
h005Info.clear();
prefixModes.clear();
chanModesOther.clear();
chanModesBool.clear();
userModes.clear();
chanPrefix = DEFAULT_CHAN_PREFIX;
// Clear output queue.
if (out != null) {
out.clearQueue();
}
setServerName("");
networkName = "";
lastLine = null;
myself = new IRCClientInfo(this, userModes, "myself").setFake(true);

synchronized (serverInformationLines) {
serverInformationLines.clear();
}
stopPingTimer();
synchronized (serverInformationLines) {
serverInformationLines.clear();
}
stopPingTimer();

currentSocketState = SocketState.CLOSED;
setEncoding(IRCEncoding.RFC1459);
currentSocketState = SocketState.CLOSED;
setEncoding(IRCEncoding.RFC1459);

whoisHandler.stop();
resetStateSem.release();
whoisHandler.stop();
}
}

/**
Expand Down

0 comments on commit 4f8a72a

Please sign in to comment.