Commit 7074e572 authored by Dietmar Maurer's avatar Dietmar Maurer

spiceproxy: code cleanups

parent d3c2403c
...@@ -503,9 +503,6 @@ sub handle_spice_proxy_request { ...@@ -503,9 +503,6 @@ sub handle_spice_proxy_request {
print "$$: CONNECT $vmid, $node, $spiceport\n" if $self->{debug}; print "$$: CONNECT $vmid, $node, $spiceport\n" if $self->{debug};
# fixme: use qmp add_client instead?
# fixme: this needs root privs
tcp_connect "127.0.0.1", $spiceport, sub { tcp_connect "127.0.0.1", $spiceport, sub {
my ($fh) = @_ my ($fh) = @_
or die "connect to 'localhost:$spiceport' failed: $!"; or die "connect to 'localhost:$spiceport' failed: $!";
...@@ -516,7 +513,6 @@ sub handle_spice_proxy_request { ...@@ -516,7 +513,6 @@ sub handle_spice_proxy_request {
rbuf_max => 64*1024, rbuf_max => 64*1024,
wbuf_max => 64*10*1024, wbuf_max => 64*10*1024,
timeout => 0, timeout => 0,
#linger => 0, # avoid problems with ssh - really needed ?
on_eof => sub { on_eof => sub {
my ($hdl) = @_; my ($hdl) = @_;
eval { eval {
...@@ -532,18 +528,19 @@ sub handle_spice_proxy_request { ...@@ -532,18 +528,19 @@ sub handle_spice_proxy_request {
$self->client_do_disconnect($reqstate); $self->client_do_disconnect($reqstate);
}; };
if (my $err = $@) { syslog('err', "$err"); } if (my $err = $@) { syslog('err', "$err"); }
}, });
on_read => sub {
my ($hdl) = @_;
my $len = length($hdl->{rbuf}); my $proxyhdlreader = sub {
my $data = substr($hdl->{rbuf}, 0, $len, ''); my ($hdl) = @_;
#print "READ1 $len\n"; my $len = length($hdl->{rbuf});
$reqstate->{hdl}->push_write($data) if $reqstate->{hdl}; my $data = substr($hdl->{rbuf}, 0, $len, '');
});
#print "READ1 $len\n";
$reqstate->{hdl}->on_read(sub { $reqstate->{hdl}->push_write($data) if $reqstate->{hdl};
};
my $hdlreader = sub {
my ($hdl) = @_; my ($hdl) = @_;
my $len = length($hdl->{rbuf}); my $len = length($hdl->{rbuf});
...@@ -551,11 +548,14 @@ sub handle_spice_proxy_request { ...@@ -551,11 +548,14 @@ sub handle_spice_proxy_request {
#print "READ0 $len\n"; #print "READ0 $len\n";
$reqstate->{proxyhdl}->push_write($data) if $reqstate->{proxyhdl}; $reqstate->{proxyhdl}->push_write($data) if $reqstate->{proxyhdl};
}); };
$reqstate->{proxyhdl}->on_read($proxyhdlreader);
$reqstate->{hdl}->on_read($hdlreader);
$reqstate->{hdl}->wbuf_max(64*10*1024); $reqstate->{hdl}->wbuf_max(64*10*1024);
# fixme: use stop_read/start_read if write buffer grows to much # todo: use stop_read/start_read if write buffer grows to much
my $proto = $reqstate->{proto} ? $reqstate->{proto}->{str} : 'HTTP/1.0'; my $proto = $reqstate->{proto} ? $reqstate->{proto}->{str} : 'HTTP/1.0';
my $res = "$proto 200 OK\015\012"; # hope this is the right answer? my $res = "$proto 200 OK\015\012"; # hope this is the right answer?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment