mirror of
git://scm.dxcluster.org/scm/spider
synced 2024-09-21 15:57:12 +00:00
Got something basically working
Need to sort out shutdown and related things
This commit is contained in:
parent
38aa5af305
commit
bbc51ffb41
@ -13,7 +13,7 @@ if ($self->is_user && -e "$main::data/logout") {
|
||||
my @in = <I>;
|
||||
close(I);
|
||||
$self->send_now('D', @in);
|
||||
sleep(1);
|
||||
Msg->sleep(1);
|
||||
}
|
||||
|
||||
#$self->send_now('Z', "");
|
||||
|
@ -386,9 +386,9 @@ sub send_now
|
||||
# chomp;
|
||||
my @lines = split /\n/;
|
||||
for (@lines) {
|
||||
dbg("-> $sort $call $_") if $sort ne 'L' && isdbg('chan');
|
||||
$conn->send_now("$sort$call|$_");
|
||||
# debug log it, but not if it is a log message
|
||||
dbg("-> $sort $call $_") if $sort ne 'L' && isdbg('chan');
|
||||
}
|
||||
}
|
||||
$self->{t} = time;
|
||||
@ -410,9 +410,9 @@ sub send_later
|
||||
# chomp;
|
||||
my @lines = split /\n/;
|
||||
for (@lines) {
|
||||
dbg("-> $sort $call $_") if $sort ne 'L' && isdbg('chan');
|
||||
$conn->send_later("$sort$call|$_");
|
||||
# debug log it, but not if it is a log message
|
||||
dbg("-> $sort $call $_") if $sort ne 'L' && isdbg('chan');
|
||||
}
|
||||
}
|
||||
$self->{t} = time;
|
||||
@ -432,8 +432,8 @@ sub send # this is always later and always data
|
||||
for (ref $l ? @$l : $l) {
|
||||
my @lines = split /\n/;
|
||||
for (@lines) {
|
||||
$conn->send_later("D$call|$_");
|
||||
dbg("-> D $call $_") if isdbg('chan');
|
||||
$conn->send_later("D$call|$_");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -500,7 +500,7 @@ sub disconnect
|
||||
my $user = $self->{user};
|
||||
|
||||
$user->close() if defined $user;
|
||||
$self->{conn}->disconnect if $self->{conn};
|
||||
$self->{conn}->close_on_empty if $self->{conn};
|
||||
$self->del();
|
||||
}
|
||||
|
||||
|
17
perl/Msg.pm
17
perl/Msg.pm
@ -123,7 +123,9 @@ sub connect {
|
||||
|
||||
# Create a connection end-point object
|
||||
my $conn = $pkg;
|
||||
$conn = $pkg->new($rproc);
|
||||
unless (ref $pkg) {
|
||||
$conn = $pkg->new($rproc);
|
||||
}
|
||||
$conn->{peerhost} = $to_host;
|
||||
$conn->{peerport} = $to_port;
|
||||
$conn->{sort} = 'Outgoing';
|
||||
@ -225,6 +227,7 @@ sub disconnect
|
||||
}
|
||||
|
||||
if (defined($sock)) {
|
||||
shutdown($sock->{fh}, 2);
|
||||
$sock->destroy;
|
||||
}
|
||||
|
||||
@ -242,14 +245,18 @@ sub _send_stuff
|
||||
while (@$rq) {
|
||||
my $data = shift @$rq;
|
||||
my $lth = length $data;
|
||||
my $call = $conn->{call} || 'none';
|
||||
if (isdbg('raw')) {
|
||||
my $call = $conn->{call} || 'none';
|
||||
if (isdbg('raw')) {
|
||||
dbgdump('raw', "$call send $lth: ", $lth);
|
||||
}
|
||||
}
|
||||
$sock->push_write($data);
|
||||
$total_out = $lth;
|
||||
if (defined $sock && !$sock->destroyed) {
|
||||
$sock->push_write($data);
|
||||
$total_out = $lth;
|
||||
} else {
|
||||
dbg("_send_stuff $call ending data ignored: $data");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -285,7 +292,7 @@ sub _err_will_block {
|
||||
sub close_on_empty
|
||||
{
|
||||
my $conn = shift;
|
||||
$conn->{sock}->push_shutdown;
|
||||
$conn->{sock}->on_drain(sub {$conn->disconnect;});
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
@ -11,7 +11,7 @@ use vars qw($version $subversion $build $gitversion);
|
||||
|
||||
$version = '1.56';
|
||||
$subversion = '0';
|
||||
$build = '1';
|
||||
$gitversion = 'd17f05b';
|
||||
$build = '2';
|
||||
$gitversion = '38aa5af';
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user