beagle r4444 - trunk/beagle/beagled
- From: dbera svn gnome org
- To: svn-commits-list gnome org
- Subject: beagle r4444 - trunk/beagle/beagled
- Date: Sun, 3 Feb 2008 01:00:56 +0000 (GMT)
Author: dbera
Date: Sun Feb 3 01:00:55 2008
New Revision: 4444
URL: http://svn.gnome.org/viewvc/beagle?rev=4444&view=rev
Log:
Recent sqlite changes uncovered a bug in our Sqlite code where the reader was not always closed after reading. Make sure all our Sqlite readers are properly closed.
Modified:
trunk/beagle/beagled/FileAttributesStore_Sqlite.cs
trunk/beagle/beagled/TextCache.cs
Modified: trunk/beagle/beagled/FileAttributesStore_Sqlite.cs
==============================================================================
--- trunk/beagle/beagled/FileAttributesStore_Sqlite.cs (original)
+++ trunk/beagle/beagled/FileAttributesStore_Sqlite.cs Sun Feb 3 01:00:55 2008
@@ -258,8 +258,6 @@
if (path != null && path != "/" && path.EndsWith ("/"))
path = path.TrimEnd ('/');
- SqliteDataReader reader;
-
if (! GetPathFlag (path))
return null;
@@ -272,12 +270,10 @@
lock (connection) {
ReadCommand.Parameters.AddWithValue ("@dir",directory);
ReadCommand.Parameters.AddWithValue ("@fname",filename);
- reader = SqliteUtils.ExecuteReaderOrWait (ReadCommand);
-
- if (SqliteUtils.ReadOrWait (reader))
- attr = GetFromReader (reader);
-
- reader.Close ();
+ using (SqliteDataReader reader = SqliteUtils.ExecuteReaderOrWait (ReadCommand)) {
+ if (SqliteUtils.ReadOrWait (reader))
+ attr = GetFromReader (reader);
+ }
}
return attr;
Modified: trunk/beagle/beagled/TextCache.cs
==============================================================================
--- trunk/beagle/beagled/TextCache.cs (original)
+++ trunk/beagle/beagled/TextCache.cs Sun Feb 3 01:00:55 2008
@@ -227,14 +227,12 @@
private string LookupPathRawUnlocked (Uri uri)
{
//SqliteCommand command;
- SqliteDataReader reader = null;
string path = null;
LookupPathCommand.Parameters.AddWithValue ("@uri", UriToString (uri));
- reader = SqliteUtils.ExecuteReaderOrWait (LookupPathCommand);
- if (SqliteUtils.ReadOrWait (reader))
- path = reader.GetString (0);
- reader.Close ();
-
+ using (SqliteDataReader reader = SqliteUtils.ExecuteReaderOrWait (LookupPathCommand)) {
+ if (SqliteUtils.ReadOrWait (reader))
+ path = reader.GetString (0);
+ }
return path;
}
@@ -455,24 +453,23 @@
// If self_cache is true when called, then self_cache will be set upon return
public TextReader GetReader (Uri uri, ref bool self_cache)
{
- SqliteDataReader reader = null;
byte[] blob = null;
string filename = null;
lock (connection) {
LookupDataCommand.Parameters.AddWithValue("@uri",UriToString (uri));
- reader = SqliteUtils.ExecuteReaderOrWait (LookupDataCommand);
- if (! SqliteUtils.ReadOrWait (reader)) {
- if (self_cache)
- self_cache = false;
- return null;
- }
+ using (SqliteDataReader reader = SqliteUtils.ExecuteReaderOrWait (LookupDataCommand)) {
+ if (! SqliteUtils.ReadOrWait (reader)) {
+ if (self_cache)
+ self_cache = false;
+ return null;
+ }
filename = reader.GetString (0);
if (! reader.IsDBNull (1))
blob = reader.GetValue (1) as byte [];
- reader.Close ();
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]