put some locking around user access, which should help with

the exception dalien found during crash-a-thon
afrisby
Sean Dague 2007-09-15 10:43:19 +00:00
parent 4a07800f14
commit b931048b16
1 changed files with 53 additions and 45 deletions

View File

@ -60,11 +60,13 @@ namespace OpenSim.Framework.Data.SQLite
ds = new DataSet();
da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn));
lock (ds) {
ds.Tables.Add(createUsersTable());
ds.Tables.Add(createUserAgentsTable());
setupUserCommands(da, conn);
da.Fill(ds.Tables["users"]);
}
return;
}
@ -76,6 +78,7 @@ namespace OpenSim.Framework.Data.SQLite
/// <returns>A user profile</returns>
public UserProfileData getUserByUUID(LLUUID uuid)
{
lock (ds) {
DataRow row = ds.Tables["users"].Rows.Find(uuid);
if(row != null) {
UserProfileData user = buildUserProfile(row);
@ -88,6 +91,7 @@ namespace OpenSim.Framework.Data.SQLite
return null;
}
}
}
/// <summary>
/// Returns a user by searching for its name
@ -108,6 +112,7 @@ namespace OpenSim.Framework.Data.SQLite
public UserProfileData getUserByName(string fname, string lname)
{
string select = "surname = '" + lname + "' and username = '" + fname + "'";
lock (ds) {
DataRow[] rows = ds.Tables["users"].Select(select);
if(rows.Length > 0) {
UserProfileData user = buildUserProfile(rows[0]);
@ -120,6 +125,7 @@ namespace OpenSim.Framework.Data.SQLite
return null;
}
}
}
/// <summary>
/// Returns a user by UUID direct
@ -173,6 +179,7 @@ namespace OpenSim.Framework.Data.SQLite
public void addNewUserProfile(UserProfileData user)
{
DataTable users = ds.Tables["users"];
lock (ds) {
DataRow row = users.Rows.Find(user.UUID);
if (row == null)
{
@ -203,6 +210,7 @@ namespace OpenSim.Framework.Data.SQLite
// save changes off to disk
da.Update(ds, "users");
}
}
/// <summary>
/// Creates a new user profile