]> git.proxmox.com Git - pve-manager.git/commitdiff
spiceproxy: code cleanups
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 18 Jul 2013 06:46:33 +0000 (08:46 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 18 Jul 2013 06:53:07 +0000 (08:53 +0200)
PVE/HTTPServer.pm

index 6b5288659e3c99d0267f251ad817aa29f83f26d9..26ced0172ba7557b78474691dd61c64bcb7dc17d 100755 (executable)
@@ -503,9 +503,6 @@ sub handle_spice_proxy_request {
 
        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 {
            my ($fh) = @_ 
                or die "connect to 'localhost:$spiceport' failed: $!";
@@ -516,7 +513,6 @@ sub handle_spice_proxy_request {
                rbuf_max => 64*1024,
                wbuf_max => 64*10*1024,
                timeout => 0,
-               #linger => 0, # avoid problems with ssh - really needed ?
                on_eof => sub {
                    my ($hdl) = @_;
                    eval {
@@ -532,18 +528,19 @@ sub handle_spice_proxy_request {
                        $self->client_do_disconnect($reqstate);
                    };
                    if (my $err = $@) { syslog('err', "$err"); }
-               },
-               on_read => sub {
-                   my ($hdl) = @_;
+               });
 
-                   my $len = length($hdl->{rbuf});
-                   my $data = substr($hdl->{rbuf}, 0, $len, '');
+           my $proxyhdlreader = sub {
+               my ($hdl) = @_;
 
-                   #print "READ1 $len\n";
-                   $reqstate->{hdl}->push_write($data) if $reqstate->{hdl};
-               });
-   
-           $reqstate->{hdl}->on_read(sub {
+               my $len = length($hdl->{rbuf});
+               my $data = substr($hdl->{rbuf}, 0, $len, '');
+
+               #print "READ1 $len\n";
+               $reqstate->{hdl}->push_write($data) if $reqstate->{hdl};
+           };
+
+           my $hdlreader = sub {
                my ($hdl) = @_;
 
                my $len = length($hdl->{rbuf});
@@ -551,11 +548,14 @@ sub handle_spice_proxy_request {
 
                #print "READ0 $len\n";
                $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);
 
-           # 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 $res = "$proto 200 OK\015\012"; # hope this is the right answer?