Viewing Issue Advanced Details

ID 0002709 Category [DMDirc] IRC Parser Severity minor
Reproducibility always Date Submitted 2009-07-02 22:40 Last Update 2009-11-21 22:56
Reporter Dataforce Assigned To Dataforce View Status public
Priority normal Status closed Resolution fixed
Platform Fixed in Version Target Version 0.6.3m2
Product Version Product Build
Summary 0002709: Option in parser to disable sending PING for servers that don't respond
Description
Option in parser to disable sending PING for servers that don't respond
Needs unit test no
Upstream Bug URL

Relationships

Notes

authorShane Mc Cormack <shane@dmdirc.com>2009-07-03 19:16:18 (GMT)
commit8b202bf815c6e95d60018ca345bf6a596ad5f488 (patch) (side-by-side diff)
Option to disable ping timer, fixes issue 2709
-rw-r--r--src/com/dmdirc/parser/irc/IRCParser.java60
1 files changed, 50 insertions, 10 deletions
Click to Expand/Collapse
diff src/com/dmdirc/parser/irc/IRCParser.java
@@ -91,10 +91,12 @@ public class IRCParser implements Runnable {
/** Server Info requested by user. */
public ServerInfo server = new ServerInfo();
+ /** Should PINGs be sent to the server to check if its alive? */
+ private boolean checkServerPing = true;
/** Timer for server ping. */
private Timer pingTimer = null;
- /** Semaphore for access to pingTimer. */
- private Semaphore pingTimerSem = new Semaphore(1);
+ /** Semaphore for access to pingTimer. */
+ private Semaphore pingTimerSem = new Semaphore(1);
/** Length of time to wait between ping stuff. */
private long pingTimerLength = 10000;
/** Is a ping needed? */
@@ -586,12 +588,7 @@ public class IRCParser implements Runnable {
lastLine = "";
cMyself = new ClientInfo(this, "myself").setFake(true);
- pingTimerSem.acquireUninterruptibly();
- if (pingTimer != null) {
- pingTimer.cancel();
- pingTimer = null;
- }
- pingTimerSem.release();
+ stopPingTimer();
currentSocketState = SocketState.CLOSED;
// Char Mapping
@@ -1803,6 +1800,28 @@ public class IRCParser implements Runnable {
}
}
+ /**
+ * Get the value of checkServerPing.
+ *
+ * @return value of checkServerPing.
+ * @see setCheckServerPing
+ */
+ public boolean getCheckServerPing() { return checkServerPing; }
+
+ /**
+ * Set the value of checkServerPing.
+ *
+ * @param newValue New value to use.
+ * @see setCheckServerPing
+ */
+ public void setCheckServerPing(final boolean newValue) {
+ checkServerPing = newValue;
+ if (checkServerPing) {
+ startPingTimer();
+ } else {
+ stopPingTimer();
+ }
+ }
/**
* Get the time used for the ping Timer.
@@ -1863,7 +1882,7 @@ public class IRCParser implements Runnable {
* Start the pingTimer.
*/
protected void startPingTimer() {
- pingTimerSem.acquireUninterruptibly();
+ pingTimerSem.acquireUninterruptibly();
setPingNeeded(false);
if (pingTimer != null) { pingTimer.cancel(); }
@@ -1871,7 +1890,19 @@ public class IRCParser implements Runnable {
pingTimer.schedule(new PingTimer(this, pingTimer), 0, pingTimerLength);
pingCountDown = 1;
- pingTimerSem.release();
+ pingTimerSem.release();
+ }
+
+ /**
+ * Stop the pingTimer.
+ */
+ protected void stopPingTimer() {
+ pingTimerSem.acquireUninterruptibly();
+ if (pingTimer != null) {
+ pingTimer.cancel();
+ pingTimer = null;
+ }
+ pingTimerSem.release();
}
/**
@@ -1882,6 +1913,15 @@ public class IRCParser implements Runnable {
* @param timer The timer that called this.
*/
protected void pingTimerTask(final Timer timer) {
+ if (!getCheckServerPing()) {
+ pingTimerSem.acquireUninterruptibly();
+ if (pingTimer != null && pingTimer.equals(timer)) {
+ pingTimer.cancel();
+ }
+ pingTimerSem.release();
+
+ return;
+ }
if (getPingNeeded()) {
if (!callPingFailed()) {
pingTimerSem.acquireUninterruptibly();

Issue History

Date Modified Username Field Change
2009-07-02 22:40 Dataforce New Issue
2009-07-02 22:40 Dataforce Status new => assigned
2009-07-02 22:40 Dataforce Assigned To => Dataforce
2009-07-03 20:58 Dataforce Checkin
2009-07-03 20:58 Dataforce Note Added: 0007086
2009-07-03 20:58 Dataforce Status assigned => resolved
2009-07-03 20:58 Dataforce Resolution open => fixed
2009-11-08 12:53 Greboid Status resolved => closed
2009-11-21 22:56 MD87 Category *Unsorted => IRC Parser