listener tcp: Catch more exceptions and increase poll/ping interval. Fixes #734

This commit is contained in:
Hylke Bons 2012-05-20 14:28:14 +01:00
parent ea432c32e8
commit 6a0ee9ed63
2 changed files with 10 additions and 12 deletions

View file

@ -111,7 +111,7 @@ namespace SparkleLib {
try {
// We've timed out, let's ping the server to
// see if the connection is still up
if (i == 180) {
if (i == 300) {
SparkleHelpers.DebugInfo ("ListenerTcp",
"Pinging " + Server);
@ -125,8 +125,7 @@ namespace SparkleLib {
// 10057 means "Socket is not connected"
throw new SocketException (10057);
SparkleHelpers.DebugInfo ("ListenerTcp",
"Received pong from " + Server);
SparkleHelpers.DebugInfo ("ListenerTcp", "Received pong from " + Server);
i = 0;
this.last_ping = DateTime.Now;
@ -143,8 +142,7 @@ namespace SparkleLib {
);
if (sleepiness <= 0) {
SparkleHelpers.DebugInfo ("ListenerTcp",
"System woke up from sleep");
SparkleHelpers.DebugInfo ("ListenerTcp", "System woke up from sleep");
// 10057 means "Socket is not connected"
throw new SocketException (10057);
@ -152,7 +150,7 @@ namespace SparkleLib {
}
// The ping failed: disconnect completely
} catch (SocketException) {
} catch (SocketException e) {
this.is_connected = false;
this.is_connecting = false;
@ -161,7 +159,7 @@ namespace SparkleLib {
this.socket = null;
}
OnDisconnected ("Ping timeout");
OnDisconnected ("Ping timeout: " + e.Message);
return;
}
@ -169,7 +167,7 @@ namespace SparkleLib {
i++;
}
} catch (ObjectDisposedException) {
} catch (Exception) {
return;
}

View file

@ -37,13 +37,13 @@ namespace SparkleLib {
public abstract class SparkleRepoBase {
private string identifier;
private TimeSpan short_interval = new TimeSpan (0, 0, 3, 0);
private TimeSpan long_interval = new TimeSpan (0, 0, 10, 0);
private TimeSpan short_interval = new TimeSpan (0, 0, 5, 0);
private TimeSpan long_interval = new TimeSpan (0, 0, 15, 0);
private TimeSpan poll_interval;
private SparkleWatcher watcher;
private SparkleListenerBase listener;
private System.Timers.Timer local_timer = new System.Timers.Timer () { Interval = 0.25 * 1000 };
private System.Timers.Timer remote_timer = new System.Timers.Timer () { Interval = 10 * 1000 };
private System.Timers.Timer remote_timer = new System.Timers.Timer () { Interval = 5 * 1000 };
private DateTime last_poll = DateTime.Now;
private List<double> size_buffer = new List<double> ();
private Object change_lock = new Object ();
@ -583,7 +583,7 @@ namespace SparkleLib {
return 0;
try {
foreach (FileInfo file in parent.GetFiles()) {
foreach (FileInfo file in parent.GetFiles ()) {
if (!file.Exists)
return 0;