Skip Menu |

This queue is for tickets about the Tk CPAN distribution.

Report information
The Basics
Id: 1561
Status: resolved
Priority: 0/
Queue: Tk

People
Owner: Nobody in particular
Requestors: MHX [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 800.024
Fixed in: (no value)



Subject: Tk::fileevent problem with IO::Socket on HP-UX
I recently upgraded from Tk-800.023 to Tk-800.024. I'm using perl 5.6.0 on HP-UX: mholland@bmdke3 $ uname -a HP-UX bmdke3 B.10.20 A 9000/778 2014451196 two-user license mholland@bmdke3 $ perl -v This is perl, v5.6.0 built for 9000/777-hpux The upgrade broke one of my scripts where I've used Tk::fileevent for handling response messages over an IO::Socket::INET connection. While I got the fileevent callback in 800.023, I didn't get it in 800.024. However, when using plain files or anonymous pipes, everything works fine, only IO::Socket seems to cause this problem. The behaviour can easily be reproduced with the following code snippet: -------------8<---------------------------------------------------------- use IO::Socket; use Tk; $d = pack( "n*", 42, 4711, 1234, 65535 ); $w = new MainWindow; $s = new IO::Socket::INET 'localhost:'.(getservbyname('echo', 'udp'))[2] or die "Cannot open socket for UDP echo: $!\n"; $w->fileevent( $s, 'readable', sub { $s->read( $res, length $d ) } ); $s->print($d); $SIG{ALRM} = sub { $res = '' }; alarm 5; DoOneEvent( Tk::DONT_WAIT ) until defined $res; print $res eq $d ? "SUCCEED\n" : "FAIL\n"; -------------8<---------------------------------------------------------- I've tried to understand what could cause the problem by looking at the code diffs between 800.023 and 800.024. The only change related to Tk::fileevent was the introduction of the untied filehandle in Event/Event.xs. Looking at the differences between filePtr->io and tmpio, I noticed that the xio_flags were different. While the original filehandle filePtr->io had the IOf_FLUSH flag set, xio_flags was zero for tmpio. I simply added a line to also copy the flags... IoFLAGS(tmpio) = IoFLAGS(filePtr->io); ...and everything works again, not breaking any tests. As I don't fully understand what's going on behind the scenes, this patch might just be some kind of kludge... -- Marcus
diff -ruN Tk800.024/Event/Event.xs Tk800.024work/Event/Event.xs --- Tk800.024/Event/Event.xs Mon Jan 7 10:35:44 2002 +++ Tk800.024work/Event/Event.xs Tue Sep 24 07:39:17 2002 @@ -344,6 +344,7 @@ IO *tmpio = GvIOp(filePtr->untied); IoIFP(tmpio) = IoIFP(filePtr->io); IoOFP(tmpio) = IoOFP(filePtr->io); + IoFLAGS(tmpio) = IoFLAGS(filePtr->io); return newRV((SV *) filePtr->untied); } return &PL_sv_undef;
Sorry this has festered so long. Report came in when I wasn't looking at Tk at all, then I noticed it was HPUX (which I can't test) and Tk800 (which I am hoping to replace). And all through this I hadn't noticed you had supplied the fix! Many thanks for clear test case and a fix. Your fix is now in Tk804 mainline.