Thank you, openlifegrid, for a patch to move new user connections to
thread pool threads.
Reworked by me to fit current trunk.
I believe that that patch may be beneficial in reducing the cases
in which regions become unresponsive and will no longer accept
new logins.
0.6.0-stable
Melanie Thielker 2008-09-06 04:21:36 +00:00
parent 01c34d5e04
commit b6b1e9e214
1 changed files with 27 additions and 1 deletions

View File

@ -30,6 +30,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Reflection;
using libsecondlife.Packets;
using log4net;
@ -69,6 +70,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected AssetCache m_assetCache;
protected AgentCircuitManager m_authenticateSessionsClass;
protected Queue<Packet> CreateUserPacket = new Queue<Packet>();
public LLPacketServer PacketServer
{
get { return m_packetServer; }
@ -236,7 +239,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
// new client
m_log.Debug("[UDPSERVER]: Adding New Client");
AddNewClient(packet);
UseCircuitCodePacket p = (UseCircuitCodePacket)packet;
@ -248,6 +250,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
ack_it.Packets[0].ID = packet.Header.Sequence;
ack_it.Header.Reliable = false;
SendPacketTo(ack_it.ToBytes(),ack_it.ToBytes().Length,SocketFlags.None,p.CircuitCode.Code);
// toss it to a worker thread so IOthread can go home
lock (CreateUserPacket)
{
CreateUserPacket.Enqueue(packet);
}
WaitCallback createUserCallback = new WaitCallback(AddNewClient);
ThreadPool.QueueUserWorkItem(createUserCallback);
}
}
catch (Exception e)
@ -311,6 +321,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
}
/// <summary>
/// target of workerthread delegate to create a new user.
/// It assumes we get fired for each new user packet that comes in.
/// </summary>
/// <param name="o"></param>
protected void AddNewClient(object o)
{
Packet packet;
lock (CreateUserPacket)
{
packet = CreateUserPacket.Dequeue();
}
if (null != packet)
AddNewClient(packet);
}
protected virtual void AddNewClient(Packet packet)
{
//Slave regions don't accept new clients