Skip to content

Commit

Permalink
Merged PR 521: RELEASE: Version 3.2.19.2 released.
Browse files Browse the repository at this point in the history
RELEASE: Version 3.2.19.2 released.

BUG: ASP.NET integration features such as bandwidth monitoring and profile overrides previously stored their 'enabled' setting in HttpApplicationState. This uses a lot of locking which could cause problems in highly concurrent web applications. The setting will now be stored in a static field instead.
DATA: Updated the Lite Binary files for November 2017.
  • Loading branch information
Joseph51D committed Dec 4, 2017
2 parents 061ea46 + 42f7830 commit 1320748
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 59 deletions.
7 changes: 2 additions & 5 deletions FoundationV3/FiftyOne.Foundation 4.project.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@
".NETFramework,Version=v4.0": []
},
"tools": {},
"projectFileToolGroups": {},
"packageFolders": {
"C:\\Users\\Stephen\\.nuget\\packages\\": {}
}
}
"projectFileToolGroups": {}
}
23 changes: 14 additions & 9 deletions FoundationV3/Mobile/Detection/Feature/Bandwidth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,16 @@ internal int AverageBandwidth

#endregion

#region HttpModule Events
#region Fields
/// <summary>
/// True if bandwidth monitoring is enabled.
/// </summary>
private static bool? _enabled;
#endregion

#region HttpModule Events
/// <summary>
/// Set a property in the application state to quickly determine if bandwidth monitoring
/// Set a static field to quickly determine if bandwidth monitoring
/// is supported by the data set.
/// </summary>
/// <param name="application"></param>
Expand All @@ -303,14 +309,14 @@ internal static void Init(HttpApplicationState application)
if (Configuration.Manager.BandwidthMonitoringEnabled == false ||
WebProvider.ActiveProvider == null)
{
application["51D_Bandwidth"] = new bool?(false);
_enabled = false;
}
else
{
var property = WebProvider.ActiveProvider.DataSet.Properties["JavascriptBandwidth"];
application["51D_Bandwidth"] = new bool?(property != null);
_enabled = property != null;
}
EventLog.Debug(String.Format("Bandwidth monitoring '{0}'", application["51D_Bandwidth"]));
EventLog.Debug(String.Format("Bandwidth monitoring '{0}'", _enabled));
}

/// <summary>
Expand Down Expand Up @@ -451,15 +457,14 @@ internal static void PostRequestHandlerExecute(HttpContext context)
}

/// <summary>
/// Determines if the feature is enabled based on the information
/// written to the application when initialised.
/// Determines if the feature is enabled based on configuration
/// when initialised.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
internal static bool GetIsEnabled(HttpContext context)
{
var enabled = context.Application["51D_Bandwidth"] as bool?;
if (enabled.HasValue && enabled.Value)
if (_enabled.HasValue && _enabled.Value)
{
// If the bandwidth javascript is present for this device then it's enabled.
var javascript = GetJavascriptValues(context.Request);
Expand Down
38 changes: 25 additions & 13 deletions FoundationV3/Mobile/Detection/Feature/ImageOptimiser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,29 @@ internal class ImageOptimiser
private const string AUTO_STRING = "auto";

/// <summary>
/// Set a property in the application state to quickly determine if image optimisation
/// True if image optimiser is enabled.
/// </summary>
private static bool? _enabled;

/// <summary>
/// Get or set the enabled flag against the image optimisation service
/// </summary>
public static bool Enabled
{
get { return _enabled ?? false; }
set { _enabled = value; }
}

/// <summary>
/// Set a static field to quickly determine if image optimisation
/// is supported by the data set.
/// </summary>
/// <param name="application"></param>
internal static void Init(HttpApplicationState application)
{
application["51D_ImageOptimiser"] = new bool?(Manager.ImageOptimisation.Enabled &&
WebProvider.ActiveProvider != null);
EventLog.Debug(String.Format("Image Optimisation '{0}'", application["51D_ImageOptimiser"]));
_enabled = Manager.ImageOptimisation.Enabled &&
WebProvider.ActiveProvider != null;
EventLog.Debug(String.Format("Image Optimisation '{0}'", _enabled));
}

/// <summary>
Expand Down Expand Up @@ -126,28 +140,26 @@ private static Values GetJavascriptValues(HttpRequest request)
}

/// <summary>
/// Determines if the feature is enabled based on the information
/// written to the application when initialised.
/// Determines if the feature is enabled based on configuration
/// when initialised.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
internal static bool GetIsEnabled(HttpContext context)
{
var enabled = context.Application["51D_ImageOptimiser"] as bool?;
return enabled.HasValue && enabled.Value;
return _enabled.HasValue && _enabled.Value;
}

/// <summary>
/// Determines if the feature is enabled based on the information
/// written to the application when initialised and the presence of
/// image optimiser java script in the detected device results.
/// Determines if the feature is enabled based on configuration
/// when initialised and the presence of image optimiser
/// Java script in the detected device results.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
internal static bool GetIsJavaScriptEnabled(HttpContext context)
{
var enabled = context.Application["51D_ImageOptimiser"] as bool?;
if (enabled.HasValue && enabled.Value)
if (_enabled.HasValue && _enabled.Value)
{
// If the image optimiser javascript is present for this device then it's enabled.
return GetJavascriptValues(context.Request) != null;
Expand Down
20 changes: 12 additions & 8 deletions FoundationV3/Mobile/Detection/Feature/ProfileOverride.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ internal static class ProfileOverride
private static readonly char[] _split = new char[] { '|' };

/// <summary>
/// Set a property in the application state to quickly determine if profile
/// True if profile overrides are enabled.
/// </summary>
private static bool? _enabled;

/// <summary>
/// Set a static field to quickly determine if profile
/// override is supported.
/// </summary>
/// <param name="application"></param>
Expand All @@ -46,15 +51,15 @@ internal static void Init(HttpApplicationState application)
if (Configuration.Manager.FeatureDetectionEnabled == false ||
WebProvider.ActiveProvider == null)
{
application[Constants.ProfileOverrideCookieName] = new bool?(false);
_enabled = false;
}
else
{
var property = WebProvider.ActiveProvider.DataSet.Properties.FirstOrDefault(i =>
i.Name == "JavascriptHardwareProfile");
application[Constants.ProfileOverrideCookieName] = new bool?(property != null);
_enabled = property != null;
}
EventLog.Debug(String.Format("Profile Override '{0}'", application[Constants.ProfileOverrideCookieName]));
EventLog.Debug(String.Format("Profile Override '{0}'", _enabled));
}

/// <summary>
Expand Down Expand Up @@ -96,15 +101,14 @@ internal static string GetJavascript(HttpContext context)
}

/// <summary>
/// Determines if the feature is enabled based on the information
/// written to the application when initialised.
/// Determines if the feature is enabled based on configuration
/// when initialised.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
private static bool GetIsEnabled(HttpContext context)
{
var enabled = context.Application[Constants.ProfileOverrideCookieName] as bool?;
if (enabled.HasValue && enabled.Value)
if (_enabled.HasValue && _enabled.Value)
{
// If the profile javascript is present for this device then it's enabled.
return GetJavascriptValues(context.Request) != null;
Expand Down
23 changes: 13 additions & 10 deletions FoundationV3/Mobile/Detection/Feature/PropertyValueOverride.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ namespace FiftyOne.Foundation.Mobile.Detection.Feature
{
internal static class PropertyValueOverride
{
#region Fields
/// <summary>
/// True if profile overrides are enabled.
/// </summary>
private static bool? _enabled;
#endregion

#region Internal Methods

/// <summary>
/// Set a property in the application state to quickly determine if property
/// Set a static field to quickly determine if property
/// value override is supported.
/// </summary>
/// <param name="application"></param>
Expand All @@ -43,18 +50,15 @@ internal static void Init(HttpApplicationState application)
if (Configuration.Manager.FeatureDetectionEnabled == false ||
WebProvider.ActiveProvider == null)
{
application[Constants.PropertyValueOverrideFlag] =
new bool?(false);
_enabled = false;
}
else
{
application[Constants.PropertyValueOverrideFlag] = new bool?(
WebProvider.GetActiveProvider().DataSet.
PropertyValueOverrideProperties.Length > 0);
_enabled = WebProvider.GetActiveProvider().DataSet.
PropertyValueOverrideProperties.Length > 0;
}
EventLog.Debug(String.Format(
"Property Value Override '{0}'",
application[Constants.PropertyValueOverrideFlag]));
"Property Value Override '{0}'", _enabled));
}

/// <summary>
Expand All @@ -64,8 +68,7 @@ internal static void Init(HttpApplicationState application)
/// <returns>JavaScript for the device, otherwise null.</returns>
internal static string GetJavascript(HttpContext context)
{
var enabled = context.Application[Constants.PropertyValueOverrideFlag] as bool?;
if (enabled.HasValue && enabled.Value)
if (_enabled.HasValue && _enabled.Value)
{
var jsvalues = GetJavascriptValues(context.Request);
if (jsvalues.Count > 0)
Expand Down
4 changes: 2 additions & 2 deletions FoundationV3/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
// Build Number
// Revision

[assembly: AssemblyVersion("3.2.18.2")]
[assembly: AssemblyFileVersion("3.2.18.2")]
[assembly: AssemblyVersion("3.2.19.2")]
[assembly: AssemblyFileVersion("3.2.19.2")]
[assembly: NeutralResourcesLanguage("en-GB")]
[assembly: AllowPartiallyTrustedCallers]
4 changes: 3 additions & 1 deletion FoundationV3/Properties/DetectionConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public static class Constants

#region Internal Constants

#if !SQL_BUILD && !NETCORE_BUILD
/// <summary>
/// The name of the category
/// <see cref="FiftyOne.Foundation.Mobile.Detection.Entities.Property.PropertyValueType.JavaScript"/>
Expand All @@ -125,7 +126,8 @@ public static class Constants
/// methods must be assigned.
/// </summary>
internal const string PropertyValueOverrideCategory = "Property Value Override";

#endif

/// <summary>
/// Used to split up a cookie string.
/// </summary>
Expand Down
6 changes: 2 additions & 4 deletions FoundationV3/UI/Web/ShareUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* defined by the Mozilla Public License, v. 2.0.
* ********************************************************************* */

using FiftyOne.Foundation.Mobile.Detection.Feature;
using System;
using System.Web.UI.WebControls;

Expand Down Expand Up @@ -422,10 +423,7 @@ private void _checkBoxImageOptimiser_CheckedChanged(object sender, EventArgs e)
try
{
FiftyOne.Foundation.Mobile.Configuration.Manager.ImageOptimisation.Enabled = _checkBoxImageOptimiser.Checked;



Context.Application["51D_ImageOptimiser"] = _checkBoxImageOptimiser.Checked;
ImageOptimiser.Enabled = _checkBoxImageOptimiser.Checked;

message = String.Format(
_checkBoxImageOptimiser.Checked ?
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ Data files which are updated weekly and daily, automatically, and with more prop

## Recent Changes

### Version 3.2.18 Highlights
### Version 3.2.19 Highlights

* Updated Lite data files for Sept 2017
* Updates to patent notification text
* ASP.NET integration features such as bandwidth monitoring and profile overrides previously stored their 'enabled' setting in HttpApplicationState. This uses a lot of locking which could cause problems in highly concurrent web applications. The setting will now be stored in a static field instead.
* Updated the Lite Binary files for November 2017.

### Major Changes in Version 3.2

Expand Down
4 changes: 2 additions & 2 deletions data/51Degrees-LiteV3.1.dat
Git LFS file not shown
4 changes: 2 additions & 2 deletions data/51Degrees-LiteV3.2.dat
Git LFS file not shown

0 comments on commit 1320748

Please sign in to comment.