From e905bc242b3a0a685be37182b06ddd3d579cfd2b Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Mon, 3 Sep 2018 07:51:42 +0200 Subject: [PATCH] - MMS server: initialize maxConnections in IsoServer --- src/mms/iso_server/iso_server.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/mms/iso_server/iso_server.c b/src/mms/iso_server/iso_server.c index fe855496..ddd43d81 100644 --- a/src/mms/iso_server/iso_server.c +++ b/src/mms/iso_server/iso_server.c @@ -374,13 +374,15 @@ handleIsoConnections(IsoServer self) if ((connectionSocket = ServerSocket_accept((ServerSocket) self->serverSocket)) != NULL) { #if (CONFIG_MMS_SERVER_CONFIG_SERVICES_AT_RUNTIME == 1) - if (private_IsoServer_getConnectionCounter(self) >= self->maxConnections) { - if (DEBUG_ISO_SERVER) - printf("ISO_SERVER: maximum number of connections reached -> reject connection attempt.\n"); + if (self->maxConnections > -1) { + if (private_IsoServer_getConnectionCounter(self) >= self->maxConnections) { + if (DEBUG_ISO_SERVER) + printf("ISO_SERVER: maximum number of connections reached -> reject connection attempt.\n"); - Socket_destroy(connectionSocket); + Socket_destroy(connectionSocket); - return; + return; + } } #endif /* (CONFIG_MMS_SERVER_CONFIG_SERVICES_AT_RUNTIME == 1) */ @@ -427,13 +429,15 @@ handleIsoConnectionsThreadless(IsoServer self) if ((connectionSocket = ServerSocket_accept((ServerSocket) self->serverSocket)) != NULL) { #if (CONFIG_MMS_SERVER_CONFIG_SERVICES_AT_RUNTIME == 1) - if (private_IsoServer_getConnectionCounter(self) >= self->maxConnections) { - if (DEBUG_ISO_SERVER) - printf("ISO_SERVER: maximum number of connections reached -> reject connection attempt.\n"); + if (self->maxConnections > -1) { + if (private_IsoServer_getConnectionCounter(self) >= self->maxConnections) { + if (DEBUG_ISO_SERVER) + printf("ISO_SERVER: maximum number of connections reached -> reject connection attempt.\n"); - Socket_destroy(connectionSocket); + Socket_destroy(connectionSocket); - return; + return; + } } #endif /* (CONFIG_MMS_SERVER_CONFIG_SERVICES_AT_RUNTIME == 1) */ @@ -522,6 +526,10 @@ IsoServer_create(TLSConfiguration tlsConfiguration) self->openClientConnections = LinkedList_create(); #endif +#if (CONFIG_MMS_SERVER_CONFIG_SERVICES_AT_RUNTIME == 1) + self->maxConnections = CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS; +#endif + #if (CONFIG_MMS_THREADLESS_STACK != 1) && (CONFIG_MMS_SINGLE_THREADED == 0) self->connectionCounterMutex = Semaphore_create(1); self->openClientConnectionsMutex = Semaphore_create(1);