Microsoft KB Archive/239726

= FIX: FtpOpenFile Fails in Asynchronous WinInet =

Article ID: 239726

Article Last Modified on 10/15/2002

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 4.01 Service Pack 1
 * Microsoft Internet Explorer 4.01 Service Pack 2

-



This article was previously published under Q239726



SYMPTOMS
In asynchronous WinInet mode you open a remote file with the FtpOpenFile function, read it with the InternetReadFile function, and then close the handle returned from FtpOpenFile with the InternetCloseHandle function. InternetCloseHandle returns TRUE. However, if you try to open another file with FtpOpenFile it fails with the error code 12110 (ERROR_FTP_TRANSFER_IN_PROGRESS). If you wait for the state of handle closing before opening another file anyway, you never get the status indication of INTERNET_STATUS_HANDLE_CLOSING from the callback function. The program stops responding.

The problem occurs only when the previous call to InternetReadFile was asynchronous or it failed with the error code of 997 (ERROR_IO_PENDING) at the first place.



CAUSE
InternetReadFile does not reset the refcount on a HANDLE_OBJECT after reaching EOF.



RESOLUTION
You can write a multiple-thread program in synchronous WinInet mode. The primary thread spawns a worker thread, which calls synchronous WinInet functions (blocking) so that the primary thread is free. Use any synchronization mechanisms, such as event object, to synchronize the primary thread and worker thread.



STATUS
The bug has been fixed in Internet Explorer 5 and later. There is no need to wait for the callback indication of INTERNET_STATUS_HANDLE_CLOSING before calling another FtpOpenFile if InternetCloseHandle returns TRUE.

Keywords: kbbug kbfix kbie500fix KB239726

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.