throttle group notices to max of 4 threads at a time
...otherwise it can create hundreds of threads and hangavinationmerge
parent
5a78161e74
commit
86decb2aa8
|
@ -449,24 +449,37 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result);
|
||||||
/// delegate for sending a grid instant message asynchronously
|
|
||||||
/// </summary>
|
|
||||||
public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID);
|
|
||||||
|
|
||||||
protected virtual void GridInstantMessageCompleted(IAsyncResult iar)
|
private class GIM {
|
||||||
|
public GridInstantMessage im;
|
||||||
|
public MessageResultNotification result;
|
||||||
|
};
|
||||||
|
|
||||||
|
private Queue<GIM> pendingInstantMessages = new Queue<GIM>();
|
||||||
|
private int numInstantMessageThreads = 0;
|
||||||
|
|
||||||
|
private void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result)
|
||||||
{
|
{
|
||||||
GridInstantMessageDelegate icon =
|
lock (pendingInstantMessages) {
|
||||||
(GridInstantMessageDelegate)iar.AsyncState;
|
if (numInstantMessageThreads >= 4) {
|
||||||
icon.EndInvoke(iar);
|
GIM gim = new GIM();
|
||||||
|
gim.im = im;
|
||||||
|
gim.result = result;
|
||||||
|
pendingInstantMessages.Enqueue(gim);
|
||||||
|
} else {
|
||||||
|
++ numInstantMessageThreads;
|
||||||
|
m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: ++numInstantMessageThreads={0}", numInstantMessageThreads);
|
||||||
|
GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsyncMain;
|
||||||
|
d.BeginInvoke(im, result, GridInstantMessageCompleted, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void GridInstantMessageCompleted(IAsyncResult iar)
|
||||||
protected virtual void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result)
|
|
||||||
{
|
{
|
||||||
GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync;
|
GridInstantMessageDelegate d = (GridInstantMessageDelegate)iar.AsyncState;
|
||||||
|
d.EndInvoke(iar);
|
||||||
d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -481,8 +494,31 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||||
/// Pass in 0 the first time this method is called. It will be called recursively with the last
|
/// Pass in 0 the first time this method is called. It will be called recursively with the last
|
||||||
/// regionhandle tried
|
/// regionhandle tried
|
||||||
/// </param>
|
/// </param>
|
||||||
protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID)
|
private void SendGridInstantMessageViaXMLRPCAsyncMain(GridInstantMessage im, MessageResultNotification result)
|
||||||
{
|
{
|
||||||
|
GIM gim;
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
SendGridInstantMessageViaXMLRPCAsync(im, result, UUID.Zero);
|
||||||
|
} catch (Exception e) {
|
||||||
|
m_log.Error("[SendGridInstantMessageViaXMLRPC]: exception " + e.Message);
|
||||||
|
}
|
||||||
|
lock (pendingInstantMessages) {
|
||||||
|
if (pendingInstantMessages.Count > 0) {
|
||||||
|
gim = pendingInstantMessages.Dequeue();
|
||||||
|
im = gim.im;
|
||||||
|
result = gim.result;
|
||||||
|
} else {
|
||||||
|
gim = null;
|
||||||
|
-- numInstantMessageThreads;
|
||||||
|
m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: --numInstantMessageThreads={0}", numInstantMessageThreads);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (gim != null);
|
||||||
|
}
|
||||||
|
private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID)
|
||||||
|
{
|
||||||
|
|
||||||
UUID toAgentID = new UUID(im.toAgentID);
|
UUID toAgentID = new UUID(im.toAgentID);
|
||||||
|
|
||||||
PresenceInfo upd = null;
|
PresenceInfo upd = null;
|
||||||
|
|
Loading…
Reference in New Issue