Tk Library Source Code

View Ticket
Login
Ticket UUID: 1076923
Title: ftp::close failing
Type: Bug Version: None
Submitter: keithv Created on: 2004-12-01 17:26:38
Subsystem: ftp Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2005-02-15 07:06:42
Resolution: Fixed Closed By: andreas_kupries
    Closed on: 2005-02-15 00:06:42
Description:
I'm consistently getting an error while 
calling ::ftp::close after downloading multiple files. The 
error message reads 
  error reading "sock1868": connection reset by peer 
  while executing "gets $sock bufline" 
  (procedure "::ftp::StateHandler" line 16)


I dug into this a bit and it appears to be a timing error.. 
It occurs after a "QUIT" has been sent to the server 
and ::ftp::StateHandler is trying to read the goodbye 
lines but the connection gets reset before it can do so.

The simplest solution two fold: first wrap the "gets" in a 
catch and setting number to 0 when it fails. Second, in 
the error handling code don't give error 
message "Service not available" if $ftp(State) 
eq "quit_sent". I've attached a file with the updated 
procedure with the fix.

An annoying aspect of this bug is that it occurs in a 
background handler and there's a vwait that doesn't get 
satisfied--effectively making this uncatchable.
User Comments: andreas_kupries added on 2005-02-15 07:06:42:
Logged In: YES 
user_id=75003

Accepted the patch, committed to CVS head.

Side comment: The whole implementation of the ftp package,
with its big StateHandler is annoying in general. 

Side note 2: Next time when attaching not a patch please
attach the whole file, and not only the changed command.
That makes running the diff against the current revision
much easier. With tkdiff I can relatively easy ignore the
irrelevant chunks, but  when using a non-graphical diff it
is inconvenient.

keithv added on 2004-12-02 00:26:39:

File Added - 110868: stateHandler.tcl

Attachments: