2011-04-05 Vanessa Gil <vanessa.gil@artica.es>
* win32/modules/pandora_module_exec.cc, win32/pandora_windows_service.cc: Fixed get module output part of over 4096 byte. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4305 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
b86a4fc557
commit
cc491d5c6e
|
@ -1,3 +1,9 @@
|
||||||
|
2011-04-05 Vanessa Gil <vanessa.gil@artica.es>
|
||||||
|
|
||||||
|
* win32/modules/pandora_module_exec.cc,
|
||||||
|
win32/pandora_windows_service.cc: Fixed get module output part of over 4096 byte.
|
||||||
|
|
||||||
|
|
||||||
2011-03-17 Dario Rodriguez <dario.rodriguez@artica.es>
|
2011-03-17 Dario Rodriguez <dario.rodriguez@artica.es>
|
||||||
|
|
||||||
* unix/pandora_agent: Fixed a typo with logfile parameter. Also fixed
|
* unix/pandora_agent: Fixed a typo with logfile parameter. Also fixed
|
||||||
|
|
|
@ -45,7 +45,7 @@ void
|
||||||
Pandora_Module_Exec::run () {
|
Pandora_Module_Exec::run () {
|
||||||
STARTUPINFO si;
|
STARTUPINFO si;
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
DWORD retval;
|
DWORD retval, dwRet;
|
||||||
SECURITY_ATTRIBUTES attributes;
|
SECURITY_ATTRIBUTES attributes;
|
||||||
HANDLE out, new_stdout, out_read, job;
|
HANDLE out, new_stdout, out_read, job;
|
||||||
string working_dir;
|
string working_dir;
|
||||||
|
@ -121,41 +121,45 @@ Pandora_Module_Exec::run () {
|
||||||
}
|
}
|
||||||
ResumeThread (pi.hThread);
|
ResumeThread (pi.hThread);
|
||||||
|
|
||||||
/* Wait until process exits. */
|
string output;
|
||||||
WaitForSingleObject (pi.hProcess, this->getTimeout ());
|
int tickbase = GetTickCount();
|
||||||
|
while ( (dwRet = WaitForSingleObject (pi.hProcess, 500)) != WAIT_ABANDONED ) {
|
||||||
|
PeekNamedPipe (out_read, buffer, BUFSIZE, &read, &avail, NULL);
|
||||||
|
if (avail > 0) {
|
||||||
|
ReadFile (out_read, buffer, BUFSIZE, &read, NULL);
|
||||||
|
buffer[read] = '\0';
|
||||||
|
output += (char *) buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dwRet == WAIT_OBJECT_0) {
|
||||||
|
break;
|
||||||
|
} else if(this->getTimeout() < GetTickCount() - tickbase) {
|
||||||
|
/* STILL_ACTIVE */
|
||||||
|
TerminateProcess(pi.hThread, STILL_ACTIVE);
|
||||||
|
pandoraLog ("Pandora_Module_Exec: %s timed out (retcode: %d)", this->module_name.c_str (), STILL_ACTIVE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GetExitCodeProcess (pi.hProcess, &retval);
|
GetExitCodeProcess (pi.hProcess, &retval);
|
||||||
|
|
||||||
if (retval != 0) {
|
if (retval != 0) {
|
||||||
if (! TerminateJobObject (job, 0)) {
|
if (! TerminateJobObject (job, 0)) {
|
||||||
pandoraLog ("TerminateJobObject failed. (error %d)",
|
pandoraLog ("TerminateJobObject failed. (error %d)",
|
||||||
GetLastError ());
|
GetLastError ());
|
||||||
}
|
}
|
||||||
|
if (retval != STILL_ACTIVE) {
|
||||||
/* STILL_ACTIVE */
|
pandoraLog ("Pandora_Module_Exec: %s did not executed well (retcode: %d)",
|
||||||
if (retval == 259) {
|
this->module_name.c_str (), retval);
|
||||||
pandoraLog ("Pandora_Module_Exec: %s timed out (retcode: 259)",
|
}
|
||||||
this->module_name.c_str ());
|
this->has_output = false;
|
||||||
} else {
|
|
||||||
pandoraLog ("Pandora_Module_Exec: %s did not executed well (retcode: %d)",
|
|
||||||
this->module_name.c_str (), retval);
|
|
||||||
}
|
|
||||||
this->has_output = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PeekNamedPipe (out_read, buffer, BUFSIZE, &read, &avail, NULL);
|
if (!output.empty()) {
|
||||||
/* Read from the stdout */
|
this->setOutput (output);
|
||||||
if (read != 0) {
|
} else {
|
||||||
string output;
|
this->setOutput ("");
|
||||||
do {
|
}
|
||||||
ReadFile (out_read, buffer, BUFSIZE, &read,
|
|
||||||
NULL);
|
|
||||||
buffer[read] = '\0';
|
|
||||||
output += (char *) buffer;
|
|
||||||
} while (read >= BUFSIZE);
|
|
||||||
this->setOutput (output);
|
|
||||||
} else {
|
|
||||||
this->setOutput ("");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Close job, process and thread handles. */
|
/* Close job, process and thread handles. */
|
||||||
CloseHandle (job);
|
CloseHandle (job);
|
||||||
|
|
|
@ -1194,6 +1194,7 @@ Pandora_Windows_Service::pandora_run () {
|
||||||
|
|
||||||
if (module->checkCron () == 1) {
|
if (module->checkCron () == 1) {
|
||||||
module->run ();
|
module->run ();
|
||||||
|
Sleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save module data to an environment variable */
|
/* Save module data to an environment variable */
|
||||||
|
|
Loading…
Reference in New Issue