2014-08-06 Ramon Novoa <rnovoa@artica.es>

* lib/PandoraFMS/NetworkServer.pm: Rewrote TCP module socket code for
	  sending data (tcp_send). Fixes ticket #1096.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10385 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
ramonn 2014-08-06 15:48:59 +00:00
parent 9b7a8cec71
commit ded9780100
2 changed files with 90 additions and 81 deletions

View File

@ -1,3 +1,8 @@
2014-08-06 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/NetworkServer.pm: Rewrote TCP module socket code for
sending data (tcp_send). Fixes ticket #1096.
2014-08-05 Hirofumi Kosaka <kosaka@rworks.jp> 2014-08-05 Hirofumi Kosaka <kosaka@rworks.jp>
* lib/PandoraFMS/Core.pm: Suppress "going to normal (warning, * lib/PandoraFMS/Core.pm: Suppress "going to normal (warning,

View File

@ -25,6 +25,7 @@ use threads::shared;
use Thread::Semaphore; use Thread::Semaphore;
use IO::Socket::INET6; use IO::Socket::INET6;
use IO::Select;
use HTML::Entities; use HTML::Entities;
use POSIX qw(strftime); use POSIX qw(strftime);
@ -190,6 +191,10 @@ sub pandora_query_tcp ($$$$$$$$$$) {
my @tcp_send = split( /\|/, $tcp_send ); my @tcp_send = split( /\|/, $tcp_send );
my @tcp_rcv = split( /\|/, $tcp_rcv ); my @tcp_rcv = split( /\|/, $tcp_rcv );
# Add server socket to select queue
my $select = IO::Select->new ();
$select->add ($handle);
next_pair: next_pair:
$tcp_send = shift( @tcp_send ); $tcp_send = shift( @tcp_send );
$tcp_rcv = shift( @tcp_rcv ); $tcp_rcv = shift( @tcp_rcv );
@ -206,12 +211,11 @@ next_pair:
# Receive data, non-blocking !!!! (VERY IMPORTANT!) # Receive data, non-blocking !!!! (VERY IMPORTANT!)
$temp2 = ""; $temp2 = "";
for ($tam = 0; $tam < $timeout; $tam ++) { for ($tam = 0; $tam < $timeout; $tam ++) {
$handle->recv($temp,16000,0x40); if ($select->can_read (1)) {
my $read = sysread ($handle, $temp, 16000);
last if (! defined ($read) || $read == 0); # No more data or something went wrong
$temp2 = $temp2.$temp; $temp2 = $temp2.$temp;
if ($temp ne ""){
$tam++; # If doesnt receive data, increase counter
} }
sleep(1);
} }
if ($id_tipo_modulo == 9){ # only for TCP Proc if ($id_tipo_modulo == 9){ # only for TCP Proc
if ($temp2 =~ /$tcp_rcv/i){ # String match ! if ($temp2 =~ /$tcp_rcv/i){ # String match !