diff options
author | Sean Dague | 2007-09-11 08:25:32 +0000 |
---|---|---|
committer | Sean Dague | 2007-09-11 08:25:32 +0000 |
commit | a1e2fea7c1fc612da088914aab7a462c212bc97d (patch) | |
tree | b02e50c4662c66d6bbd6b2fed46dac4bec9f4988 /OpenSim/Framework/Data.SQLite | |
parent | remove autogenerated files (diff) | |
download | opensim-SC-a1e2fea7c1fc612da088914aab7a462c212bc97d.zip opensim-SC-a1e2fea7c1fc612da088914aab7a462c212bc97d.tar.gz opensim-SC-a1e2fea7c1fc612da088914aab7a462c212bc97d.tar.bz2 opensim-SC-a1e2fea7c1fc612da088914aab7a462c212bc97d.tar.xz |
move the locks closer to the data, sqlite for assets now works like a champ
Diffstat (limited to 'OpenSim/Framework/Data.SQLite')
-rw-r--r-- | OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs index aef9350..4616275 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs | |||
@@ -61,19 +61,20 @@ namespace OpenSim.Framework.Data.SQLite | |||
61 | 61 | ||
62 | ds = new DataSet(); | 62 | ds = new DataSet(); |
63 | da = new SqliteDataAdapter(new SqliteCommand(assetSelect, conn)); | 63 | da = new SqliteDataAdapter(new SqliteCommand(assetSelect, conn)); |
64 | |||
65 | ds.Tables.Add(createAssetsTable()); | ||
66 | |||
67 | setupAssetCommands(da, conn); | ||
68 | try | ||
69 | { | ||
70 | da.Fill(ds.Tables["assets"]); | ||
71 | } | ||
72 | catch (Exception) | ||
73 | { | ||
74 | MainLog.Instance.Verbose("AssetStorage", "Caught fill error on asset table"); | ||
75 | } | ||
76 | 64 | ||
65 | lock (ds) { | ||
66 | ds.Tables.Add(createAssetsTable()); | ||
67 | |||
68 | setupAssetCommands(da, conn); | ||
69 | try | ||
70 | { | ||
71 | da.Fill(ds.Tables["assets"]); | ||
72 | } | ||
73 | catch (Exception) | ||
74 | { | ||
75 | MainLog.Instance.Verbose("AssetStorage", "Caught fill error on asset table"); | ||
76 | } | ||
77 | } | ||
77 | 78 | ||
78 | return; | 79 | return; |
79 | } | 80 | } |
@@ -110,19 +111,19 @@ namespace OpenSim.Framework.Data.SQLite | |||
110 | ", Local: " + asset.Local + | 111 | ", Local: " + asset.Local + |
111 | ", Data Length: " + asset.Data.Length ); | 112 | ", Data Length: " + asset.Data.Length ); |
112 | DataTable assets = ds.Tables["assets"]; | 113 | DataTable assets = ds.Tables["assets"]; |
113 | DataRow row = assets.Rows.Find(asset.FullID); | 114 | lock(ds) { |
114 | if (row == null) | 115 | DataRow row = assets.Rows.Find(asset.FullID); |
115 | { | 116 | if (row == null) |
116 | row = assets.NewRow(); | 117 | { |
117 | fillAssetRow(row, asset); | 118 | row = assets.NewRow(); |
118 | assets.Rows.Add(row); | 119 | fillAssetRow(row, asset); |
119 | } | 120 | assets.Rows.Add(row); |
120 | else | 121 | } |
121 | { | 122 | else |
122 | fillAssetRow(row, asset); | 123 | { |
124 | fillAssetRow(row, asset); | ||
125 | } | ||
123 | } | 126 | } |
124 | da.Update(ds, "assets"); | ||
125 | ds.AcceptChanges(); | ||
126 | } | 127 | } |
127 | 128 | ||
128 | public bool ExistsAsset(LLUUID uuid) | 129 | public bool ExistsAsset(LLUUID uuid) |
@@ -133,19 +134,21 @@ namespace OpenSim.Framework.Data.SQLite | |||
133 | 134 | ||
134 | public void DeleteAsset(LLUUID uuid) | 135 | public void DeleteAsset(LLUUID uuid) |
135 | { | 136 | { |
136 | DataRow row = ds.Tables["assets"].Rows.Find(uuid); | 137 | lock (ds) { |
137 | if (row != null) { | 138 | DataRow row = ds.Tables["assets"].Rows.Find(uuid); |
138 | row.Delete(); | 139 | if (row != null) { |
140 | row.Delete(); | ||
141 | } | ||
139 | } | 142 | } |
140 | da.Update(ds, "assets"); | ||
141 | ds.AcceptChanges(); | ||
142 | } | 143 | } |
143 | 144 | ||
144 | public void CommitAssets() // force a sync to the database | 145 | public void CommitAssets() // force a sync to the database |
145 | { | 146 | { |
146 | MainLog.Instance.Verbose("AssetStorage", "Attempting commit"); | 147 | MainLog.Instance.Verbose("AssetStorage", "Attempting commit"); |
147 | // da.Update(ds, "assets"); | 148 | lock (ds) { |
148 | // ds.AcceptChanges(); | 149 | da.Update(ds, "assets"); |
150 | ds.AcceptChanges(); | ||
151 | } | ||
149 | } | 152 | } |
150 | 153 | ||
151 | /*********************************************************************** | 154 | /*********************************************************************** |