aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorMic Bowman2011-02-03 12:43:46 -0800
committerMic Bowman2011-02-03 12:43:46 -0800
commitcf24069227f9a32272c873d4423e2e11f5da25a8 (patch)
treea88f39073401978953ef803d2920f60e70f32143 /OpenSim/Services
parentAddresses mantis #5360: CreatorData was being written as long as it wasn't nu... (diff)
downloadopensim-SC-cf24069227f9a32272c873d4423e2e11f5da25a8.zip
opensim-SC-cf24069227f9a32272c873d4423e2e11f5da25a8.tar.gz
opensim-SC-cf24069227f9a32272c873d4423e2e11f5da25a8.tar.bz2
opensim-SC-cf24069227f9a32272c873d4423e2e11f5da25a8.tar.xz
Change UpdateAgent (for changes in agent position) to be sent
once to each simulator rather than once to each region. This should help with some of the delays caused by multiple outstanding requests to a single service point.
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs55
1 files changed, 52 insertions, 3 deletions
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index c5313fc..cc6bffb 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -48,6 +48,9 @@ namespace OpenSim.Services.Connectors.Simulation
48 { 48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 // we use this dictionary to track the pending updateagent requests, maps URI --> position update
52 private Dictionary<string,AgentPosition> m_updateAgentQueue = new Dictionary<string,AgentPosition>();
53
51 //private GridRegion m_Region; 54 //private GridRegion m_Region;
52 55
53 public SimulationServiceConnector() 56 public SimulationServiceConnector()
@@ -133,10 +136,56 @@ namespace OpenSim.Services.Connectors.Simulation
133 /// </summary> 136 /// </summary>
134 public bool UpdateAgent(GridRegion destination, AgentPosition data) 137 public bool UpdateAgent(GridRegion destination, AgentPosition data)
135 { 138 {
136 // we need a better throttle for these 139 // The basic idea of this code is that the first thread that needs to
137 // return false; 140 // send an update for a specific avatar becomes the worker for any subsequent
141 // requests until there are no more outstanding requests. Further, only send the most
142 // recent update; this *should* never be needed but some requests get
143 // slowed down and once that happens the problem with service end point
144 // limits kicks in and nothing proceeds
145 string uri = destination.ServerURI + AgentPath() + data.AgentID + "/";
146 lock (m_updateAgentQueue)
147 {
148 if (m_updateAgentQueue.ContainsKey(uri))
149 {
150 // Another thread is already handling
151 // updates for this simulator, just update
152 // the position and return, overwrites are
153 // not a problem since we only care about the
154 // last update anyway
155 m_updateAgentQueue[uri] = data;
156 return true;
157 }
158
159 // Otherwise update the reference and start processing
160 m_updateAgentQueue[uri] = data;
161 }
138 162
139 return UpdateAgent(destination, (IAgentData)data); 163 AgentPosition pos = null;
164 while (true)
165 {
166 lock (m_updateAgentQueue)
167 {
168 // save the position
169 AgentPosition lastpos = pos;
170
171 pos = m_updateAgentQueue[uri];
172
173 // this is true if no one put a new
174 // update in the map since the last
175 // one we processed, if thats the
176 // case then we are done
177 if (pos == lastpos)
178 {
179 m_updateAgentQueue.Remove(uri);
180 return true;
181 }
182 }
183
184 UpdateAgent(destination,(IAgentData)pos);
185 }
186
187 // unreachable
188 return true;
140 } 189 }
141 190
142 /// <summary> 191 /// <summary>