Merged the latest version of the Tentacle server from the SF repo.

(cherry picked from commit e44ef7ddc1)
This commit is contained in:
Ramon Novoa 2016-02-01 12:04:37 +01:00
parent 1b8b9f3390
commit 18e2eb54a0
5 changed files with 28 additions and 10 deletions

View File

@ -64,6 +64,7 @@ use threads;
use Thread::Semaphore; use Thread::Semaphore;
use POSIX ":sys_wait_h"; use POSIX ":sys_wait_h";
use Time::HiRes qw(usleep); use Time::HiRes qw(usleep);
use Scalar::Util qw(refaddr);
# Constants for Win32 services. # Constants for Win32 services.
use constant WIN32_SERVICE_STOPPED => 0x01; use constant WIN32_SERVICE_STOPPED => 0x01;
@ -682,7 +683,7 @@ sub accept_connections {
my $pid; my $pid;
my $t_server_socket; my $t_server_socket;
# Ignore SIGPIPE errors (happens on FreeBSD when SSL is enabled ¿?) # Ignore SIGPIPE
$SIG{PIPE} = 'IGNORE'; $SIG{PIPE} = 'IGNORE';
# Start server # Start server
@ -769,16 +770,23 @@ sub serve_proxy_connection {
# Forward data between the client and the server. # Forward data between the client and the server.
eval { eval {
while (1) { my $select = IO::Select->new ();
if ($t_select->can_read(0)) { $select->add($t_proxy_socket);
$select->add($t_client_socket);
while (my @ready = $select->can_read()) {
foreach my $socket (@ready) {
if (refaddr($socket) == refaddr($t_client_socket)) {
my ($read, $data) = recv_data($t_block_size); my ($read, $data) = recv_data($t_block_size);
return unless defined($data);
send_data_proxy($data); send_data_proxy($data);
} }
if ($t_proxy_select->can_read(0)) { else {
my ($read, $data) = recv_data_proxy($t_block_size); my ($read, $data) = recv_data_proxy($t_block_size);
return unless defined($data);
send_data($data); send_data($data);
} }
} }
}
}; };
# Close the connection to the Tentacle Server. # Close the connection to the Tentacle Server.
@ -969,8 +977,10 @@ sub print_log {
sub error { sub error {
if ($t_quiet == 0) { if ($t_quiet == 0) {
die("[err] $_[0]\n\n"); print (STDERR "[err] $_[0]\n");
} }
die("\n");
} }
################################################################################ ################################################################################

View File

@ -64,6 +64,7 @@ use threads;
use Thread::Semaphore; use Thread::Semaphore;
use POSIX ":sys_wait_h"; use POSIX ":sys_wait_h";
use Time::HiRes qw(usleep); use Time::HiRes qw(usleep);
use Scalar::Util qw(refaddr);
# Constants for Win32 services. # Constants for Win32 services.
use constant WIN32_SERVICE_STOPPED => 0x01; use constant WIN32_SERVICE_STOPPED => 0x01;
@ -769,16 +770,23 @@ sub serve_proxy_connection {
# Forward data between the client and the server. # Forward data between the client and the server.
eval { eval {
while (1) { my $select = IO::Select->new ();
if ($t_select->can_read(0)) { $select->add($t_proxy_socket);
$select->add($t_client_socket);
while (my @ready = $select->can_read()) {
foreach my $socket (@ready) {
if (refaddr($socket) == refaddr($t_client_socket)) {
my ($read, $data) = recv_data($t_block_size); my ($read, $data) = recv_data($t_block_size);
return unless defined($data);
send_data_proxy($data); send_data_proxy($data);
} }
if ($t_proxy_select->can_read(0)) { else {
my ($read, $data) = recv_data_proxy($t_block_size); my ($read, $data) = recv_data_proxy($t_block_size);
return unless defined($data);
send_data($data); send_data($data);
} }
} }
}
}; };
# Close the connection to the Tentacle Server. # Close the connection to the Tentacle Server.