diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 137 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 3 |
2 files changed, 128 insertions, 12 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 7042c9a..75a47d5 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -110,7 +110,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
110 | /// <summary>Handlers for incoming packets</summary> | 110 | /// <summary>Handlers for incoming packets</summary> |
111 | //PacketEventDictionary packetEvents = new PacketEventDictionary(); | 111 | //PacketEventDictionary packetEvents = new PacketEventDictionary(); |
112 | /// <summary>Incoming packets that are awaiting handling</summary> | 112 | /// <summary>Incoming packets that are awaiting handling</summary> |
113 | private OpenMetaverse.BlockingQueue<IncomingPacket> packetInbox = new OpenMetaverse.BlockingQueue<IncomingPacket>(); | 113 | //private OpenMetaverse.BlockingQueue<IncomingPacket> packetInbox = new OpenMetaverse.BlockingQueue<IncomingPacket>(); |
114 | |||
115 | private DoubleQueue<IncomingPacket> packetInbox = new DoubleQueue<IncomingPacket>(); | ||
116 | |||
114 | /// <summary></summary> | 117 | /// <summary></summary> |
115 | //private UDPClientCollection m_clients = new UDPClientCollection(); | 118 | //private UDPClientCollection m_clients = new UDPClientCollection(); |
116 | /// <summary>Bandwidth throttle for this UDP server</summary> | 119 | /// <summary>Bandwidth throttle for this UDP server</summary> |
@@ -919,7 +922,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
919 | #endregion Ping Check Handling | 922 | #endregion Ping Check Handling |
920 | 923 | ||
921 | // Inbox insertion | 924 | // Inbox insertion |
922 | packetInbox.Enqueue(new IncomingPacket((LLClientView)client, packet)); | 925 | if (packet.Type == PacketType.AgentUpdate || |
926 | packet.Type == PacketType.ChatFromViewer) | ||
927 | packetInbox.EnqueueHigh(new IncomingPacket((LLClientView)client, packet)); | ||
928 | else | ||
929 | packetInbox.EnqueueLow(new IncomingPacket((LLClientView)client, packet)); | ||
923 | } | 930 | } |
924 | 931 | ||
925 | #region BinaryStats | 932 | #region BinaryStats |
@@ -1471,8 +1478,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1471 | Packet packet = incomingPacket.Packet; | 1478 | Packet packet = incomingPacket.Packet; |
1472 | LLClientView client = incomingPacket.Client; | 1479 | LLClientView client = incomingPacket.Client; |
1473 | 1480 | ||
1474 | if (client.IsActive) | 1481 | // if (client.IsActive) |
1475 | { | 1482 | // { |
1476 | m_currentIncomingClient = client; | 1483 | m_currentIncomingClient = client; |
1477 | 1484 | ||
1478 | try | 1485 | try |
@@ -1499,13 +1506,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1499 | { | 1506 | { |
1500 | m_currentIncomingClient = null; | 1507 | m_currentIncomingClient = null; |
1501 | } | 1508 | } |
1502 | } | 1509 | // } |
1503 | else | 1510 | // else |
1504 | { | 1511 | // { |
1505 | m_log.DebugFormat( | 1512 | // m_log.DebugFormat( |
1506 | "[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}", | 1513 | // "[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}", |
1507 | packet.Type, client.Name, m_scene.RegionInfo.RegionName); | 1514 | // packet.Type, client.Name, m_scene.RegionInfo.RegionName); |
1508 | } | 1515 | // } |
1509 | } | 1516 | } |
1510 | 1517 | ||
1511 | protected void LogoutHandler(IClientAPI client) | 1518 | protected void LogoutHandler(IClientAPI client) |
@@ -1519,4 +1526,112 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1519 | } | 1526 | } |
1520 | } | 1527 | } |
1521 | } | 1528 | } |
1529 | |||
1530 | internal class DoubleQueue<T> where T:class | ||
1531 | { | ||
1532 | private Queue<T> m_lowQueue = new Queue<T>(); | ||
1533 | private Queue<T> m_highQueue = new Queue<T>(); | ||
1534 | |||
1535 | private object m_syncRoot = new object(); | ||
1536 | private Semaphore m_s = new Semaphore(0, 1); | ||
1537 | |||
1538 | public DoubleQueue() | ||
1539 | { | ||
1540 | } | ||
1541 | |||
1542 | public virtual int Count | ||
1543 | { | ||
1544 | get { return m_highQueue.Count + m_lowQueue.Count; } | ||
1545 | } | ||
1546 | |||
1547 | public virtual void Enqueue(T data) | ||
1548 | { | ||
1549 | Enqueue(m_lowQueue, data); | ||
1550 | } | ||
1551 | |||
1552 | public virtual void EnqueueLow(T data) | ||
1553 | { | ||
1554 | Enqueue(m_lowQueue, data); | ||
1555 | } | ||
1556 | |||
1557 | public virtual void EnqueueHigh(T data) | ||
1558 | { | ||
1559 | Enqueue(m_highQueue, data); | ||
1560 | } | ||
1561 | |||
1562 | private void Enqueue(Queue<T> q, T data) | ||
1563 | { | ||
1564 | lock (m_syncRoot) | ||
1565 | { | ||
1566 | m_lowQueue.Enqueue(data); | ||
1567 | m_s.WaitOne(0); | ||
1568 | m_s.Release(); | ||
1569 | } | ||
1570 | } | ||
1571 | |||
1572 | public virtual T Dequeue() | ||
1573 | { | ||
1574 | return Dequeue(Timeout.Infinite); | ||
1575 | } | ||
1576 | |||
1577 | public virtual T Dequeue(int tmo) | ||
1578 | { | ||
1579 | return Dequeue(TimeSpan.FromMilliseconds(tmo)); | ||
1580 | } | ||
1581 | |||
1582 | public virtual T Dequeue(TimeSpan wait) | ||
1583 | { | ||
1584 | T res = null; | ||
1585 | |||
1586 | if (!Dequeue(wait, ref res)) | ||
1587 | return null; | ||
1588 | |||
1589 | return res; | ||
1590 | } | ||
1591 | |||
1592 | public bool Dequeue(int timeout, ref T res) | ||
1593 | { | ||
1594 | return Dequeue(TimeSpan.FromMilliseconds(timeout), ref res); | ||
1595 | } | ||
1596 | |||
1597 | public bool Dequeue(TimeSpan wait, ref T res) | ||
1598 | { | ||
1599 | if (!m_s.WaitOne(wait)) | ||
1600 | return false; | ||
1601 | |||
1602 | lock (m_syncRoot) | ||
1603 | { | ||
1604 | if (m_highQueue.Count > 0) | ||
1605 | res = m_highQueue.Dequeue(); | ||
1606 | else | ||
1607 | res = m_lowQueue.Dequeue(); | ||
1608 | |||
1609 | if (m_highQueue.Count == 0 && m_lowQueue.Count == 0) | ||
1610 | return true; | ||
1611 | |||
1612 | try | ||
1613 | { | ||
1614 | m_s.Release(); | ||
1615 | } | ||
1616 | catch | ||
1617 | { | ||
1618 | } | ||
1619 | |||
1620 | return true; | ||
1621 | } | ||
1622 | } | ||
1623 | |||
1624 | public virtual void Clear() | ||
1625 | { | ||
1626 | |||
1627 | lock (m_syncRoot) | ||
1628 | { | ||
1629 | // Make sure sem count is 0 | ||
1630 | m_s.WaitOne(0); | ||
1631 | |||
1632 | m_lowQueue.Clear(); | ||
1633 | m_highQueue.Clear(); | ||
1634 | } | ||
1635 | } | ||
1636 | } | ||
1522 | } | 1637 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index fe34ad4..df4bd0d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -3034,7 +3034,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3034 | /// <param name="objectGroup"></param> | 3034 | /// <param name="objectGroup"></param> |
3035 | public virtual void DetachFromBackup() | 3035 | public virtual void DetachFromBackup() |
3036 | { | 3036 | { |
3037 | m_scene.SceneGraph.FireDetachFromBackup(this); | 3037 | if (m_scene != null) |
3038 | m_scene.SceneGraph.FireDetachFromBackup(this); | ||
3038 | if (m_isBackedUp && Scene != null) | 3039 | if (m_isBackedUp && Scene != null) |
3039 | m_scene.EventManager.OnBackup -= ProcessBackup; | 3040 | m_scene.EventManager.OnBackup -= ProcessBackup; |
3040 | 3041 | ||