aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorSean Dague2007-12-11 21:47:18 +0000
committerSean Dague2007-12-11 21:47:18 +0000
commit2e38e534d90463fbf9c8c0cfd8f7620eac2fd22b (patch)
treea13fe0086282c7a3f5b82848583737241335bf76 /OpenSim/Region
parent* Added some locking to help race conditions in the neighbors lists (diff)
downloadopensim-SC_OLD-2e38e534d90463fbf9c8c0cfd8f7620eac2fd22b.zip
opensim-SC_OLD-2e38e534d90463fbf9c8c0cfd8f7620eac2fd22b.tar.gz
opensim-SC_OLD-2e38e534d90463fbf9c8c0cfd8f7620eac2fd22b.tar.bz2
opensim-SC_OLD-2e38e534d90463fbf9c8c0cfd8f7620eac2fd22b.tar.xz
consolidate client view exit paths, this seems to
cause a different synchronization issue in other shutdown routines, though I'm not sure why
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs53
-rw-r--r--OpenSim/Region/ClientStack/PacketQueue.cs17
2 files changed, 33 insertions, 37 deletions
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index e199f30..be9917c 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -73,7 +73,6 @@ namespace OpenSim.Region.ClientStack
73 private uint m_circuitCode; 73 private uint m_circuitCode;
74 private int m_moneyBalance; 74 private int m_moneyBalance;
75 75
76
77 private byte[] m_channelVersion=new byte[] { 0x00} ; // Dummy value needed by libSL 76 private byte[] m_channelVersion=new byte[] { 0x00} ; // Dummy value needed by libSL
78 77
79 /* protected variables */ 78 /* protected variables */
@@ -188,11 +187,6 @@ namespace OpenSim.Region.ClientStack
188 187
189 PacketQueue = new PacketQueue(); 188 PacketQueue = new PacketQueue();
190 189
191 //this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);
192 AckTimer = new Timer(750);
193 AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
194 AckTimer.Start();
195
196 RegisterLocalPacketHandlers(); 190 RegisterLocalPacketHandlers();
197 191
198 ClientThread = new Thread(new ThreadStart(AuthUser)); 192 ClientThread = new Thread(new ThreadStart(AuthUser));
@@ -211,18 +205,29 @@ namespace OpenSim.Region.ClientStack
211 205
212 public void Close() 206 public void Close()
213 { 207 {
214 // FLUSH Packets
215 PacketQueue.Flush();
216 PacketQueue.Close();
217
218 // Pull Client out of Region 208 // Pull Client out of Region
219 m_scene.RemoveClient(AgentId); 209 m_scene.RemoveClient(AgentId);
210
211 // Send the STOP packet
212 libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket();
213 OutPacket(disable, ThrottleOutPacketType.Task);
214
215 // FLUSH Packets
216 PacketQueue.Close();
217 PacketQueue.Flush();
220 218
221 // Shut down timers 219 // Shut down timers
220 AckTimer.Stop();
222 clientPingTimer.Stop(); 221 clientPingTimer.Stop();
222
223 // This is just to give the client a reasonable chance of
224 // flushing out all it's packets. There should probably
225 // be a better mechanism here
226 Thread.Sleep(2000);
223 227
224 ClientThread.Abort(); 228 ClientThread.Abort();
225 } 229 }
230
226 public void Kick(string message) 231 public void Kick(string message)
227 { 232 {
228 KickUserPacket kupack = new KickUserPacket(); 233 KickUserPacket kupack = new KickUserPacket();
@@ -234,17 +239,11 @@ namespace OpenSim.Region.ClientStack
234 kupack.TargetBlock.TargetPort = (ushort)0; 239 kupack.TargetBlock.TargetPort = (ushort)0;
235 kupack.UserInfo.Reason = Helpers.StringToField(message); 240 kupack.UserInfo.Reason = Helpers.StringToField(message);
236 OutPacket(kupack, ThrottleOutPacketType.Task); 241 OutPacket(kupack, ThrottleOutPacketType.Task);
237
238
239 } 242 }
243
240 public void Stop() 244 public void Stop()
241 { 245 {
242 clientPingTimer.Stop(); 246 Close();
243
244 libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket();
245 OutPacket(disable, ThrottleOutPacketType.Task);
246
247 ClientThread.Abort();
248 } 247 }
249 248
250 #endregion 249 #endregion
@@ -389,6 +388,13 @@ namespace OpenSim.Region.ClientStack
389 388
390 protected virtual void InitNewClient() 389 protected virtual void InitNewClient()
391 { 390 {
391 //this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);
392
393 // Establish our two timers. We could probably get this down to one
394 AckTimer = new Timer(750);
395 AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
396 AckTimer.Start();
397
392 clientPingTimer = new Timer(5000); 398 clientPingTimer = new Timer(5000);
393 clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity); 399 clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity);
394 clientPingTimer.Enabled = true; 400 clientPingTimer.Enabled = true;
@@ -407,6 +413,7 @@ namespace OpenSim.Region.ClientStack
407 { 413 {
408 //session/circuit not authorised 414 //session/circuit not authorised
409 MainLog.Instance.Notice("CLIENT", "New user request denied to " + userEP.ToString()); 415 MainLog.Instance.Notice("CLIENT", "New user request denied to " + userEP.ToString());
416 PacketQueue.Close();
410 ClientThread.Abort(); 417 ClientThread.Abort();
411 } 418 }
412 else 419 else
@@ -423,6 +430,7 @@ namespace OpenSim.Region.ClientStack
423 { 430 {
424 m_secureSessionId = sessionInfo.LoginInfo.SecureSession; 431 m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
425 } 432 }
433 // This sets up all the timers
426 InitNewClient(); 434 InitNewClient();
427 435
428 ClientLoop(); 436 ClientLoop();
@@ -431,11 +439,6 @@ namespace OpenSim.Region.ClientStack
431 439
432 # endregion 440 # endregion
433 441
434 protected void KillThread()
435 {
436 ClientThread.Abort();
437 }
438
439 // Previously ClientView.API partial class 442 // Previously ClientView.API partial class
440 public event Action<IClientAPI> OnLogout; 443 public event Action<IClientAPI> OnLogout;
441 public event ObjectPermissions OnObjectPermissions; 444 public event ObjectPermissions OnObjectPermissions;
@@ -2171,7 +2174,7 @@ namespace OpenSim.Region.ClientStack
2171 "ClientView.PacketQueue.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + 2174 "ClientView.PacketQueue.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " +
2172 userEP.ToString() + " - killing thread"); 2175 userEP.ToString() + " - killing thread");
2173 MainLog.Instance.Error(e.ToString()); 2176 MainLog.Instance.Error(e.ToString());
2174 KillThread(); 2177 Close();
2175 } 2178 }
2176 } 2179 }
2177 2180
diff --git a/OpenSim/Region/ClientStack/PacketQueue.cs b/OpenSim/Region/ClientStack/PacketQueue.cs
index 747ef18..b1a649c 100644
--- a/OpenSim/Region/ClientStack/PacketQueue.cs
+++ b/OpenSim/Region/ClientStack/PacketQueue.cs
@@ -44,6 +44,8 @@ namespace OpenSim.Region.ClientStack
44{ 44{
45 public class PacketQueue 45 public class PacketQueue
46 { 46 {
47 private bool m_enabled = true;
48
47 private BlockingQueue<QueItem> SendQueue; 49 private BlockingQueue<QueItem> SendQueue;
48 50
49 private Queue<QueItem> IncomingPacketQueue; 51 private Queue<QueItem> IncomingPacketQueue;
@@ -127,8 +129,10 @@ namespace OpenSim.Region.ClientStack
127 129
128 public void Enqueue(QueItem item) 130 public void Enqueue(QueItem item)
129 { 131 {
132 if (!m_enabled) {return;}
130 // We could micro lock, but that will tend to actually 133 // We could micro lock, but that will tend to actually
131 // probably be worse than just synchronizing on SendQueue 134 // probably be worse than just synchronizing on SendQueue
135
132 lock (this) { 136 lock (this) {
133 switch (item.throttleType) 137 switch (item.throttleType)
134 { 138 {
@@ -209,6 +213,7 @@ namespace OpenSim.Region.ClientStack
209 213
210 public void Close() 214 public void Close()
211 { 215 {
216 m_enabled = false;
212 throttleTimer.Stop(); 217 throttleTimer.Stop();
213 } 218 }
214 219
@@ -235,18 +240,6 @@ namespace OpenSim.Region.ClientStack
235 TextureOutgoingPacketQueue.Count > 0); 240 TextureOutgoingPacketQueue.Count > 0);
236 } 241 }
237 242
238 // Run through our wait queues and flush out allotted numbers of bytes into the process queue
239
240// private bool ThrottlingTime()
241// {
242// if(DateTime.Now.Ticks > (LastThrottle + ThrottleInterval)) {
243// LastThrottle = DateTime.Now.Ticks;
244// return true;
245// } else {
246// return false;
247// }
248// }
249
250 public void ProcessThrottle() 243 public void ProcessThrottle()
251 { 244 {
252 245