http://bugs.winehq.org/show_bug.cgi?id=2166
Summary: AsyncCallbacks in Wininet should not be asynchronous Product: Wine Version: 20040309 Platform: All OS/Version: other Status: UNCONFIRMED Severity: normal Priority: P2 Component: wine-net AssignedTo: wine-bugs@winehq.org ReportedBy: wjweiss@hotmail.com
My research has shown that the native WININET implementation invokes the statuscallback from whatever thread that performs the work that requires a notification. However, the implementation of SendAsyncCallback in Utility.C uses the INTERNET_FLAG_ASYNC option associated with the connection as the criteria for generating an async response.
This would cause fault in asynchronous pluggable protocols that perform a close handle and terminate because the HANDLE_CLOSING notification can arrive after the APP has terminated. However, on further investigation, I have discovered that in the native implementation race conditions are avoided by disabling the statuscallback assocated with the handle before removing the handle thereby disabling the callback.
I would recommend that the correct fix is to check if the statuscallback is associated with the handle being closed in InternetCloseHandle, and to disable the callback.
I would also recommend making callbacks synchronous. In my testing I have not seen any problems after making this change. However, this change would be strictly a change with closer consistency and better performance.
I would also recommend a name change from SendAsyncCallback to SendCallback.