- MMS server: better data model lock handling for performance improvements

pull/331/head
Michael Zillgith 5 years ago
parent 60d66e5ba4
commit 4dc971ba56

@ -70,18 +70,6 @@ private_IsoServer_decreaseConnectionCounter(IsoServer self);
LIB61850_INTERNAL int
private_IsoServer_getConnectionCounter(IsoServer self);
/**
* \brief User provided lock that will be called when higher layer (MMS) is called
*/
LIB61850_INTERNAL void
IsoServer_setUserLock(IsoServer self, Semaphore userLock);
LIB61850_INTERNAL void
IsoServer_userLock(IsoServer self);
LIB61850_INTERNAL void
IsoServer_userUnlock(IsoServer self);
LIB61850_INTERNAL bool
IsoConnection_isRunning(IsoConnection self);

@ -928,11 +928,19 @@ mmsServer_handleReadRequest(
request = &(mmsPdu->choice.confirmedRequestPdu.confirmedServiceRequest.choice.read);
if (request->variableAccessSpecification.present == VariableAccessSpecification_PR_listOfVariable) {
MmsServer_lockModel(connection->server);
handleReadListOfVariablesRequest(connection, request, invokeId, response);
MmsServer_unlockModel(connection->server);
}
#if (MMS_DATA_SET_SERVICE == 1)
else if (request->variableAccessSpecification.present == VariableAccessSpecification_PR_variableListName) {
MmsServer_lockModel(connection->server);
handleReadNamedVariableListRequest(connection, request, invokeId, response);
MmsServer_unlockModel(connection->server);
}
#endif
else {

@ -81,10 +81,6 @@ MmsServer_create(MmsDevice* device, TLSConfiguration tlsConfiguration)
if (isoServer == NULL)
goto exit_error;
#if (CONFIG_MMS_THREADLESS_STACK != 1)
IsoServer_setUserLock(isoServer, self->modelMutex);
#endif
LinkedList_add(self->isoServerList, isoServer);
}
@ -132,8 +128,6 @@ MmsServer_addAP(MmsServer self, const char* ipAddr, int tcpPort, TLSConfiguratio
if (isoServer) {
IsoServer_setUserLock(isoServer, self->modelMutex);
IsoServer_setLocalIpAddress(isoServer, ipAddr);
if (tcpPort != -1)
@ -479,7 +473,8 @@ mmsServer_setValue(MmsServer self, MmsDomain* domain, char* itemId, MmsValue* va
if (self->writeHandler != NULL) {
indication = self->writeHandler(self->writeHandlerParameter, domain,
itemId, value, connection);
} else {
}
else {
MmsValue* cachedValue;
if (domain == NULL)
@ -497,7 +492,6 @@ mmsServer_setValue(MmsServer self, MmsDomain* domain, char* itemId, MmsValue* va
return indication;
}
MmsValue*
mmsServer_getValue(MmsServer self, MmsDomain* domain, char* itemId, MmsServerConnection connection, bool isDirectAccess)
{

@ -501,6 +501,8 @@ mmsServer_handleWriteRequest(
goto exit_function;
}
MmsServer_lockModel(connection->server);
WriteRequest_t* writeRequest = &(mmsPdu->choice.confirmedRequestPdu.confirmedServiceRequest.choice.write);
if (writeRequest->variableAccessSpecification.present == VariableAccessSpecification_PR_variableListName) {
@ -701,6 +703,9 @@ end_of_main_loop:
}
exit_function:
MmsServer_unlockModel(connection->server);
asn_DEF_MmsPdu.free_struct(&asn_DEF_MmsPdu, mmsPdu, 0);
}

@ -329,7 +329,6 @@ IsoConnection_handleTcpConnection(IsoConnection self, bool isSingleThread)
ByteBuffer mmsResponseBuffer;
#if (CONFIG_MMS_THREADLESS_STACK != 1)
IsoServer_userLock(self->isoServer);
IsoConnection_lock(self);
#endif
@ -370,7 +369,6 @@ IsoConnection_handleTcpConnection(IsoConnection self, bool isSingleThread)
#if (CONFIG_MMS_THREADLESS_STACK != 1)
IsoConnection_unlock(self);
IsoServer_userUnlock(self->isoServer);
#endif
}
else {
@ -389,7 +387,6 @@ IsoConnection_handleTcpConnection(IsoConnection self, bool isSingleThread)
printf("ISO_SERVER: iso_connection: presentation ok\n");
#if (CONFIG_MMS_THREADLESS_STACK != 1)
IsoServer_userLock(self->isoServer);
IsoConnection_lock(self);
#endif
@ -418,7 +415,6 @@ IsoConnection_handleTcpConnection(IsoConnection self, bool isSingleThread)
#if (CONFIG_MMS_THREADLESS_STACK != 1)
IsoConnection_unlock(self);
IsoServer_userUnlock(self->isoServer);
#endif
}

@ -84,11 +84,6 @@ struct sIsoServer {
IsoConnection openClientConnections[CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS];
#endif /* (CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS == -1) */
#if (CONFIG_MMS_THREADLESS_STACK != 1)
/* used to control access to server data model */
Semaphore userLock;
#endif
#if (CONFIG_MMS_THREADLESS_STACK != 1) && (CONFIG_MMS_SINGLE_THREADED == 0)
Semaphore openClientConnectionsMutex; /* mutex for openClientConnections list */
Semaphore connectionCounterMutex;
@ -878,26 +873,3 @@ private_IsoServer_getConnectionCounter(IsoServer self)
return connectionCounter;
}
#if (CONFIG_MMS_THREADLESS_STACK != 1)
void
IsoServer_setUserLock(IsoServer self, Semaphore userLock)
{
self->userLock = userLock;
}
void
IsoServer_userLock(IsoServer self)
{
if (self->userLock != NULL)
Semaphore_wait(self->userLock);
}
void
IsoServer_userUnlock(IsoServer self)
{
if (self->userLock != NULL)
Semaphore_post(self->userLock);
}
#endif /* (CONFIG_MMS_THREADLESS_STACK != 1) */

Loading…
Cancel
Save