Winsock2 & overlapped IO
Martin.Wilck at fujitsu-siemens.com
Thu Nov 8 10:36:58 CST 2001
> The bulk of the implementation is in files/file.c and
> scheduler/synchro.c. When ReadFile is called on a handle, the
> following happens:
> 1. check that the handle is valid > FILE_FLAG_OVERLAPPED.
> 2. attempt to read any data that is available immediately, and perhaps
> return if we read enough already.
> 3. queue the operation onto CurrentTeb()->pending_list
I have taken a closer look at this code. I believe a very similar approach
is possible for Winsock. However, there are a few problems:
The asynchronous functions for Winsock take different arguments
than the file I/O functions. Thus, the async_handler structure
as defined in file.h must be changed such that Winsock can define
a compatible wsa_async_handler structure.
In a first attempt, I changed the sequence of fields in async_handler
such that common elements between file and winsock routines come first,
others at the end. Moreover, the "finish_async" function will be different
for File and Winsock I/O. Thus, I've come up with a new declaration of
async_private that looks like this:
typedef void (*async_handler) (struct async_private*, int);
typedef void (*async_finish) (struct async_private*, int);
typedef struct async_private
struct async_private *next;
struct async_private *prev;
/* "common" elements end here */
struct timeval tv;
What do you think about this?
It would be cleaner to define a "general" async structure
containing either a type-specific union or a pointer to
type-specific data, and using void* for pointers. However, that would
require even more changes in the async file I/O code, which I'd like to
avoid at the moment.
Another difference is that the overlapped Winsock routines cause
asynchronous success notification (i.e. calling the completion routine or
signalling the lpOverlapped->hEvent) even if they are immediately
successful, which seems not to be the case for asynchronous file I/O.
That would require a minor change in the check_async_list() routine.
Please tell me your opinion!
Martin Wilck Phone: +49 5251 8 15113
Fujitsu Siemens Computers Fax: +49 5251 8 20409
Heinz-Nixdorf-Ring 1 mailto:Martin.Wilck at Fujitsu-Siemens.com
D-33106 Paderborn http://www.fujitsu-siemens.com/primergy
More information about the wine-devel