Skip to content

Commit

Permalink
properly fix startup race (again) and fix a bug in threaded hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
inorton committed Jun 1, 2014
1 parent b88b2f8 commit afec091
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
5 changes: 4 additions & 1 deletion CClash.Tests/HashingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ public void ThreadyHashIncludeFilesCacheTest()
var hashes2 = ht.DigestFiles(Directory.GetFiles(IncludeDir));
foreach (var h in hashes2)
{
Assert.IsTrue(h.Value.Cached);
if (hashes.ContainsKey(h.Key))
{
Assert.IsTrue(h.Value.Cached);
}
}
}
}
Expand Down
16 changes: 14 additions & 2 deletions CClash/CClashServerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void Connect()
p.Start();
Logging.Error("started new cclash service process");
System.Threading.Thread.Sleep(1000);
Logging.Error("connecting to cclash service");
ConnectClient();
} catch (Exception e) {
Logging.Emit("error starting cclash server process {0}", e.ToString());
Expand All @@ -78,8 +79,19 @@ void Connect()

private void ConnectClient()
{
if (!ncs.IsConnected)
ncs.Connect(1000);
for (int i = 0; i < 6; i++)
{
try
{
if (!ncs.IsConnected)
ncs.Connect(500);
break;
}
catch (TimeoutException)
{
if (i == 5) throw;
}
}
ncs.ReadMode = PipeTransmissionMode.Message;
}

Expand Down
9 changes: 5 additions & 4 deletions CClash/HashUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,15 @@ public Dictionary<string,DataHash> DigestFiles(IEnumerable<string> files)

foreach (var f in files.Distinct())
{
if (recentHashes.ContainsKey(f) && (recentHashes[f].Age.TotalMinutes < SavedHashMaxAgeMinutes))
var filepath = f.ToLower();
if (recentHashes.ContainsKey(filepath) && (recentHashes[filepath].Age.TotalMinutes < SavedHashMaxAgeMinutes))
{
rv[f] = recentHashes[f];
rv[f].Cached = true;
rv[filepath] = recentHashes[filepath];
rv[filepath].Cached = true;
}
else
{
tohash.Add(f);
tohash.Add(filepath);
}
}

Expand Down
Binary file modified Installer/Installer/Express/DVD-5/DiskImages/DISK1/CClash.msi
Binary file not shown.
Binary file modified Installer/Installer/Express/DVD-5/DiskImages/DISK1/Setup.ini
Binary file not shown.

0 comments on commit afec091

Please sign in to comment.