fixed bugs detected by clng analyzer
authorVictor Kirhenshtein <victor@netxms.org>
Wed, 5 Aug 2015 20:01:17 +0000 (23:01 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Wed, 5 Aug 2015 20:01:17 +0000 (23:01 +0300)
include/nxdbapi.h
src/db/libnxdb/dbcp.cpp
src/libnxsl/vm.cpp
src/server/core/main.cpp
src/server/core/node.cpp
src/server/libnxsrv/ndd.cpp

index be97983..8dd8eab 100644 (file)
@@ -200,7 +200,7 @@ void LIBNXDB_EXPORTABLE DecodeSQLString(TCHAR *pszStr);
 bool LIBNXDB_EXPORTABLE DBConnectionPoolStartup(DB_DRIVER driver, const TCHAR *server, const TCHAR *dbName,
                                                                                                                                const TCHAR *login, const TCHAR *password, const TCHAR *schema,
                                                                                                                                int basePoolSize, int maxPoolSize, int cooldownTime,
-                                                                                                                               int connTTL, DB_HANDLE fallback);
+                                                                                                                               int connTTL);
 void LIBNXDB_EXPORTABLE DBConnectionPoolShutdown();
 DB_HANDLE LIBNXDB_EXPORTABLE __DBConnectionPoolAcquireConnection(const char *srcFile, int srcLine);
 #define DBConnectionPoolAcquireConnection() __DBConnectionPoolAcquireConnection(__FILE__, __LINE__)
index aab6a0a..23cda74 100644 (file)
@@ -37,7 +37,6 @@ static int m_connectionTTL;
 
 static MUTEX m_poolAccessMutex = INVALID_MUTEX_HANDLE;
 static ObjectArray<PoolConnectionInfo> m_connections;
-static DB_HANDLE m_hFallback;
 static THREAD m_maintThread = INVALID_THREAD_HANDLE;
 static CONDITION m_condShutdown = INVALID_CONDITION_HANDLE;
 static CONDITION m_condRelease = INVALID_CONDITION_HANDLE;
@@ -210,7 +209,7 @@ static THREAD_RESULT THREAD_CALL MaintenanceThread(void *arg)
 bool LIBNXDB_EXPORTABLE DBConnectionPoolStartup(DB_DRIVER driver, const TCHAR *server, const TCHAR *dbName,
                                                                                                                                const TCHAR *login, const TCHAR *password, const TCHAR *schema,
                                                                                                                                int basePoolSize, int maxPoolSize, int cooldownTime,
-                                                                                                                               int connTTL, DB_HANDLE fallback)
+                                                                                                                               int connTTL)
 {
        m_driver = driver;
        nx_strncpy(m_server, CHECK_NULL_EX(server), 256);
@@ -223,7 +222,6 @@ bool LIBNXDB_EXPORTABLE DBConnectionPoolStartup(DB_DRIVER driver, const TCHAR *s
        m_maxPoolSize = maxPoolSize;
        m_cooldownTime = cooldownTime;
    m_connectionTTL = connTTL;
-       m_hFallback = fallback;
 
        m_poolAccessMutex = MutexCreate();
    m_connections.setOwner(true);
@@ -323,7 +321,6 @@ retry:
 
        if (handle == NULL)
        {
-               handle = m_hFallback;
        __DBDbgPrintf(1, _T("Database Connection Pool exhausted (call from %hs:%d)"), srcFile, srcLine);
       ConditionWait(m_condRelease, 10000);
       __DBDbgPrintf(5, _T("Database Connection Pool: retry acquire connection (call from %hs:%d)"), srcFile, srcLine);
@@ -339,9 +336,6 @@ retry:
  */
 void LIBNXDB_EXPORTABLE DBConnectionPoolReleaseConnection(DB_HANDLE handle)
 {
-       if (handle == m_hFallback)
-               return;
-
        MutexLock(m_poolAccessMutex);
 
    for(int i = 0; i < m_connections.size(); i++)
index 94c68a6..689cb3a 100644 (file)
@@ -1215,7 +1215,7 @@ void NXSL_VM::getOrUpdateArrayElement(int opcode, NXSL_Value *array, NXSL_Value
 
       if (opcode == OPCODE_INCP_ELEMENT)
       {
-         if (element->isNumeric())
+         if ((element != NULL) && element->isNumeric())
          {
             element->increment();
          }
@@ -1226,7 +1226,7 @@ void NXSL_VM::getOrUpdateArrayElement(int opcode, NXSL_Value *array, NXSL_Value
       }
       else if (opcode == OPCODE_DECP_ELEMENT)
       {
-         if (element->isNumeric())
+         if ((element != NULL) && element->isNumeric())
          {
             element->decrement();
          }
@@ -1240,7 +1240,7 @@ void NXSL_VM::getOrUpdateArrayElement(int opcode, NXSL_Value *array, NXSL_Value
 
       if (opcode == OPCODE_INC_ELEMENT)
       {
-         if (element->isNumeric())
+         if ((element != NULL) && element->isNumeric())
          {
             element->increment();
          }
@@ -1251,7 +1251,7 @@ void NXSL_VM::getOrUpdateArrayElement(int opcode, NXSL_Value *array, NXSL_Value
       }
       else if (opcode == OPCODE_DEC_ELEMENT)
       {
-         if (element->isNumeric())
+         if ((element != NULL) && element->isNumeric())
          {
             element->decrement();
          }
index 6973cde..3b32eb0 100644 (file)
@@ -634,7 +634,7 @@ BOOL NXCORE_EXPORTABLE Initialize()
        int baseSize = ConfigReadInt(_T("ConnectionPoolBaseSize"), 5);
        int maxSize = ConfigReadInt(_T("ConnectionPoolMaxSize"), 20);
        int cooldownTime = ConfigReadInt(_T("ConnectionPoolCooldownTime"), 300);
-       DBConnectionPoolStartup(g_dbDriver, g_szDbServer, g_szDbName, g_szDbLogin, g_szDbPassword, g_szDbSchema, baseSize, maxSize, cooldownTime, 0, g_hCoreDB);
+       DBConnectionPoolStartup(g_dbDriver, g_szDbServer, g_szDbName, g_szDbLogin, g_szDbPassword, g_szDbSchema, baseSize, maxSize, cooldownTime, 0);
    g_flags |= AF_DB_CONNECTION_POOL_READY;
 
    UINT32 lrt = ConfigReadULong(_T("LongRunningQueryThreshold"), 0);
index fdee6d0..e1d51cf 100644 (file)
@@ -666,11 +666,9 @@ void Node::addVrrpInterfaces(InterfaceList *ifList)
 }
 
 /**
- * Find interface by index and/or IP subnet. Interface IP considered matching
- * if it is from same IP subnet as hostAddr or if hostAddr set to INADDR_ANY.
+ * Find interface by index.
  *
- * @param ifIndex interface index to match or INVALID_INDEX to select first matching interface
- * @param hostAddr IP address to match or INADDR_ANY to select first matching interface
+ * @param ifIndex interface index to match
  * @return pointer to interface object or NULL if appropriate interface couldn't be found
  */
 Interface *Node::findInterfaceByIndex(UINT32 ifIndex)
index ba8a301..6b81b99 100644 (file)
@@ -1,6 +1,6 @@
 /* 
 ** NetXMS - Network Management System
-** Copyright (C) 2003-2014 Victor Kirhenshtein
+** Copyright (C) 2003-2015 Victor Kirhenshtein
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by