Dear Gtk-Perl experts, We have a legacy Gtk2 application that occasionally has to send HTTP requests asynchronously. We've noticed that it hangs on Windows with recent perls.
The issue can be reduced to the following simple test case: ######################## #!/usr/bin/perl use strict; use warnings; use feature qw/say/; #use Gtk2 -init; use AnyEvent; use AnyEvent::DNS; use AnyEvent::Socket; use AnyEvent::Handle; use AnyEvent::Impl::Glib; #use AnyEvent::Impl::EV; #use AnyEvent::Impl::Perl; my $cv = AnyEvent->condvar; tcp_connect #'localhost', 8000, "www.google.com", "http", sub { my ($fh) = @_ or die "unable to connect: $!"; my $handle; # avoid direct assignment so on_eof has it in scope. $handle = new AnyEvent::Handle fh => $fh, on_error => sub { AE::log error => $_[2]; $_[0]->destroy; }, on_eof => sub { $handle->destroy; # destroy handle AE::log info => "Done."; $cv->send; }; $handle->push_write ("GET / HTTP/1.0\015\012\015\012"); $handle->push_read (line => "\015\012\015\012", sub { my ($handle, $line) = @_; # print response header print "HEADER\n$line\n\nBODY\n"; $handle->on_read (sub { # print response body print $_[0]->rbuf; $_[0]->rbuf = ""; }); }); }; $cv->recv; #Gtk2->main(); ######################## This program (taken almost verbatim from the AnyEvent::Socket documentation) works as expected on linux (downloads and prints the Google homepage), and breaks on Windows. The reported error is sometimes a Broken Pipe, sometimes it is the following: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied. (This apparently corresponds to the error code WSANOTCONN) If I use a webserver on localhost as the target to avoid any DNS requests, I (seemingly) always get a broken pipe. And here is the main point, which is why this report belongs on this mailing list: the problem only appears if I explicitly select the Glib event loop implementation. The pure perl or EV backends work even on Windows. Affected version numbers: Windows 7 (Version 6.1 Build 7601 Service Pack 1) perl 5.24.1 (ActiveState) Glib 1.305 (from the sisyphusion.tk PPM repo advertised here a few weeks ago) AnyEvent 7.13 Finally, my question: is there any hope that this issue will be fixed, or at least its cause be found, or should we abandon this approach entirely? best regards, Peter Juhasz
_______________________________________________ gtk-perl-list mailing list gtk-perl-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-perl-list