diff options
author | Sean Dague | 2007-09-15 10:43:19 +0000 |
---|---|---|
committer | Sean Dague | 2007-09-15 10:43:19 +0000 |
commit | b931048b16a441616d165c670bdeb253b4ac5eeb (patch) | |
tree | 826b1f31be82891150baa910a526d27d49359e20 /OpenSim/Framework/Data.SQLite/SQLiteUserData.cs | |
parent | Testing to see if this fixes the editing appearance crash, or makes it (or an... (diff) | |
download | opensim-SC-b931048b16a441616d165c670bdeb253b4ac5eeb.zip opensim-SC-b931048b16a441616d165c670bdeb253b4ac5eeb.tar.gz opensim-SC-b931048b16a441616d165c670bdeb253b4ac5eeb.tar.bz2 opensim-SC-b931048b16a441616d165c670bdeb253b4ac5eeb.tar.xz |
put some locking around user access, which should help with
the exception dalien found during crash-a-thon
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Data.SQLite/SQLiteUserData.cs | 98 |
1 files changed, 53 insertions, 45 deletions
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs index e0ad49e..76be89c 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs | |||
@@ -59,12 +59,14 @@ namespace OpenSim.Framework.Data.SQLite | |||
59 | 59 | ||
60 | ds = new DataSet(); | 60 | ds = new DataSet(); |
61 | da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn)); | 61 | da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn)); |
62 | 62 | ||
63 | ds.Tables.Add(createUsersTable()); | 63 | lock (ds) { |
64 | ds.Tables.Add(createUserAgentsTable()); | 64 | ds.Tables.Add(createUsersTable()); |
65 | 65 | ds.Tables.Add(createUserAgentsTable()); | |
66 | setupUserCommands(da, conn); | 66 | |
67 | da.Fill(ds.Tables["users"]); | 67 | setupUserCommands(da, conn); |
68 | da.Fill(ds.Tables["users"]); | ||
69 | } | ||
68 | 70 | ||
69 | return; | 71 | return; |
70 | } | 72 | } |
@@ -76,16 +78,18 @@ namespace OpenSim.Framework.Data.SQLite | |||
76 | /// <returns>A user profile</returns> | 78 | /// <returns>A user profile</returns> |
77 | public UserProfileData getUserByUUID(LLUUID uuid) | 79 | public UserProfileData getUserByUUID(LLUUID uuid) |
78 | { | 80 | { |
79 | DataRow row = ds.Tables["users"].Rows.Find(uuid); | 81 | lock (ds) { |
80 | if(row != null) { | 82 | DataRow row = ds.Tables["users"].Rows.Find(uuid); |
81 | UserProfileData user = buildUserProfile(row); | ||
82 | row = ds.Tables["useragents"].Rows.Find(uuid); | ||
83 | if(row != null) { | 83 | if(row != null) { |
84 | user.currentAgent = buildUserAgent(row); | 84 | UserProfileData user = buildUserProfile(row); |
85 | row = ds.Tables["useragents"].Rows.Find(uuid); | ||
86 | if(row != null) { | ||
87 | user.currentAgent = buildUserAgent(row); | ||
88 | } | ||
89 | return user; | ||
90 | } else { | ||
91 | return null; | ||
85 | } | 92 | } |
86 | return user; | ||
87 | } else { | ||
88 | return null; | ||
89 | } | 93 | } |
90 | } | 94 | } |
91 | 95 | ||
@@ -108,16 +112,18 @@ namespace OpenSim.Framework.Data.SQLite | |||
108 | public UserProfileData getUserByName(string fname, string lname) | 112 | public UserProfileData getUserByName(string fname, string lname) |
109 | { | 113 | { |
110 | string select = "surname = '" + lname + "' and username = '" + fname + "'"; | 114 | string select = "surname = '" + lname + "' and username = '" + fname + "'"; |
111 | DataRow[] rows = ds.Tables["users"].Select(select); | 115 | lock (ds) { |
112 | if(rows.Length > 0) { | 116 | DataRow[] rows = ds.Tables["users"].Select(select); |
113 | UserProfileData user = buildUserProfile(rows[0]); | 117 | if(rows.Length > 0) { |
114 | DataRow row = ds.Tables["useragents"].Rows.Find(user.UUID); | 118 | UserProfileData user = buildUserProfile(rows[0]); |
115 | if(row != null) { | 119 | DataRow row = ds.Tables["useragents"].Rows.Find(user.UUID); |
116 | user.currentAgent = buildUserAgent(row); | 120 | if(row != null) { |
121 | user.currentAgent = buildUserAgent(row); | ||
122 | } | ||
123 | return user; | ||
124 | } else { | ||
125 | return null; | ||
117 | } | 126 | } |
118 | return user; | ||
119 | } else { | ||
120 | return null; | ||
121 | } | 127 | } |
122 | } | 128 | } |
123 | 129 | ||
@@ -173,35 +179,37 @@ namespace OpenSim.Framework.Data.SQLite | |||
173 | public void addNewUserProfile(UserProfileData user) | 179 | public void addNewUserProfile(UserProfileData user) |
174 | { | 180 | { |
175 | DataTable users = ds.Tables["users"]; | 181 | DataTable users = ds.Tables["users"]; |
176 | DataRow row = users.Rows.Find(user.UUID); | 182 | lock (ds) { |
177 | if (row == null) | 183 | DataRow row = users.Rows.Find(user.UUID); |
178 | { | ||
179 | row = users.NewRow(); | ||
180 | fillUserRow(row, user); | ||
181 | users.Rows.Add(row); | ||
182 | } | ||
183 | else | ||
184 | { | ||
185 | fillUserRow(row, user); | ||
186 | } | ||
187 | |||
188 | if(user.currentAgent != null) { | ||
189 | DataTable ua = ds.Tables["useragents"]; | ||
190 | row = ua.Rows.Find(user.UUID); | ||
191 | if (row == null) | 184 | if (row == null) |
192 | { | 185 | { |
193 | row = ua.NewRow(); | 186 | row = users.NewRow(); |
194 | fillUserAgentRow(row, user.currentAgent); | 187 | fillUserRow(row, user); |
195 | ua.Rows.Add(row); | 188 | users.Rows.Add(row); |
196 | } | 189 | } |
197 | else | 190 | else |
198 | { | 191 | { |
199 | fillUserAgentRow(row, user.currentAgent); | 192 | fillUserRow(row, user); |
193 | } | ||
194 | |||
195 | if(user.currentAgent != null) { | ||
196 | DataTable ua = ds.Tables["useragents"]; | ||
197 | row = ua.Rows.Find(user.UUID); | ||
198 | if (row == null) | ||
199 | { | ||
200 | row = ua.NewRow(); | ||
201 | fillUserAgentRow(row, user.currentAgent); | ||
202 | ua.Rows.Add(row); | ||
203 | } | ||
204 | else | ||
205 | { | ||
206 | fillUserAgentRow(row, user.currentAgent); | ||
207 | } | ||
200 | } | 208 | } |
209 | MainLog.Instance.Verbose("Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored"); | ||
210 | // save changes off to disk | ||
211 | da.Update(ds, "users"); | ||
201 | } | 212 | } |
202 | MainLog.Instance.Verbose("Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored"); | ||
203 | // save changes off to disk | ||
204 | da.Update(ds, "users"); | ||
205 | } | 213 | } |
206 | 214 | ||
207 | /// <summary> | 215 | /// <summary> |