Thank you, DoranZemlja, for a patch that addresses some moe llGetNextEmail
issues. Fixes Mantis #3145.0.6.3-post-fixes
parent
38b1f2dbfc
commit
7ea2812a9e
|
@ -59,7 +59,9 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
||||||
|
|
||||||
private int m_MaxQueueSize = 50; // maximum size of an object mail queue
|
private int m_MaxQueueSize = 50; // maximum size of an object mail queue
|
||||||
private Dictionary<UUID, List<Email>> m_MailQueues = new Dictionary<UUID, List<Email>>();
|
private Dictionary<UUID, List<Email>> m_MailQueues = new Dictionary<UUID, List<Email>>();
|
||||||
private string m_InterObjectHostname;
|
private Dictionary<UUID, DateTime> m_LastGetEmailCall = new Dictionary<UUID, DateTime>();
|
||||||
|
private TimeSpan m_QueueTimeout = new TimeSpan(2, 0, 0); // 2 hours without llGetNextEmail drops the queue
|
||||||
|
private string m_InterObjectHostname = "lsl.opensim.local";
|
||||||
|
|
||||||
// Scenes by Region Handle
|
// Scenes by Region Handle
|
||||||
private Dictionary<ulong, Scene> m_Scenes =
|
private Dictionary<ulong, Scene> m_Scenes =
|
||||||
|
@ -69,19 +71,27 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
||||||
|
|
||||||
public void InsertEmail(UUID to, Email email)
|
public void InsertEmail(UUID to, Email email)
|
||||||
{
|
{
|
||||||
if (!m_MailQueues.ContainsKey(to))
|
// It's tempting to create the queue here. Don't; objects which have
|
||||||
{
|
// not yet called GetNextEmail should have no queue, and emails to them
|
||||||
m_MailQueues.Add(to, new List<Email>());
|
// should be silently dropped.
|
||||||
}
|
|
||||||
|
|
||||||
|
lock (m_MailQueues)
|
||||||
|
{
|
||||||
|
if (m_MailQueues.ContainsKey(to))
|
||||||
|
{
|
||||||
if (m_MailQueues[to].Count >= m_MaxQueueSize)
|
if (m_MailQueues[to].Count >= m_MaxQueueSize)
|
||||||
{
|
{
|
||||||
// fail silently
|
// fail silently
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lock (m_MailQueues[to])
|
||||||
|
{
|
||||||
m_MailQueues[to].Add(email);
|
m_MailQueues[to].Add(email);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Initialise(Scene scene, IConfigSource config)
|
public void Initialise(Scene scene, IConfigSource config)
|
||||||
{
|
{
|
||||||
|
@ -113,7 +123,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
||||||
}
|
}
|
||||||
|
|
||||||
m_HostName = SMTPConfig.GetString("host_domain_header_from", m_HostName);
|
m_HostName = SMTPConfig.GetString("host_domain_header_from", m_HostName);
|
||||||
m_InterObjectHostname = SMTPConfig.GetString("internal_object_host", "lsl.secondlife.com");
|
m_InterObjectHostname = SMTPConfig.GetString("internal_object_host", m_InterObjectHostname);
|
||||||
SMTP_SERVER_HOSTNAME = SMTPConfig.GetString("SMTP_SERVER_HOSTNAME", SMTP_SERVER_HOSTNAME);
|
SMTP_SERVER_HOSTNAME = SMTPConfig.GetString("SMTP_SERVER_HOSTNAME", SMTP_SERVER_HOSTNAME);
|
||||||
SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT);
|
SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT);
|
||||||
SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN);
|
SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN);
|
||||||
|
@ -279,16 +289,9 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
||||||
emailMessage.Subject = subject;
|
emailMessage.Subject = subject;
|
||||||
//TEXT Body
|
//TEXT Body
|
||||||
resolveNamePositionRegionName(objectID, out LastObjectName, out LastObjectPosition, out LastObjectRegionName);
|
resolveNamePositionRegionName(objectID, out LastObjectName, out LastObjectPosition, out LastObjectRegionName);
|
||||||
emailMessage.TextPart = new TextAttachment("Object-Name: " + LastObjectName +
|
emailMessage.BodyText = "Object-Name: " + LastObjectName +
|
||||||
"\r\nRegion: " + LastObjectRegionName + "\r\nLocal-Position: " +
|
"\nRegion: " + LastObjectRegionName + "\nLocal-Position: " +
|
||||||
LastObjectPosition + "\r\n\r\n" + body);
|
LastObjectPosition + "\n\n" + body;
|
||||||
|
|
||||||
//HTML Body
|
|
||||||
emailMessage.HtmlPart = new HtmlAttachment("<html><body><p>" +
|
|
||||||
"<BR>Object-Name: " + LastObjectName +
|
|
||||||
"<BR>Region: " + LastObjectRegionName +
|
|
||||||
"<BR>Local-Position: " + LastObjectPosition + "<BR><BR><BR>"
|
|
||||||
+ body + "\r\n</p></body><html>");
|
|
||||||
|
|
||||||
//Set SMTP SERVER config
|
//Set SMTP SERVER config
|
||||||
SmtpServer smtpServer = new SmtpServer(SMTP_SERVER_HOSTNAME, SMTP_SERVER_PORT);
|
SmtpServer smtpServer = new SmtpServer(SMTP_SERVER_HOSTNAME, SMTP_SERVER_PORT);
|
||||||
|
@ -309,7 +312,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
||||||
{
|
{
|
||||||
// inter object email, keep it in the family
|
// inter object email, keep it in the family
|
||||||
Email email = new Email();
|
Email email = new Email();
|
||||||
email.time = ((DateTime.UtcNow - new DateTime(1970,1,1,0,0,0)).TotalSeconds).ToString();
|
email.time = ((int)((DateTime.UtcNow - new DateTime(1970,1,1,0,0,0)).TotalSeconds)).ToString();
|
||||||
email.subject = subject;
|
email.subject = subject;
|
||||||
email.sender = objectID.ToString() + "@" + m_InterObjectHostname;
|
email.sender = objectID.ToString() + "@" + m_InterObjectHostname;
|
||||||
email.message = "Object-Name: " + LastObjectName +
|
email.message = "Object-Name: " + LastObjectName +
|
||||||
|
@ -341,11 +344,51 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
||||||
/// <param name="subject"></param>
|
/// <param name="subject"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Email GetNextEmail(UUID objectID, string sender, string subject)
|
public Email GetNextEmail(UUID objectID, string sender, string subject)
|
||||||
|
{
|
||||||
|
List<Email> queue = null;
|
||||||
|
|
||||||
|
lock (m_LastGetEmailCall)
|
||||||
|
{
|
||||||
|
if (m_LastGetEmailCall.ContainsKey(objectID))
|
||||||
|
{
|
||||||
|
m_LastGetEmailCall.Remove(objectID);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_LastGetEmailCall.Add(objectID, DateTime.Now);
|
||||||
|
|
||||||
|
// Hopefully this isn't too time consuming. If it is, we can always push it into a worker thread.
|
||||||
|
DateTime now = DateTime.Now;
|
||||||
|
List<UUID> removal = new List<UUID>();
|
||||||
|
foreach (UUID uuid in m_LastGetEmailCall.Keys)
|
||||||
|
{
|
||||||
|
if ((now - m_LastGetEmailCall[uuid]) > m_QueueTimeout)
|
||||||
|
{
|
||||||
|
removal.Add(uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (UUID remove in removal)
|
||||||
|
{
|
||||||
|
m_LastGetEmailCall.Remove(remove);
|
||||||
|
lock (m_MailQueues)
|
||||||
|
{
|
||||||
|
m_MailQueues.Remove(remove);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (m_MailQueues)
|
||||||
{
|
{
|
||||||
if (m_MailQueues.ContainsKey(objectID))
|
if (m_MailQueues.ContainsKey(objectID))
|
||||||
{
|
{
|
||||||
List<Email> queue = m_MailQueues[objectID];
|
queue = m_MailQueues[objectID];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (queue != null)
|
||||||
|
{
|
||||||
|
lock (queue)
|
||||||
|
{
|
||||||
if (queue.Count > 0)
|
if (queue.Count > 0)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -368,6 +411,14 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lock (m_MailQueues)
|
||||||
|
{
|
||||||
|
m_MailQueues.Add(objectID, new List<Email>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,6 +197,25 @@
|
||||||
;WorldMapModule = "WorldMap"
|
;WorldMapModule = "WorldMap"
|
||||||
;MapImageModule = "MapImageModule"
|
;MapImageModule = "MapImageModule"
|
||||||
|
|
||||||
|
|
||||||
|
; ##
|
||||||
|
; ## EMAIL MODULE
|
||||||
|
; ##
|
||||||
|
|
||||||
|
;emailmodule = DefaultEmailModule
|
||||||
|
|
||||||
|
[SMTP]
|
||||||
|
|
||||||
|
enabled=false
|
||||||
|
|
||||||
|
;enabled=true
|
||||||
|
;internal_object_host=lsl.opensim.local
|
||||||
|
;host_domain_header_from=127.0.0.1
|
||||||
|
;SMTP_SERVER_HOSTNAME=127.0.0.1
|
||||||
|
;SMTP_SERVER_PORT=25
|
||||||
|
;SMTP_SERVER_LOGIN=foo
|
||||||
|
;SMTP_SERVER_PASSWORD=bar
|
||||||
|
|
||||||
[Communications]
|
[Communications]
|
||||||
|
|
||||||
;InterregionComms = "LocalComms"
|
;InterregionComms = "LocalComms"
|
||||||
|
|
Loading…
Reference in New Issue