Overview
| Artifact ID: | 0ab910bf33670e5ab2496e07f2cc7a797c0795bc |
|---|---|
| Ticket: | 219273ffffffffffffffffffffffffffffffffff
socket -async combined with fileevent is broken on the Mac |
| User & Date: | nobody on 2000-10-26 05:09:43 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
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; - foundin changed to: "final: 8.0.5"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "63. (unused)"
- title changed to:
socket -async combined with fileevent is broken on the Mac
- type changed to: "Bug"