Update the thread-local storage patch, to fix #335178
[beagle.git] / beagled / Lucene.Net / upstream-changes / 15_lock-timeout-verbose.patch
blobc57430adfe9a80ad4a46dc13ac961c2e7341ddb0
1 From: Daniel Drake <dsd@gentoo.org>
3 When lock obtain times out, do a little bit of automatic investigation into
4 the possibly-stale lockfile.
6 Index: Store/FSDirectory.cs
7 ===================================================================
8 RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Store/FSDirectory.cs,v
9 retrieving revision 1.13
10 diff -u -B -p -r1.13 FSDirectory.cs
11 --- Store/FSDirectory.cs 27 Oct 2005 20:10:34 -0000 1.13
12 +++ Store/FSDirectory.cs 31 Oct 2005 00:33:43 -0000
13 @@ -130,7 +130,7 @@ namespace Lucene.Net.Store
15 public override System.String ToString()
17 - return "Lock@" + lockFile;
18 + return lockFile.FullName;
21 /// <summary>This cache of directories ensures that there is a unique Directory
22 Index: Store/Lock.cs
23 ===================================================================
24 RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Store/Lock.cs,v
25 retrieving revision 1.5
26 diff -u -B -p -r1.5 Lock.cs
27 --- Store/Lock.cs 29 Oct 2005 15:15:26 -0000 1.5
28 +++ Store/Lock.cs 31 Oct 2005 00:33:43 -0000
29 @@ -66,7 +66,27 @@ namespace Lucene.Net.Store
31 if (sleepCount == maxSleepCount)
33 - throw new System.IO.IOException("Lock obtain timed out: " + this.ToString());
34 + // Try and be a little more verbose on failure
35 + string lockpath = this.ToString ();
36 + System.Text.StringBuilder ex = new System.Text.StringBuilder();
37 + ex.Append ("Lock obain timed out: ");
38 + ex.Append (lockpath);
39 + if (System.IO.File.Exists (lockpath)) {
40 + System.IO.FileStream fs = System.IO.File.Open (lockpath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
41 + System.IO.StreamReader sr = new System.IO.StreamReader (fs);
42 + string pid = sr.ReadToEnd ().Trim ();
43 + sr.Close ();
44 + fs.Close ();
45 + ex.Append (" -- pid ").Append (pid);
47 + if (System.IO.Directory.Exists ("/proc/" + pid))
48 + ex.Append (" -- process exists");
49 + else
50 + ex.Append (" -- process does not exist, stale lockfile?");
51 + } else {
52 + ex.Append (" -- lock file doesn't exist!?");
53 + }
54 + throw new System.IO.IOException(ex.ToString ());
56 ++sleepCount;