From ea4cc8a3688cfe952042f2b089b0fb9edf76e70a Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Mon, 15 Dec 2025 08:31:11 +0100 Subject: [PATCH] EgtExecutor : - in Redis modifica nomi variabili statiche di modulo. --- EXE_Redis.cpp | 72 +++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/EXE_Redis.cpp b/EXE_Redis.cpp index cc0c1e3..d0351bd 100644 --- a/EXE_Redis.cpp +++ b/EXE_Redis.cpp @@ -110,7 +110,7 @@ struct RedisSync { } } ; -static array vRedisClients ; +static array s_vRedisClients ; // Struttura per stato di Connessione Asincrona struct RedisConnectionStatus { @@ -190,7 +190,7 @@ class RedisAsync { void RedisEventLoop( bool bIsSub) const ; } ; -static array vAsyncRedisClients ; +static array s_vAsyncRedisClients ; // Mappa lettura Messaggi per Modalità Asicnrona struct RedisAsyncMessage { @@ -200,7 +200,7 @@ struct RedisAsyncMessage { string sMessage ; } ; -static unordered_map vAsyncRedisMessages ; +static unordered_map s_vAsyncRedisMessages ; // --------------------------------------------------------------------------- // [Redis] Funzione Ciclo degli eventi per Read/Write su Socket @@ -357,8 +357,8 @@ ExeRedisConnect( const string& sConnection, int& nIdConnection) { // Inizializzo una nuova connessione, recuperando l'Id int nMyIdConnection = NO_CONNECTION ; - for ( int i = 0 ; i < int( vRedisClients.size()) ; ++ i) { - if ( vRedisClients[i].bFreeConnection) { + for ( int i = 0 ; i < int( s_vRedisClients.size()) ; ++ i) { + if ( s_vRedisClients[i].bFreeConnection) { nMyIdConnection = i ; break ; } @@ -370,7 +370,7 @@ ExeRedisConnect( const string& sConnection, int& nIdConnection) } // Recupero i riferimenti necessari e blocco la connessione corrente - RedisSync& SyncRedisClient = vRedisClients[nMyIdConnection] ; + RedisSync& SyncRedisClient = s_vRedisClients[nMyIdConnection] ; SyncRedisClient.bFreeConnection = false ; RedisConnectionInfo& ConnectionInfo = SyncRedisClient.ConnectionInfo ; @@ -502,13 +502,13 @@ ExeRedisDisconnect( int nIdConnection) if ( ! CheckIdConnection( nMyIdConnection)) return false ; // Verifico che la connessione sia attiva - if ( vRedisClients[nMyIdConnection].bFreeConnection) { + if ( s_vRedisClients[nMyIdConnection].bFreeConnection) { LOG_INFO( GetCmdLogger(), "Error : Id Connection not found") return false ; } // Pulisco la connessione corrente - vRedisClients[nMyIdConnection].Clear() ; + s_vRedisClients[nMyIdConnection].Clear() ; LOG_INFO( GetCmdLogger(), "Disconnected to Redis !") ; return true ; @@ -525,13 +525,13 @@ ExeRedisSetValFromKey( int nIdConnection, const string& sKey, const string& sVal if ( ! CheckIdConnection( nMyIdConnection)) return false ; // Verifico che la connessione sia attiva - if ( vRedisClients[nMyIdConnection].bFreeConnection) { + if ( s_vRedisClients[nMyIdConnection].bFreeConnection) { LOG_INFO( GetCmdLogger(), "Error : Id Connection not found") return false ; } // Recupero la connessione corrente - RedisSync& RedisClient = vRedisClients[nMyIdConnection] ; + RedisSync& RedisClient = s_vRedisClients[nMyIdConnection] ; // Il valore associato alla chiave può essere solo di tipo stringa redisReply* reply = ( redisReply*)redisCommand( RedisClient.pRedisContext, "SET %s %s", sKey.c_str(), sVal.c_str()) ; @@ -562,13 +562,13 @@ ExeRedisGetValFromKey( int nIdConnection, const string& sKey, string& sVal) if ( ! CheckIdConnection( nMyIdConnection)) return false ; // Verifico che la connessione sia attiva - if ( vRedisClients[nMyIdConnection].bFreeConnection) { + if ( s_vRedisClients[nMyIdConnection].bFreeConnection) { LOG_INFO( GetCmdLogger(), "Error : Id Connection not found") return false ; } // Recupero la connessione corrente - RedisSync& RedisClient = vRedisClients[nMyIdConnection] ; + RedisSync& RedisClient = s_vRedisClients[nMyIdConnection] ; // Recupero il tipo associato alla chiave da Redis redisReply* typeReply = ( redisReply*)redisCommand( RedisClient.pRedisContext, "TYPE %s", sKey.c_str()) ; @@ -713,8 +713,8 @@ RedisPubSubUnsubMsgCallback( redisAsyncContext* ctx, void* r, void*) } // Aggiorno la Mappa dei Messaggi ( viene sempre sovrascritto all'ultimo) string sKey = GetMessageMapKey( MyStatus->nIdConnection, sChannel) ; - auto Iter = vAsyncRedisMessages.find( sKey) ; - if ( Iter != vAsyncRedisMessages.end()) { + auto Iter = s_vAsyncRedisMessages.find( sKey) ; + if ( Iter != s_vAsyncRedisMessages.end()) { RedisAsyncMessage& LockedMessage = Iter->second ; while ( LockedMessage.Lock.test_and_set( memory_order_acquire)) LockedMessage.Lock.wait( true, memory_order_relaxed) ; @@ -880,8 +880,8 @@ ExeRedisAsyncConnect( const string& sConnection, int& nIdConnection) { // Inizializzo una nuova connessione, recuperando l'Id int nMyIdConnection = NO_CONNECTION ; - for ( int i = 0 ; i < int( vAsyncRedisClients.size()) ; ++ i) { - if ( vAsyncRedisClients[i].m_bFreeConnection) { + for ( int i = 0 ; i < int( s_vAsyncRedisClients.size()) ; ++ i) { + if ( s_vAsyncRedisClients[i].m_bFreeConnection) { nMyIdConnection = i ; break ; } @@ -893,7 +893,7 @@ ExeRedisAsyncConnect( const string& sConnection, int& nIdConnection) } // Recupero i riferimenti necessari e blocco la connessione corrente - RedisAsync& AsyncRedisClient = vAsyncRedisClients[nMyIdConnection] ; + RedisAsync& AsyncRedisClient = s_vAsyncRedisClients[nMyIdConnection] ; AsyncRedisClient.m_bFreeConnection = false ; RedisConnectionInfo& ConnectionInfo = AsyncRedisClient.m_ConnectionInfo ; @@ -1066,13 +1066,13 @@ ExeRedisAsyncDisconnect( int nIdConnection) if ( ! CheckIdConnection( nMyIdConnection)) return false ; // Verifico che la connessione sia attiva - if ( vAsyncRedisClients[nMyIdConnection].m_bFreeConnection) { + if ( s_vAsyncRedisClients[nMyIdConnection].m_bFreeConnection) { LOG_INFO( GetCmdLogger(), "Error : Id Connection not found") return false ; } // Recupero la connessione - RedisAsync& AsyncRedisClient = vAsyncRedisClients[nMyIdConnection] ; + RedisAsync& AsyncRedisClient = s_vAsyncRedisClients[nMyIdConnection] ; // Effettuo la Disconnesione asincrona ( libera la memoria in automatico) redisAsyncDisconnect( AsyncRedisClient.m_pRedisAsyncPubContext) ; @@ -1098,9 +1098,9 @@ ExeRedisAsyncDisconnect( int nIdConnection) // ??? // Elimino i Messaggi dalla mappa - for ( auto Iter = vAsyncRedisMessages.begin() ; Iter != vAsyncRedisMessages.end() ; ) { + for ( auto Iter = s_vAsyncRedisMessages.begin() ; Iter != s_vAsyncRedisMessages.end() ; ) { if ( Iter->first.compare( GetMessageMapKey( nIdConnection, "")) == 0) - Iter = vAsyncRedisMessages.erase( Iter) ; + Iter = s_vAsyncRedisMessages.erase( Iter) ; else ++ Iter ; } @@ -1124,7 +1124,7 @@ ExeRedisAsyncPublish( int nIdConnection, const string& sChannel, const string& s if ( ! CheckIdConnection( nMyIdConnection)) return false ; // Verifico che la connessione sia attiva - if ( vAsyncRedisClients[nMyIdConnection].m_bFreeConnection) { + if ( s_vAsyncRedisClients[nMyIdConnection].m_bFreeConnection) { LOG_INFO( GetCmdLogger(), "Error : Id Connection not found") return false ; } @@ -1138,7 +1138,7 @@ ExeRedisAsyncPublish( int nIdConnection, const string& sChannel, const string& s LOG_INFO( GetCmdLogger(), "Warning : Empty Message") ; // Recupero la connessione - RedisAsync& AsyncRedisClient = vAsyncRedisClients[nMyIdConnection] ; + RedisAsync& AsyncRedisClient = s_vAsyncRedisClients[nMyIdConnection] ; // Eseguo il comando PUBLISH AsyncRedisClient.m_ConnectionPubStatus.bPublished = false ; @@ -1174,7 +1174,7 @@ ExeRedisAsyncSubscribe( int nIdConnection, const string& sChannel) if ( ! CheckIdConnection( nMyIdConnection)) return false ; // Verifico che la connessione sia attiva - if ( vAsyncRedisClients[nMyIdConnection].m_bFreeConnection) { + if ( s_vAsyncRedisClients[nMyIdConnection].m_bFreeConnection) { LOG_INFO( GetCmdLogger(), "Error : Id Connection not found") return false ; } @@ -1185,7 +1185,7 @@ ExeRedisAsyncSubscribe( int nIdConnection, const string& sChannel) } // Recupero la connessione - RedisAsync& AsyncRedisClient = vAsyncRedisClients[nMyIdConnection] ; + RedisAsync& AsyncRedisClient = s_vAsyncRedisClients[nMyIdConnection] ; // Eseguo il comando SUBSCRIBE AsyncRedisClient.m_ConnectionPubStatus.bSubscribed = false ; @@ -1206,8 +1206,8 @@ ExeRedisAsyncSubscribe( int nIdConnection, const string& sChannel) // Aggiorno la Mappa per la lettura dei Messaggio string sKey = GetMessageMapKey( nIdConnection, sChannel) ; - vAsyncRedisMessages.try_emplace( sKey) ; - vAsyncRedisMessages[sKey].Lock.clear() ; + s_vAsyncRedisMessages.try_emplace( sKey) ; + s_vAsyncRedisMessages[sKey].Lock.clear() ; #if DEBUG double dMsSubscribeTime = chrono::duration_cast( chrono::steady_clock::now() - tStart).count() ; @@ -1227,7 +1227,7 @@ ExeRedisAsyncUnsubscribe( int nIdConnection, const string& sChannel) if ( ! CheckIdConnection( nMyIdConnection)) return false ; // Verifico che la connessione sia attiva - if ( vAsyncRedisClients[nMyIdConnection].m_bFreeConnection) { + if ( s_vAsyncRedisClients[nMyIdConnection].m_bFreeConnection) { LOG_INFO( GetCmdLogger(), "Error : Id Connection not found") return false ; } @@ -1238,7 +1238,7 @@ ExeRedisAsyncUnsubscribe( int nIdConnection, const string& sChannel) } // Recupero la connessione - RedisAsync& AsyncRedisClient = vAsyncRedisClients[nMyIdConnection] ; + RedisAsync& AsyncRedisClient = s_vAsyncRedisClients[nMyIdConnection] ; // Eseguo il comando UNSUBSCRIBE AsyncRedisClient.m_ConnectionPubStatus.bUnsubscribed = false ; @@ -1258,9 +1258,9 @@ ExeRedisAsyncUnsubscribe( int nIdConnection, const string& sChannel) } // Elimino i Messaggi dalla mappa - for ( auto Iter = vAsyncRedisMessages.begin() ; Iter != vAsyncRedisMessages.end() ; ) { + for ( auto Iter = s_vAsyncRedisMessages.begin() ; Iter != s_vAsyncRedisMessages.end() ; ) { if ( Iter->first.compare( GetMessageMapKey( nIdConnection, sChannel)) == 0) - Iter = vAsyncRedisMessages.erase( Iter) ; + Iter = s_vAsyncRedisMessages.erase( Iter) ; else ++ Iter ; } @@ -1285,7 +1285,7 @@ ExeRedisAsyncSubscribeOneMessage( int nIdConnection, const string& sChannel, dou if ( ! CheckIdConnection( nMyIdConnection)) return false ; // Verifico che la connessione sia attiva - if ( vAsyncRedisClients[nMyIdConnection].m_bFreeConnection) { + if ( s_vAsyncRedisClients[nMyIdConnection].m_bFreeConnection) { LOG_INFO( GetCmdLogger(), "Error : Id Connection not found") return false ; } @@ -1301,7 +1301,7 @@ ExeRedisAsyncSubscribeOneMessage( int nIdConnection, const string& sChannel, dou } // Recupero la connessione - RedisAsync& AsyncRedisClient = vAsyncRedisClients[nMyIdConnection] ; + RedisAsync& AsyncRedisClient = s_vAsyncRedisClients[nMyIdConnection] ; // Invio del comando di SUBSCRIBE AsyncRedisClient.m_ConnectionSubStatus.bMessage = false ; @@ -1354,7 +1354,7 @@ ExeRedisAsyncGetMessage( int nIdConnection, const string& sChannel, int& nCount, if ( ! CheckIdConnection( nMyIdConnection)) return false ; // Verifico che la connessione sia attiva - if ( vAsyncRedisClients[nMyIdConnection].m_bFreeConnection) { + if ( s_vAsyncRedisClients[nMyIdConnection].m_bFreeConnection) { LOG_INFO( GetCmdLogger(), "Error : Id Connection not found") return false ; } @@ -1366,8 +1366,8 @@ ExeRedisAsyncGetMessage( int nIdConnection, const string& sChannel, int& nCount, // Recupero la Chiave di accesso alla Mappa dei Messaggi string sKey = GetMessageMapKey( nIdConnection, sChannel) ; - auto Iter = vAsyncRedisMessages.find( sKey) ; - if ( Iter == vAsyncRedisMessages.end()) { + auto Iter = s_vAsyncRedisMessages.find( sKey) ; + if ( Iter == s_vAsyncRedisMessages.end()) { LOG_INFO( GetCmdLogger(), "Error : Connection not Subscribed to this Channel") ; return false ; }