llClientView: try to have only one thread per client processing

RegionHandleRequests. (code assumes packet handle is called async as it is not)
avinationmerge
UbitUmarov 2012-09-08 12:22:40 +01:00
parent 71d2d327d0
commit a91ca984d5
1 changed files with 49 additions and 4 deletions

View File

@ -8751,16 +8751,61 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#region Parcel related packets
// acumulate several HandleRegionHandleRequest consecutive overlaping requests
// to be done with minimal resources as possible
// variables temporary here while in test
Queue<UUID> RegionHandleRequests = new Queue<UUID>();
bool RegionHandleRequestsInService = false;
private bool HandleRegionHandleRequest(IClientAPI sender, Packet Pack)
{
RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
UUID currentUUID;
RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest;
if (handlerRegionHandleRequest != null)
if (handlerRegionHandleRequest == null)
return true;
RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
lock (RegionHandleRequests)
{
handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID);
if (RegionHandleRequestsInService)
{
// we are already busy doing a previus request
// so enqueue it
RegionHandleRequests.Enqueue(rhrPack.RequestBlock.RegionID);
return true;
}
// else do it
currentUUID = rhrPack.RequestBlock.RegionID;
RegionHandleRequestsInService = true;
}
return true;
while (true)
{
handlerRegionHandleRequest(this, currentUUID);
lock (RegionHandleRequests)
{
// exit condition, nothing to do or closed
// current code seems to assume we may loose the handler at anytime,
// so keep checking it
handlerRegionHandleRequest = OnRegionHandleRequest;
if (RegionHandleRequests.Count == 0 || !IsActive || handlerRegionHandleRequest == null)
{
RegionHandleRequests.Clear();
RegionHandleRequestsInService = false;
return true;
}
currentUUID = RegionHandleRequests.Dequeue();
}
}
return true; // actually unreached
}
private bool HandleParcelInfoRequest(IClientAPI sender, Packet Pack)