minor refactoring ("new node" flag renamed to "configuration poll pending")
authorVictor Kirhenshtein <victor@netxms.org>
Tue, 31 Oct 2017 20:22:10 +0000 (22:22 +0200)
committerVictor Kirhenshtein <victor@netxms.org>
Tue, 31 Oct 2017 20:22:10 +0000 (22:22 +0200)
include/nxcldefs.h
src/server/core/accesspoint.cpp
src/server/core/node.cpp
src/server/core/np.cpp
src/server/core/sensor.cpp
src/server/include/nms_objects.h

index b7c6089..5a61962 100644 (file)
 #define DCDF_FORCE_STATUS_POLL             0x0010
 #define DCDF_FORCE_CONFIGURATION_POLL      0x0020
 #define DCDF_CONFIGURATION_POLL_PASSED     0x0040
-#define DCDF_POLL_NEW_NODE                 0x0080
+#define DCDF_CONFIGURATION_POLL_PENDING    0x0080
 
 /**
  * Node runtime (dynamic) flags
index 0ef6f25..871660d 100644 (file)
@@ -59,9 +59,9 @@ AccessPoint::AccessPoint(const TCHAR *name, UINT32 index, const BYTE *macAddr) :
  */
 AccessPoint::~AccessPoint()
 {
-       safe_free(m_vendor);
-       safe_free(m_model);
-       safe_free(m_serialNumber);
+       free(m_vendor);
+       free(m_model);
+       free(m_serialNumber);
        delete m_radioInterfaces;
 }
 
index 22050a4..5b40b52 100644 (file)
@@ -132,6 +132,7 @@ Node::Node() : DataCollectionTarget()
  */
 Node::Node(const InetAddress& addr, UINT32 flags, UINT32 capabilities, UINT32 agentProxy, UINT32 snmpProxy, UINT32 icmpProxy, UINT32 sshProxy, UINT32 zoneUIN) : DataCollectionTarget()
 {
+   m_runtimeFlags |= DCDF_CONFIGURATION_POLL_PENDING;
    addr.toString(m_primaryName);
    m_status = STATUS_UNKNOWN;
    m_type = NODE_TYPE_UNKNOWN;
@@ -2522,7 +2523,7 @@ void Node::configurationPoll(PollerInfo *poller, ClientSession *session, UINT32
       sendPollerMsg(rqId, _T("Finished configuration poll for node %s\r\n"), m_name);
       sendPollerMsg(rqId, _T("Node configuration was%schanged after poll\r\n"), (modified != 0) ? _T(" ") : _T(" not "));
 
-      m_runtimeFlags &= ~DCDF_POLL_NEW_NODE;
+      m_runtimeFlags &= ~DCDF_CONFIGURATION_POLL_PENDING;
       m_runtimeFlags |= DCDF_CONFIGURATION_POLL_PASSED;
    }
 
index a570561..2fac7a9 100644 (file)
@@ -212,7 +212,6 @@ Node NXCORE_EXPORTABLE *PollNewNode(const InetAddress& ipAddr, UINT32 creationFl
       pNode->setMgmtStatus(FALSE);
       pNode->checkSubnetBinding();
    }
-   pNode->setNewNodeFlag();
 
        if (doConfPoll)
    {
index 03f3865..759952b 100644 (file)
@@ -54,6 +54,7 @@ Sensor::Sensor(TCHAR *name, UINT32 flags, MacAddress macAddress, UINT32 deviceCl
                UINT32 commProtocol, TCHAR *xmlRegConfig, TCHAR *xmlConfig, TCHAR *serialNumber, TCHAR *deviceAddress,
                TCHAR *metaType, TCHAR *description, UINT32 proxyNode) : DataCollectionTarget(name)
 {
+   m_runtimeFlags |= DCDF_CONFIGURATION_POLL_PENDING;
    m_flags = flags;
    m_macAddress = macAddress;
        m_deviceClass = deviceClass;
@@ -92,8 +93,6 @@ Sensor *Sensor::createSensor(TCHAR *name, NXCPMessage *request)
                           request->getFieldAsString(VID_DESCRIPTION),
                           request->getFieldAsUInt32(VID_SENSOR_PROXY));
 
-   sensor->setNewNodeFlag();
-
    switch(request->getFieldAsUInt32(VID_COMM_PROTOCOL))
    {
       case COMM_LORAWAN:
@@ -589,7 +588,7 @@ void Sensor::configurationPoll(PollerInfo *poller, ClientSession *session, UINT3
    m_lastConfigurationPoll = time(NULL);
 
    nxlog_debug(5, _T("Finished configuration poll for sensor %s (ID: %d)"), m_name, m_id);
-   m_runtimeFlags &= ~DCDF_POLL_NEW_NODE;
+   m_runtimeFlags &= ~DCDF_CONFIGURATION_POLL_PENDING;
    m_runtimeFlags |= DCDF_CONFIGURATION_POLL_PASSED;
    pollerUnlock();
 
index 6ba2ffc..536e346 100644 (file)
@@ -1151,7 +1151,6 @@ public:
    int getMostCriticalDCIStatus();
 
    UINT32 getPingTime();
-   void setNewNodeFlag() { m_runtimeFlags |= DCDF_POLL_NEW_NODE; }
 
    void statusPollWorkerEntry(PollerInfo *poller);
    void statusPollWorkerEntry(PollerInfo *poller, ClientSession *session, UINT32 rqId);
@@ -1184,7 +1183,6 @@ inline bool DataCollectionTarget::isReadyForInstancePoll()
           (!(m_runtimeFlags & DCDF_QUEUED_FOR_INSTANCE_POLL)) &&
           (!(m_runtimeFlags & DCDF_DELETE_IN_PROGRESS)) &&
           (m_runtimeFlags & DCDF_CONFIGURATION_POLL_PASSED) &&
-          (!(m_runtimeFlags & DCDF_POLL_NEW_NODE)) &&
           ((UINT32)(time(NULL) - m_lastInstancePoll) > g_instancePollingInterval);
 
 }
@@ -1247,7 +1245,7 @@ inline bool DataCollectionTarget::isReadyForStatusPoll()
               (!(m_flags & DCF_DISABLE_STATUS_POLL)) &&
           (!(m_runtimeFlags & DCDF_QUEUED_FOR_STATUS_POLL)) &&
           (!(m_runtimeFlags & DCDF_DELETE_IN_PROGRESS)) &&
-          (!(m_runtimeFlags & DCDF_POLL_NEW_NODE)) &&
+          (!(m_runtimeFlags & DCDF_CONFIGURATION_POLL_PENDING)) &&
           ((UINT32)(time(NULL) - m_lastStatusPoll) > g_dwStatusPollingInterval);
 }
 inline void DataCollectionTarget::lockForStatusPoll()
@@ -2062,7 +2060,7 @@ inline bool Node::isReadyForStatusPoll()
           (!(m_runtimeFlags & DCDF_QUEUED_FOR_STATUS_POLL)) &&
           (!(m_runtimeFlags & DCDF_DELETE_IN_PROGRESS)) &&
                         (getMyCluster() == NULL) &&
-          (!(m_runtimeFlags & DCDF_POLL_NEW_NODE)) &&
+          (!(m_runtimeFlags & DCDF_CONFIGURATION_POLL_PENDING)) &&
           ((UINT32)(time(NULL) - m_lastStatusPoll) > g_dwStatusPollingInterval);
 }
 
@@ -2076,7 +2074,6 @@ inline bool Node::isReadyForDiscoveryPoll()
           (!(m_runtimeFlags & NDF_QUEUED_FOR_DISCOVERY_POLL)) &&
           (!(m_runtimeFlags & DCDF_DELETE_IN_PROGRESS)) &&
           (m_runtimeFlags & DCDF_CONFIGURATION_POLL_PASSED) &&
-          (!(m_runtimeFlags & DCDF_POLL_NEW_NODE)) &&
           ((UINT32)(time(NULL) - m_lastDiscoveryPoll) > g_dwDiscoveryPollingInterval);
 }
 
@@ -2089,7 +2086,6 @@ inline bool Node::isReadyForRoutePoll()
           (!(m_runtimeFlags & NDF_QUEUED_FOR_ROUTE_POLL)) &&
           (!(m_runtimeFlags & DCDF_DELETE_IN_PROGRESS)) &&
           (m_runtimeFlags & DCDF_CONFIGURATION_POLL_PASSED) &&
-          (!(m_runtimeFlags & DCDF_POLL_NEW_NODE)) &&
           ((UINT32)(time(NULL) - m_lastRTUpdate) > g_dwRoutingTableUpdateInterval);
 }
 
@@ -2102,7 +2098,6 @@ inline bool Node::isReadyForTopologyPoll()
           (!(m_runtimeFlags & NDF_QUEUED_FOR_TOPOLOGY_POLL)) &&
           (!(m_runtimeFlags & DCDF_DELETE_IN_PROGRESS)) &&
           (m_runtimeFlags & DCDF_CONFIGURATION_POLL_PASSED) &&
-          (!(m_runtimeFlags & DCDF_POLL_NEW_NODE)) &&
           ((UINT32)(time(NULL) - m_lastTopologyPoll) > g_dwTopologyPollingInterval);
 }