From: <no...@so...> - 2001-09-07 23:42:03
|
Bugs item #219273, was opened at 2000-10-25 22:09 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=110894&aid=219273&group_id=10894 Category: 52. Macintosh Group: : 8.0.5 Status: Open Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) >Assigned to: Daniel A. Steffen (das) Summary: socket -async combined with fileevent is broken on the Mac Initial Comment: OriginalBugID: 1663 Bug Version: 8.0.5 SubmitDate: '1999-03-30' LastModified: '2000-04-14' Severity: CRIT Status: UnAssn Submitter: pat ChangedBy: hobbs RelatedBugIDs: 1776 OS: Macintosh OSVersion: 8.0 (PPC) Machine: Power PC FixedDate: '2000-10-25' ClosedDate: '2000-10-25' Name: mo ReproducibleScript: set server ftp.netscape.com set port 12345 if {[catch { set sock [socket -async $server $port] } err]} { puts "socket -async connect error 1 \$err\" } # define file event callback proc firstWritable { sock } { # remove writable fileevent handler fileevent $sock writable {} #find out if the connection worked by testing the -peername if [catch {fconfigure $sock -peername} peerinfo] { close $sock puts "socket -async connect error 2 \$peerinfo\" } else { puts "socket -async connect worked" } } # set up file event on the socket so we know # when it connects (or fails to connect) fileevent $sock writable "firstWritable $sock" ObservedBehavior: When this code is run under MacOS with Tcl 8.0.5 it will fail to run the fileevent callback in the case where the host is unreachable. This same code works perfectly under Unix. While this is bad, it gets even worse if you invoke the fconfigure command like this: fconfigure $sock Doing this will kill wish completely with an error dialog that says "error closing async connect socket" This is no way to recover from this! DesiredBehavior: I need to be able to test to see if the async socket connect worked using the writable fileevent. There is simply no other way to check the status of the socket without doing a read on the socket and doing a read on the socket is not an option because the program can not block Tk events during a network operation. It looks like the problem is located here. I am not sure what the fix is but a panic in this case does not seem like the correct action. tcl8.0.5/mac/tclMacSock.c:734 /* * If this socket is in the midddle on async connect we can just * abort the connect and release the stream right now. */ if (statePtr->flags & TCP_ASYNC_CONNECT) { InitMacTCPParamBlock(&closePB, TCPClose); closePB.tcpStream = tcpStream; closePB.ioCompletion = NULL; err = PBControlSync((ParmBlkPtr) &closePB); if (err != noErr) { panic("error closing async connect socket"); } statePtr->flags |= TCP_RELEASE; ---------------------------------------------------------------------- Comment By: Daniel A. Steffen (das) Date: 2001-08-24 10:30 Message: Logged In: YES user_id=90580 ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=110894&aid=219273&group_id=10894 |