diff options
author | Justin Clark-Casey (justincc) | 2012-06-25 22:48:13 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-06-25 22:48:13 +0100 |
commit | e5b739aaebace6b028f3f6bf05d21ff7a7c5affe (patch) | |
tree | f76c578681da34fddb0c36eeada8af57eaf0bbc4 | |
parent | In AttachmentsModule.DetachSingleAttachmentToInvInternal(), remove attachment... (diff) | |
download | opensim-SC_OLD-e5b739aaebace6b028f3f6bf05d21ff7a7c5affe.zip opensim-SC_OLD-e5b739aaebace6b028f3f6bf05d21ff7a7c5affe.tar.gz opensim-SC_OLD-e5b739aaebace6b028f3f6bf05d21ff7a7c5affe.tar.bz2 opensim-SC_OLD-e5b739aaebace6b028f3f6bf05d21ff7a7c5affe.tar.xz |
When attachments are being saved and deleted for a closing root agent, delete first to avoid a hud race condition with update threads.
If delete doesn't occur first then the update thread can outrace the IsAttachment = false necessary to save attachments and send hud artifacts to other viewers.
4 files changed, 42 insertions, 29 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 99e0153..2b0e4ab 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -152,31 +152,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | public void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted) | 155 | public void DeRezAttachments(IScenePresence sp, bool saveChanged, bool saveAllScripted) |
156 | { | 156 | { |
157 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name); | ||
158 | |||
159 | if (!Enabled) | 157 | if (!Enabled) |
160 | return; | 158 | return; |
161 | 159 | ||
162 | foreach (SceneObjectGroup grp in sp.GetAttachments()) | 160 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name); |
161 | |||
162 | lock (sp.AttachmentsSyncLock) | ||
163 | { | 163 | { |
164 | grp.IsAttachment = false; | 164 | foreach (SceneObjectGroup grp in sp.GetAttachments()) |
165 | grp.AbsolutePosition = grp.RootPart.AttachedPos; | 165 | { |
166 | UpdateKnownItem(sp, grp, saveAllScripted); | 166 | grp.Scene.DeleteSceneObject(grp, false); |
167 | grp.IsAttachment = true; | 167 | |
168 | if (saveChanged || saveAllScripted) | ||
169 | { | ||
170 | grp.IsAttachment = false; | ||
171 | grp.AbsolutePosition = grp.RootPart.AttachedPos; | ||
172 | UpdateKnownItem(sp, grp, saveAllScripted); | ||
173 | } | ||
174 | } | ||
175 | |||
176 | sp.ClearAttachments(); | ||
168 | } | 177 | } |
169 | } | 178 | } |
170 | 179 | ||
171 | public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent) | 180 | public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent) |
172 | { | 181 | { |
173 | // m_log.DebugFormat( | ||
174 | // "[ATTACHMENTS MODULE]: Deleting attachments from scene {0} for {1}, silent = {2}", | ||
175 | // m_scene.RegionInfo.RegionName, sp.Name, silent); | ||
176 | |||
177 | if (!Enabled) | 182 | if (!Enabled) |
178 | return; | 183 | return; |
179 | 184 | ||
185 | // m_log.DebugFormat( | ||
186 | // "[ATTACHMENTS MODULE]: Deleting attachments from scene {0} for {1}, silent = {2}", | ||
187 | // m_scene.RegionInfo.RegionName, sp.Name, silent); | ||
188 | |||
180 | foreach (SceneObjectGroup sop in sp.GetAttachments()) | 189 | foreach (SceneObjectGroup sop in sp.GetAttachments()) |
181 | { | 190 | { |
182 | sop.Scene.DeleteSceneObject(sop, silent); | 191 | sop.Scene.DeleteSceneObject(sop, silent); |
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index eb07165..fde5de1 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs | |||
@@ -43,10 +43,15 @@ namespace OpenSim.Region.Framework.Interfaces | |||
43 | void RezAttachments(IScenePresence sp); | 43 | void RezAttachments(IScenePresence sp); |
44 | 44 | ||
45 | /// <summary> | 45 | /// <summary> |
46 | /// Save the attachments that have change on this presence. | 46 | /// Derez the attachements for a scene presence that is closing. |
47 | /// </summary> | 47 | /// </summary> |
48 | /// <param name="sp"></param> | 48 | /// <remarks> |
49 | void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted); | 49 | /// Attachment changes are saved. |
50 | /// </remarks> | ||
51 | /// <param name="sp">The presence closing</param> | ||
52 | /// <param name="saveChanged">Save changed attachments.</param> | ||
53 | /// <param name="saveAllScripted">Save attachments with scripts even if they haven't changed.</para> | ||
54 | void DeRezAttachments(IScenePresence sp, bool saveChanged, bool saveAllScripted); | ||
50 | 55 | ||
51 | /// <summary> | 56 | /// <summary> |
52 | /// Delete all the presence's attachments from the scene | 57 | /// Delete all the presence's attachments from the scene |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 385febf..d449116 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -500,6 +500,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
500 | public IAttachmentsModule AttachmentsModule { get; set; } | 500 | public IAttachmentsModule AttachmentsModule { get; set; } |
501 | public IEntityTransferModule EntityTransferModule { get; private set; } | 501 | public IEntityTransferModule EntityTransferModule { get; private set; } |
502 | public IAgentAssetTransactions AgentTransactionsModule { get; private set; } | 502 | public IAgentAssetTransactions AgentTransactionsModule { get; private set; } |
503 | public IUserManagement UserManagementModule { get; private set; } | ||
503 | 504 | ||
504 | public IAvatarFactoryModule AvatarFactory | 505 | public IAvatarFactoryModule AvatarFactory |
505 | { | 506 | { |
@@ -1243,6 +1244,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1243 | EntityTransferModule = RequestModuleInterface<IEntityTransferModule>(); | 1244 | EntityTransferModule = RequestModuleInterface<IEntityTransferModule>(); |
1244 | m_groupsModule = RequestModuleInterface<IGroupsModule>(); | 1245 | m_groupsModule = RequestModuleInterface<IGroupsModule>(); |
1245 | AgentTransactionsModule = RequestModuleInterface<IAgentAssetTransactions>(); | 1246 | AgentTransactionsModule = RequestModuleInterface<IAgentAssetTransactions>(); |
1247 | UserManagementModule = RequestModuleInterface<IUserManagement>(); | ||
1246 | } | 1248 | } |
1247 | 1249 | ||
1248 | #endregion | 1250 | #endregion |
@@ -2021,9 +2023,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2021 | sceneObject.SetGroup(groupID, null); | 2023 | sceneObject.SetGroup(groupID, null); |
2022 | } | 2024 | } |
2023 | 2025 | ||
2024 | IUserManagement uman = RequestModuleInterface<IUserManagement>(); | 2026 | if (UserManagementModule != null) |
2025 | if (uman != null) | 2027 | sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID); |
2026 | sceneObject.RootPart.CreatorIdentification = uman.GetUserUUI(ownerID); | ||
2027 | 2028 | ||
2028 | sceneObject.ScheduleGroupForFullUpdate(); | 2029 | sceneObject.ScheduleGroupForFullUpdate(); |
2029 | 2030 | ||
@@ -2711,14 +2712,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2711 | /// <param name="aCircuit"></param> | 2712 | /// <param name="aCircuit"></param> |
2712 | private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit) | 2713 | private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit) |
2713 | { | 2714 | { |
2714 | IUserManagement uMan = RequestModuleInterface<IUserManagement>(); | 2715 | if (UserManagementModule != null) |
2715 | if (uMan != null) | ||
2716 | { | 2716 | { |
2717 | string first = aCircuit.firstname, last = aCircuit.lastname; | 2717 | string first = aCircuit.firstname, last = aCircuit.lastname; |
2718 | 2718 | ||
2719 | if (sp.PresenceType == PresenceType.Npc) | 2719 | if (sp.PresenceType == PresenceType.Npc) |
2720 | { | 2720 | { |
2721 | uMan.AddUser(aCircuit.AgentID, first, last); | 2721 | UserManagementModule.AddUser(aCircuit.AgentID, first, last); |
2722 | } | 2722 | } |
2723 | else | 2723 | else |
2724 | { | 2724 | { |
@@ -2737,7 +2737,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2737 | } | 2737 | } |
2738 | } | 2738 | } |
2739 | 2739 | ||
2740 | uMan.AddUser(aCircuit.AgentID, first, last, homeURL); | 2740 | UserManagementModule.AddUser(aCircuit.AgentID, first, last, homeURL); |
2741 | } | 2741 | } |
2742 | } | 2742 | } |
2743 | } | 2743 | } |
@@ -3292,17 +3292,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
3292 | 3292 | ||
3293 | if (!isChildAgent) | 3293 | if (!isChildAgent) |
3294 | { | 3294 | { |
3295 | if (AttachmentsModule != null && avatar.PresenceType != PresenceType.Npc) | 3295 | if (AttachmentsModule != null) |
3296 | { | 3296 | { |
3297 | IUserManagement uMan = RequestModuleInterface<IUserManagement>(); | ||
3298 | // Don't save attachments for HG visitors, it | 3297 | // Don't save attachments for HG visitors, it |
3299 | // messes up their inventory. When a HG visitor logs | 3298 | // messes up their inventory. When a HG visitor logs |
3300 | // out on a foreign grid, their attachments will be | 3299 | // out on a foreign grid, their attachments will be |
3301 | // reloaded in the state they were in when they left | 3300 | // reloaded in the state they were in when they left |
3302 | // the home grid. This is best anyway as the visited | 3301 | // the home grid. This is best anyway as the visited |
3303 | // grid may use an incompatible script engine. | 3302 | // grid may use an incompatible script engine. |
3304 | if (uMan == null || uMan.IsLocalGridUser(avatar.UUID)) | 3303 | bool saveChanged |
3305 | AttachmentsModule.SaveChangedAttachments(avatar, false); | 3304 | = avatar.PresenceType != PresenceType.Npc |
3305 | && (UserManagementModule == null || UserManagementModule.IsLocalGridUser(avatar.UUID)); | ||
3306 | |||
3307 | AttachmentsModule.DeRezAttachments(avatar, saveChanged, false); | ||
3306 | } | 3308 | } |
3307 | 3309 | ||
3308 | ForEachClient( | 3310 | ForEachClient( |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3909fd4..909c7c8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -3416,9 +3416,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3416 | 3416 | ||
3417 | public void Close() | 3417 | public void Close() |
3418 | { | 3418 | { |
3419 | if (!IsChildAgent && m_scene.AttachmentsModule != null) | ||
3420 | m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false); | ||
3421 | |||
3422 | // Clear known regions | 3419 | // Clear known regions |
3423 | KnownRegions = new Dictionary<ulong, string>(); | 3420 | KnownRegions = new Dictionary<ulong, string>(); |
3424 | 3421 | ||