Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/lib/sttp.core/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
//
//******************************************************************************************************

#if NET
#define MONO
#endif

#if !MONO
#if !NET
using Microsoft.Win32;
#endif

Expand All @@ -40,7 +36,7 @@ public static class Common
{
static Common()
{
#if MONO
#if NET || MONO
UseManagedEncryption = true;
#else
const string FipsKeyOld = @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/sttp.core/DataPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ public override void Initialize()
PayloadAware = true,
PayloadMarker = null,
PayloadEndianOrder = EndianOrder.BigEndian,
MaxConnectionAttempts = 1,
MaxConnectionAttempts = -1,
CertificateFile = FilePath.GetAbsolutePath(localCertificate!),
CheckCertificateRevocation = checkCertificateRevocation,
CertificateChecker = m_certificateChecker,
Expand Down
24 changes: 13 additions & 11 deletions src/lib/sttp.core/DataSubscriber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2580,7 +2580,7 @@ private void ProcessServerResponse(byte[]? buffer, int length)
if (TotalBytesReceived == 0)
{
// At the point when data is being received, data monitor should be enabled
if (m_dataStreamMonitor is not null && m_dataStreamMonitor.Enabled)
if (m_dataStreamMonitor is not null && !m_dataStreamMonitor.Enabled)
m_dataStreamMonitor.Enabled = true;

// Establish run-time log for subscriber
Expand Down Expand Up @@ -2609,7 +2609,7 @@ private void ProcessServerResponse(byte[]? buffer, int length)

// Track total data packet bytes received from any channel
TotalBytesReceived += m_lastBytesReceived;
m_monitoredBytesReceived += m_lastBytesReceived;
Interlocked.Add(ref m_monitoredBytesReceived, m_lastBytesReceived);

// Get data packet flags
DataPacketFlags flags = (DataPacketFlags)buffer[responseIndex];
Expand Down Expand Up @@ -3156,7 +3156,7 @@ private void ParseTSSCMeasurements(byte[] buffer, int packetLength, SignalIndexC

Measurement measurement = new()
{
Metadata = key!.Metadata,
Metadata = key.Metadata,
Timestamp = time,
StateFlags = (MeasurementStateFlags)quality,
Value = value
Expand Down Expand Up @@ -4214,6 +4214,9 @@ private bool HandleSocketException(Exception? ex)
// Disconnect client, restarting if disconnect was not intentional
private void DisconnectClient()
{
if (m_dataStreamMonitor is not null)
m_dataStreamMonitor.Enabled = false;

// Mark end of any data transmission in run-time log
if (m_runTimeLog is not null && m_runTimeLog.Enabled)
{
Expand Down Expand Up @@ -4245,12 +4248,14 @@ private void DisconnectClient()
}
else
{
if (m_activeClientID != Guid.Empty)
m_serverCommandChannel.DisconnectOne(m_activeClientID);
Guid activeClientID = m_activeClientID;
m_activeClientID = Guid.Empty;

if (activeClientID != Guid.Empty)
m_serverCommandChannel.DisconnectOne(activeClientID);

// When subscriber is in server mode, the server does not need to be restarted, but we
// will reset client statistics - this is a server of "one" client, the publisher
m_activeClientID = Guid.Empty;
m_subscribedDevicesTimer?.Stop();
m_metadataRefreshPending = false;
m_expectedBufferBlockSequenceNumber = 0u;
Expand Down Expand Up @@ -4736,12 +4741,12 @@ protected string GetLoggingPath(string filePath)

private void DataStreamMonitor_Elapsed(object? sender, EventArgs<DateTime> e)
{
bool dataReceived = m_monitoredBytesReceived > 0;
bool dataReceived = Interlocked.Exchange(ref m_monitoredBytesReceived, 0L) > 0;

if (m_dataChannel is null && m_metadataRefreshPending)
{
if (m_lastReceivedAt > DateTime.MinValue)
dataReceived = (DateTime.UtcNow - m_lastReceivedAt).Seconds < DataLossInterval;
dataReceived = (DateTime.UtcNow - m_lastReceivedAt).TotalSeconds < DataLossInterval;
}

if (!dataReceived)
Expand All @@ -4758,9 +4763,6 @@ private void DataStreamMonitor_Elapsed(object? sender, EventArgs<DateTime> e)
DisconnectClient();
});
}

// Reset bytes received bytes being monitored
m_monitoredBytesReceived = 0L;
}

private void RunTimeLog_ProcessException(object? sender, EventArgs<Exception> e)
Expand Down
1 change: 0 additions & 1 deletion src/lib/sttp.gsf/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
1 change: 0 additions & 1 deletion src/lib/sttp.gsf/internal/RequiredMemberAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma warning disable

using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;

namespace System.Runtime.CompilerServices
{
Expand Down