| Steps To Reproduce | Previous behavior cuts off email size at 1024 total bytes, including subject+body. Patch sets it to 4096 bytes by default (as documented on LSL pages), but also makes the size limit configurable.
Further, many odd problems were occurring due to sleep time. There turned out to be a redundant 10 second sleep in EmailModule; the LSLApi was already sleeping 20 seconds. (Note that in my tests, even sleeping 20 seconds seems to cause problems when multiple emails are being sent by same script, but I left this as the default since that's what's documented.)
So, earlier behavior actually implemented a 30 second sleep.
(Odd problems with multiple emails in a row plus large sleep times may possibly point to other issues for scripts that sleep a long time. With a 1 second sleep duration between emails, they cranked along just fine and never froze. With the documentation-specified 20 second sleep duration, one or two emails would be sent fine, but then script never regained control; a call to llSendEmail would just never return to the calling script.) |
| Attached Files | 0001-Modifications-for-SMTP-in-OpenSimulator.patch [^] (8,918 bytes) 2012-05-13 21:29 [Show Content] [Hide Content]From 48611dfe06b427d7e5faf20397cd7a9be50813bb Mon Sep 17 00:00:00 2001
From: Chris Koeritz <fred@gruntose.com>
Date: Sun, 13 May 2012 16:58:47 -0400
Subject: [PATCH] Modifications for SMTP in OpenSimulator. Email size limit
was fixed (was out of step with documentation at 1024, so
boosted to 4096). Added configuration item for maximum
email size. Redundant sleep inside email module was fixed
(LSL Api was already sleeping). Added sleep time
configuration item for snooze between email sending for LSL
Api. Added two new configuration items (email_max_size and
email_pause_time) into the example OpenSim.ini, plus fixed
a spelling error (llimits) and odd tabbing.
Status: RO
Content-Length: 8199
Lines: 182
---
.../Scripting/EMailModules/EmailModule.cs | 24 +++-------------
.../Shared/Api/Implementation/LSL_Api.cs | 28 +++++++++++++++-----
bin/OpenSim.ini.example | 11 +++++--
3 files changed, 34 insertions(+), 29 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs
index 9255791..e91e8b9 100644
--- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs
@@ -64,6 +64,8 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
private TimeSpan m_QueueTimeout = new TimeSpan(2, 0, 0); // 2 hours without llGetNextEmail drops the queue
private string m_InterObjectHostname = "lsl.opensim.local";
+ private int m_MaxEmailSize = 4096; // largest email allowed by default, as per lsl docs.
+
// Scenes by Region Handle
private Dictionary<ulong, Scene> m_Scenes =
new Dictionary<ulong, Scene>();
@@ -127,6 +129,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT);
SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN);
SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD);
+ m_MaxEmailSize = SMTPConfig.GetInt("email_max_size", m_MaxEmailSize);
}
catch (Exception e)
{
@@ -176,18 +179,6 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
get { return true; }
}
- /// <summary>
- /// Delay function using thread in seconds
- /// </summary>
- /// <param name="seconds"></param>
- private void DelayInSeconds(int delay)
- {
- delay = (int)((float)delay * 1000);
- if (delay == 0)
- return;
- System.Threading.Thread.Sleep(delay);
- }
-
private bool IsLocal(UUID objectID)
{
string unused;
@@ -267,10 +258,9 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
m_log.Error("[EMAIL] REGEX Problem in EMail Address: "+address);
return;
}
- //FIXME:Check if subject + body = 4096 Byte
- if ((subject.Length + body.Length) > 1024)
+ if ((subject.Length + body.Length) > m_MaxEmailSize)
{
- m_log.Error("[EMAIL] subject + body > 1024 Byte");
+ m_log.Error("[EMAIL] subject + body larger than limit of " + m_MaxEmailSize + " bytes");
return;
}
@@ -345,10 +335,6 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
// TODO FIX
}
}
-
- //DONE: Message as Second Life style
- //20 second delay - AntiSpam System - for now only 10 seconds
- DelayInSeconds(10);
}
/// <summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 5b5cab8..5bff2e9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -106,6 +106,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected IUrlModule m_UrlModule = null;
protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache =
new Dictionary<UUID, UserInfoCacheEntry>();
+ protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp.
public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
{
@@ -113,6 +114,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host = host;
m_item = item;
+ LoadLimits(); // read script limits from config.
+
+ m_TransferModule =
+ m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>();
+ m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
+
+ AsyncCommands = new AsyncCommandManager(ScriptEngine);
+ }
+
+ /* load configuration items that affect script, object and run-time behavior. */
+ private void LoadLimits()
+ {
m_ScriptDelayFactor =
m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
m_ScriptDistanceFactor =
@@ -125,12 +138,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255);
if (m_notecardLineReadCharsMax > 65535)
m_notecardLineReadCharsMax = 65535;
-
- m_TransferModule =
- m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>();
- m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
-
- AsyncCommands = new AsyncCommandManager(ScriptEngine);
+ // load limits for particular subsystems.
+ IConfig SMTPConfig;
+ if ((SMTPConfig = m_ScriptEngine.ConfigSource.Configs["SMTP"]) != null) {
+ // there's an smtp config, so load in the snooze time.
+ EMAIL_PAUSE_TIME = SMTPConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME);
+ }
}
public override Object InitializeLifetimeService()
@@ -2877,6 +2890,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public virtual void llSleep(double sec)
{
+// m_log.Info("llSleep snoozing " + sec + "s.");
m_host.AddScriptLPS(1);
Thread.Sleep((int)(sec * 1000));
}
@@ -3130,7 +3144,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
emailModule.SendEmail(m_host.UUID, address, subject, message);
- ScriptSleep(20000);
+ llSleep(EMAIL_PAUSE_TIME);
}
public void llGetNextEmail(string address, string subject)
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index 50366a6..8e7e459 100755
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -273,6 +273,12 @@
;# {host_domain_header_from} {[Startup]emailmodule:DefaultEmailModule enabled:true} {From address to use in the sent email header?} {} 127.0.0.1
; host_domain_header_from = "127.0.0.1"
+ ;# {email_pause_time} {[Startup]emailmodule:DefaultEmailModule enabled:true} {Period in seconds to delay after an email is sent.} {} 20
+ ; email_pause_time = 20
+
+ ;# {email_max_size} {[Startup]emailmodule:DefaultEmailModule enabled:true} {Maximum total size of email in bytes.} {} 4096
+ ; email_max_size = 4096
+
;# {SMTP_SERVER_HOSTNAME} {[Startup]emailmodule:DefaultEmailModule enabled:true} {SMTP server name?} {} 127.0.0.1
; SMTP_SERVER_HOSTNAME = "127.0.0.1"
@@ -285,7 +291,6 @@
;# {SMTP_SERVER_PASSWORD} {[Startup]emailmodule:DefaultEmailModule enabled:true} {SMTP server password} {}
; SMTP_SERVER_PASSWORD = ""
-
[Network]
;; Configure the remote console user here. This will not actually be used
;; unless you use -console=rest at startup.
@@ -677,7 +682,7 @@
;; Sets the multiplier for the scripting delays
; ScriptDelayFactor = 1.0
- ;; The factor the 10 m distances llimits are multiplied by
+ ;; The factor the 10 m distances limits are multiplied by
; ScriptDistanceLimitFactor = 1.0
;; Maximum length of notecard line read
@@ -780,7 +785,7 @@
;; groups service if the service is using these keys
; XmlRpcServiceReadKey = 1234
; XmlRpcServiceWriteKey = 1234
-
+
[InterestManagement]
;# {UpdatePrioritizationScheme} {} {Update prioritization scheme?} {BestAvatarResponsiveness Time Distance SimpleAngularDistance FrontBack} BestAvatarResponsiveness
;; This section controls how state updates are prioritized for each client
--
1.7.5.4
|