2009-10-05 Ramon Novoa <rnovoa@artica.es>
* ftp/pandora_ftp_client.h: Fixed the path of curl.h to match that in the Dev-cpp libcurl devpack. * modules/pandora_module_tcpcheck.cc: Properly close the connection socket. * modules/pandora_module_regexp.cc: Removed debugging code. * modules/pandora_module_perfcounter.cc: Close the query handle even if no data was returned to avoid memory leaks. * windows/pandora_windows_info.h, windows/pandora_windows_info.cc, modules/pandora_module_proc.cc: Fixed a process handle leak. * configure.in: Improved library detection. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2000 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
0b9f395ec3
commit
54aa4c3852
|
@ -1,3 +1,22 @@
|
|||
2009-10-05 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* ftp/pandora_ftp_client.h: Fixed the path of curl.h to match
|
||||
that in the Dev-cpp libcurl devpack.
|
||||
|
||||
* modules/pandora_module_tcpcheck.cc: Properly close the connection
|
||||
socket.
|
||||
|
||||
* modules/pandora_module_regexp.cc: Removed debugging code.
|
||||
|
||||
* modules/pandora_module_perfcounter.cc: Close the query handle even if
|
||||
no data was returned to avoid memory leaks.
|
||||
|
||||
* windows/pandora_windows_info.h,
|
||||
windows/pandora_windows_info.cc,
|
||||
modules/pandora_module_proc.cc: Fixed a process handle leak.
|
||||
|
||||
* configure.in: Improved library detection.
|
||||
|
||||
2009-09-24 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* modules/pandora_module_tcpcheck.cc: WSAStartup memory management
|
||||
|
|
|
@ -22,17 +22,18 @@ AM_CONDITIONAL(DEBUG, test "$debug" = "yes")
|
|||
|
||||
# Checks for libraries.
|
||||
AC_CHECK_LIB([ws2_32], [main], , AC_MSG_ERROR([MingGW not found. You can get it from http://www.mingw.org/]))
|
||||
AC_CHECK_LIB([psapi], [main], , )
|
||||
AC_CHECK_LIB([ole32], [main], , )
|
||||
AC_CHECK_LIB([oleaut32], [main], , )
|
||||
AC_CHECK_LIB([uuid], [main], , )
|
||||
AC_CHECK_LIB([regex], [main], , AC_MSG_ERROR([Boost.Regex not not found. Get it from http://www.boost.org/ and rename it to libregex.a]))
|
||||
AC_CHECK_LIB([z], [main], , )
|
||||
AC_CHECK_LIB([gdi32], [main], , )
|
||||
AC_CHECK_LIB([crypto], [main], , )
|
||||
AC_CHECK_LIB([ssl], [main], , )
|
||||
AC_CHECK_LIB([curl], [main], , )
|
||||
AC_CHECK_LIB([odbc++], [main], , )
|
||||
AC_CHECK_LIB([winmm], [main], , AC_MSG_ERROR([libwinmm not found.]))
|
||||
AC_CHECK_LIB([psapi], [main], , AC_MSG_ERROR([libpsapi not found.]))
|
||||
AC_CHECK_LIB([ole32], [main], , AC_MSG_ERROR([libole32 not found.]))
|
||||
AC_CHECK_LIB([oleaut32], [main], , AC_MSG_ERROR([liboleaut not found.]))
|
||||
AC_CHECK_LIB([uuid], [main], , AC_MSG_ERROR([libuuid not found.]))
|
||||
AC_CHECK_LIB([boost_regex], [main], , AC_MSG_ERROR([Boost.Regex not not found. Get it from http://www.boost.org/]))
|
||||
AC_CHECK_LIB([z], [main], , AC_MSG_ERROR([libz not found.]))
|
||||
AC_CHECK_LIB([gdi32], [main], , AC_MSG_ERROR([libgdi32 not found.]))
|
||||
AC_CHECK_LIB([crypto], [main], , AC_MSG_ERROR([libcrypto not found.]))
|
||||
AC_CHECK_LIB([ssl], [main], , AC_MSG_ERROR([libssl not found.]))
|
||||
AC_CHECK_LIB([curl], [main], , AC_MSG_ERROR([libcurl not found.]))
|
||||
AC_CHECK_LIB([odbc++], [main], , AC_MSG_ERROR([libodbc++ not found.]))
|
||||
|
||||
# Checks for header files.
|
||||
AC_CHECK_HEADERS([fcntl.h stddef.h stdlib.h string.h sys/socket.h sys/time.h unistd.h wchar.h])
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include <string>
|
||||
#include "../pandora.h"
|
||||
#include <curl/curl.h>
|
||||
#include <curl.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
|
@ -137,6 +137,7 @@ Pandora_Module_Perfcounter::run () {
|
|||
status = PdhAddCounter (query, this->source.c_str (), 0, &counter);
|
||||
if (status != ERROR_SUCCESS) {
|
||||
pandoraLog ("PdhAddCounter failed with error %d", status);
|
||||
PdhCloseQuery (query);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -144,6 +145,7 @@ Pandora_Module_Perfcounter::run () {
|
|||
status = PdhCollectQueryData (query);
|
||||
if (status != ERROR_SUCCESS) {
|
||||
// No data
|
||||
PdhCloseQuery (query);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ async_run (Pandora_Module_Proc *module) {
|
|||
Pandora_Module_List *modules;
|
||||
string str_res;
|
||||
string prev_res;
|
||||
int i, res, counter = 0;
|
||||
int i, res, counter = 0, num_proc;
|
||||
|
||||
prev_res = module->getLatestOutput ();
|
||||
modules = new Pandora_Module_List ();
|
||||
|
@ -136,7 +136,7 @@ async_run (Pandora_Module_Proc *module) {
|
|||
Sleep (module->getStartDelay ());
|
||||
|
||||
while (1) {
|
||||
processes = getProcessHandles (module->getProcessName ());
|
||||
processes = getProcessHandles (module->getProcessName (), &num_proc);
|
||||
if (processes == NULL) {
|
||||
if (module->isWatchdog ()) {
|
||||
if (counter >= module->getRetries ()) {
|
||||
|
@ -173,7 +173,7 @@ async_run (Pandora_Module_Proc *module) {
|
|||
|
||||
if (result > (WAIT_OBJECT_0 + nprocess - 1)) {
|
||||
/* No event happened */
|
||||
for (i = 0; i < nprocess; i++)
|
||||
for (i = 0; i < num_proc; i++)
|
||||
CloseHandle (processes[i]);
|
||||
pandoraFree (processes);
|
||||
continue;
|
||||
|
@ -189,7 +189,7 @@ async_run (Pandora_Module_Proc *module) {
|
|||
}
|
||||
|
||||
/* Free handles */
|
||||
for (i = 0; i < nprocess; i++)
|
||||
for (i = 0; i < num_proc; i++)
|
||||
CloseHandle (processes[i]);
|
||||
pandoraFree (processes);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ Pandora_Module_Regexp::Pandora_Module_Regexp (string name, string source, string
|
|||
// Open the file and skip to the end
|
||||
this->file.open (source.c_str ());
|
||||
if (this->file.is_open ()) {
|
||||
//this->file.seekg (0, ios_base::end);
|
||||
this->file.seekg (0, ios_base::end);
|
||||
} else {
|
||||
pandoraLog ("Error opening file %s", source.c_str ());
|
||||
}
|
||||
|
|
|
@ -131,11 +131,13 @@ Pandora_Module_Tcpcheck::run () {
|
|||
|
||||
rc = select(0, NULL, &socket_set, NULL, &timer);
|
||||
if (rc == 0) {
|
||||
this->setOutput ("0");
|
||||
|
||||
WSACleanup ();
|
||||
closesocket (sock);
|
||||
WSACleanup ();
|
||||
this->setOutput ("0");
|
||||
return;
|
||||
}
|
||||
|
||||
closesocket (sock);
|
||||
WSACleanup ();
|
||||
this->setOutput ("1");
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ Pandora_Windows_Info::getSystemPath () {
|
|||
}
|
||||
|
||||
HANDLE *
|
||||
Pandora_Windows_Info::getProcessHandles (string name) {
|
||||
Pandora_Windows_Info::getProcessHandles (string name, int *num_proc) {
|
||||
HANDLE handle;
|
||||
HANDLE handles[128];
|
||||
HANDLE *retval;
|
||||
|
@ -95,6 +95,7 @@ Pandora_Windows_Info::getProcessHandles (string name) {
|
|||
bool success;
|
||||
TCHAR process_name[MAX_PATH];
|
||||
|
||||
*num_proc = 0;
|
||||
if (! EnumProcesses (pids, sizeof (pids), &needed))
|
||||
return NULL;
|
||||
|
||||
|
@ -119,11 +120,15 @@ Pandora_Windows_Info::getProcessHandles (string name) {
|
|||
if (stricmp (process_name, name.c_str ()) == 0) {
|
||||
/* Process found */
|
||||
handles[count++] = handle;
|
||||
} else {
|
||||
CloseHandle (handle);
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
return NULL;
|
||||
|
||||
*num_proc = count;
|
||||
retval = (HANDLE *) malloc (count * sizeof (HANDLE));
|
||||
for (i = 0; i < count; i++)
|
||||
retval[i] = handles[i];
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace Pandora_Windows_Info {
|
|||
string getOSBuild ();
|
||||
string getSystemName ();
|
||||
string getSystemPath ();
|
||||
HANDLE *getProcessHandles (string name);
|
||||
HANDLE *getProcessHandles (string name, int *num_procs);
|
||||
string getRegistryValue (HKEY root, const string treepath, const string keyname);
|
||||
int getSoftware (list<string> &rows, string separator);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue