Copied the newest tentacle_server from the tentacled repository.
(Fixed that tcp connection is not closed when timed out or connection refused by libwrap.)
This commit is contained in:
parent
92e8699887
commit
9e9595b965
|
@ -684,7 +684,13 @@ sub accept_connections {
|
||||||
error ("accept: $!.");
|
error ("accept: $!.");
|
||||||
}
|
}
|
||||||
|
|
||||||
print_log ("Client connected from " . $t_client_socket->sockhost ());
|
print_log ("Client connected from " . $t_client_socket->peerhost ());
|
||||||
|
|
||||||
|
if ($t_use_libwrap && (! hosts_ctl($t_program_name, $t_client_socket))) {
|
||||||
|
print_log ("Connection from " . $t_client_socket->peerhost() . " is closed by tcpwrappers.");
|
||||||
|
$t_client_socket->close();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
# Create a new thread and serve the client
|
# Create a new thread and serve the client
|
||||||
$t_sem->down();
|
$t_sem->down();
|
||||||
|
@ -693,6 +699,8 @@ sub accept_connections {
|
||||||
error ("Error creating thread: $!.");
|
error ("Error creating thread: $!.");
|
||||||
}
|
}
|
||||||
$thr->detach();
|
$thr->detach();
|
||||||
|
$t_client_socket->close ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep (1000);
|
usleep (1000);
|
||||||
|
@ -705,15 +713,6 @@ sub accept_connections {
|
||||||
################################################################################
|
################################################################################
|
||||||
sub serve_client() {
|
sub serve_client() {
|
||||||
|
|
||||||
if ($t_use_libwrap) {
|
|
||||||
if (! hosts_ctl($t_program_name, $t_client_socket)) {
|
|
||||||
print_log ("Connection from " . $t_client_socket->sockhost() . " is closed by tcpwrappers.");
|
|
||||||
$t_client_socket->close ();
|
|
||||||
$t_sem->up();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
# Add client socket to select queue
|
# Add client socket to select queue
|
||||||
$t_select = IO::Select->new ();
|
$t_select = IO::Select->new ();
|
||||||
|
@ -737,7 +736,6 @@ sub serve_client() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$t_client_socket->close ();
|
|
||||||
$t_sem->up();
|
$t_sem->up();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -684,7 +684,13 @@ sub accept_connections {
|
||||||
error ("accept: $!.");
|
error ("accept: $!.");
|
||||||
}
|
}
|
||||||
|
|
||||||
print_log ("Client connected from " . $t_client_socket->sockhost ());
|
print_log ("Client connected from " . $t_client_socket->peerhost ());
|
||||||
|
|
||||||
|
if ($t_use_libwrap && (! hosts_ctl($t_program_name, $t_client_socket))) {
|
||||||
|
print_log ("Connection from " . $t_client_socket->peerhost() . " is closed by tcpwrappers.");
|
||||||
|
$t_client_socket->close();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
# Create a new thread and serve the client
|
# Create a new thread and serve the client
|
||||||
$t_sem->down();
|
$t_sem->down();
|
||||||
|
@ -693,6 +699,8 @@ sub accept_connections {
|
||||||
error ("Error creating thread: $!.");
|
error ("Error creating thread: $!.");
|
||||||
}
|
}
|
||||||
$thr->detach();
|
$thr->detach();
|
||||||
|
$t_client_socket->close ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep (1000);
|
usleep (1000);
|
||||||
|
@ -705,15 +713,6 @@ sub accept_connections {
|
||||||
################################################################################
|
################################################################################
|
||||||
sub serve_client() {
|
sub serve_client() {
|
||||||
|
|
||||||
if ($t_use_libwrap) {
|
|
||||||
if (! hosts_ctl($t_program_name, $t_client_socket)) {
|
|
||||||
print_log ("Connection from " . $t_client_socket->sockhost() . " is closed by tcpwrappers.");
|
|
||||||
$t_client_socket->close ();
|
|
||||||
$t_sem->up();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
# Add client socket to select queue
|
# Add client socket to select queue
|
||||||
$t_select = IO::Select->new ();
|
$t_select = IO::Select->new ();
|
||||||
|
@ -737,7 +736,6 @@ sub serve_client() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$t_client_socket->close ();
|
|
||||||
$t_sem->up();
|
$t_sem->up();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue