fixed bug in agent initialization
authorAlex Kalimulin <alex@netxms.org>
Sun, 13 Dec 2009 15:34:04 +0000 (15:34 +0000)
committerAlex Kalimulin <alex@netxms.org>
Sun, 13 Dec 2009 15:34:04 +0000 (15:34 +0000)
src/agent/core/comm.cpp
src/agent/core/nxagentd.cpp
src/agent/core/nxagentd.vcproj

index e3ffc61..1359ae0 100644 (file)
@@ -41,6 +41,20 @@ MUTEX g_hSessionListAccess;
 static MUTEX m_mutexWatchdogActive = INVALID_MUTEX_HANDLE;
 
 
+//
+// Initialize session list
+//
+
+void InitSessionList()
+{
+       // Create session list and it's access mutex
+       g_dwMaxSessions = min(max(g_dwMaxSessions, 2), 1024);
+       g_pSessionList = (CommSession **)malloc(sizeof(CommSession *) * g_dwMaxSessions);
+       memset(g_pSessionList, 0, sizeof(CommSession *) * g_dwMaxSessions);
+       g_hSessionListAccess = MutexCreate();
+}
+
+
 //
 // Validates server's address
 //
@@ -112,12 +126,6 @@ THREAD_RESULT THREAD_CALL ListenerThread(void *)
    struct timeval tv;
    fd_set rdfs;
 
-   // Create session list and it's access mutex
-   g_dwMaxSessions = min(max(g_dwMaxSessions, 2), 1024);
-   g_pSessionList = (CommSession **)malloc(sizeof(CommSession *) * g_dwMaxSessions);
-   memset(g_pSessionList, 0, sizeof(CommSession *) * g_dwMaxSessions);
-   g_hSessionListAccess = MutexCreate();
-
    // Create socket
    if ((hSocket = socket(AF_INET, SOCK_STREAM, 0)) == -1)
    {
index 09cfc33..b0f0a8e 100644 (file)
@@ -57,6 +57,8 @@ void StartWatchdog();
 void StopWatchdog();
 int WatchdogMain(DWORD pid);
 
+void InitSessionList();
+
 BOOL PushData(const TCHAR *parameter, const TCHAR *value);
 
 #if !defined(_WIN32) && !defined(_NETWARE)
@@ -683,6 +685,8 @@ BOOL Initialize(void)
    }
 #endif
 
+   InitSessionList();
+
    // Initialize API for subagents
    InitSubAgentAPI(WriteSubAgentMsg, SendTrap, SendTrap, SendFileToServer, PushData);
    DebugPrintf(INVALID_INDEX, "Subagent API initialized");
index 69b5da1..81f587c 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="windows-1251"?>\r
 <VisualStudioProject\r
        ProjectType="Visual C++"\r
-       Version="8.00"\r
+       Version="8,00"\r
        Name="nxagentd"\r
        ProjectGUID="{57598B02-3295-4FE8-9322-94CE871CC84D}"\r
        RootNamespace="nxagentd"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Debug|x64"\r
-                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
-                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
                        ConfigurationType="1"\r
                        CharacterSet="2"\r
+                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
-                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               Optimization="0"\r
                                AdditionalIncludeDirectories="..\..\..\include"\r
-                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
-                               MinimalRebuild="true"\r
-                               BasicRuntimeChecks="3"\r
-                               RuntimeLibrary="3"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+                               RuntimeLibrary="2"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
-                               Detect64BitPortabilityProblems="true"\r
+                               Detect64BitPortabilityProblems="false"\r
                                DebugInformationFormat="3"\r
                        />\r
                        <Tool\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="ws2_32.lib iphlpapi.lib"\r
-                               LinkIncremental="2"\r
+                               LinkIncremental="1"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="1"\r
-                               TargetMachine="17"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Release|Win32"\r
-                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
-                       IntermediateDirectory="$(ConfigurationName)"\r
+                       Name="Debug|x64"\r
+                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
                        ConfigurationType="1"\r
                        CharacterSet="2"\r
-                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
+                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
                                AdditionalIncludeDirectories="..\..\..\include"\r
-                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
-                               RuntimeLibrary="2"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
-                               Detect64BitPortabilityProblems="false"\r
+                               Detect64BitPortabilityProblems="true"\r
                                DebugInformationFormat="3"\r
                        />\r
                        <Tool\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="ws2_32.lib iphlpapi.lib"\r
-                               LinkIncremental="1"\r
+                               LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="1"\r
-                               OptimizeReferences="2"\r
-                               EnableCOMDATFolding="2"\r
-                               TargetMachine="1"\r
+                               TargetMachine="17"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r