From f2c811c7c7a58e8be1f2ff74c6f2f98d91217d5d Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Sat, 23 Mar 2019 17:05:42 +0100 Subject: [PATCH] - IedServer: fixed potential deadlock when IedServer_stop is directly called after IedServer_start --- .../IEC61850forCSharp/ReportControlBlock.cs | 57 +++++++++++-------- src/iec61850/server/impl/ied_server.c | 6 +- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/dotnet/IEC61850forCSharp/ReportControlBlock.cs b/dotnet/IEC61850forCSharp/ReportControlBlock.cs index e5b0ad2a..dfdfa824 100644 --- a/dotnet/IEC61850forCSharp/ReportControlBlock.cs +++ b/dotnet/IEC61850forCSharp/ReportControlBlock.cs @@ -746,32 +746,41 @@ namespace IEC61850 flagOptFlds = true; } - /// - /// Gets the ResvTms (reservation time) value - /// - /// - /// Only for BRCB. - /// Value of -1 indicate the BRCB is exclusively reserved for a set of client based upon configuration. - /// Value of 0 means that the BRCB is not reserved. - /// Positive value indicates that the BRCB is reserved dynamically and the value is the number of - /// seconds for reservation after association loss. - /// - /// The reservation time - public Int16 GetResvTms() - { - return ClientReportControlBlock_getResvTms (self); - } + /// + /// Check if the report control block has the "ResvTms" attribute. + /// + /// true, if ResvTms is available, false otherwise. + public bool HasResvTms() + { + return ClientReportControlBlock_hasResvTms(self); + } - /// - /// Sets the ResvTms (reservation time) value - /// - /// the reservation time value - public void SetResvTms(Int16 resvTms) - { - ClientReportControlBlock_setResvTms (self, resvTms); + /// + /// Gets the ResvTms (reservation time) value + /// + /// + /// Only for BRCB. + /// Value of -1 indicate the BRCB is exclusively reserved for a set of client based upon configuration. + /// Value of 0 means that the BRCB is not reserved. + /// Positive value indicates that the BRCB is reserved dynamically and the value is the number of + /// seconds for reservation after association loss. + /// + /// The reservation time + public Int16 GetResvTms() + { + return ClientReportControlBlock_getResvTms(self); + } - flagResvTms = true; - } + /// + /// Sets the ResvTms (reservation time) value + /// + /// the reservation time value + public void SetResvTms(Int16 resvTms) + { + ClientReportControlBlock_setResvTms(self, resvTms); + + flagResvTms = true; + } /// /// Gets the current owner of the RCB diff --git a/src/iec61850/server/impl/ied_server.c b/src/iec61850/server/impl/ied_server.c index 072733fb..5ca28a5b 100644 --- a/src/iec61850/server/impl/ied_server.c +++ b/src/iec61850/server/impl/ied_server.c @@ -567,9 +567,6 @@ singleThreadedServerThread(void* parameter) bool running = true; - mmsMapping->reportThreadFinished = false; - mmsMapping->reportThreadRunning = true; - if (DEBUG_IED_SERVER) printf("IED_SERVER: server thread started!\n"); @@ -602,6 +599,9 @@ IedServer_start(IedServer self, int tcpPort) #if (CONFIG_MMS_SINGLE_THREADED == 1) MmsServer_startListeningThreadless(self->mmsServer, tcpPort); + self->mmsMapping->reportThreadFinished = false; + self->mmsMapping->reportThreadRunning = true; + self->serverThread = Thread_create((ThreadExecutionFunction) singleThreadedServerThread, (void*) self, false); Thread_start(self->serverThread);