socket -async combined with fileevent is broken on the Mac
Closed / Out of Date219273ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 23 years ago
Descriptionplain2000-10-26 05:09:43
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;
dgp Ticket [219273ffff]: 1 change
[History diff]2001-04-01 01:47:31
dasplain2001-08-25 00:30:56
Logged In: YES user_id=90580
andreas_kupries Ticket [219273ffff]: 1 change
[History diff]2001-09-08 06:41:54
dgpplain2002-07-06 04:09:31
Logged In: YES user_id=80530 Is this bug still present in 8.4 ?
dasplain2004-03-30 14:30:36
Logged In: YES user_id=90580 mac classic bugs closed as "Out of date"
Log in (anonymous is fine) to add a comment.