From: Toby Douglass <[EMAIL PROTECTED]>
This is for those of you who've done some IO completion port work. According to my reading of the docs, GetQueuedCompletionStatus has four return status'; --- 1. return value != 0 - all went well, we've just returned from a successful dequeuing
Yes.
2. return value != 0 and lpOverlapped == NULL - all handles associated with the IO completion object have been closed and the IO completion object itself has been closed (time to quit)
For an lpOverlapped == NULL case I recognise two err codes, WAIT_TIMEOUT (common, because you can use a demuxer in poll mode) and ERROR_OPERATION_ABORTED. This last one I've never seen... I think, or only when someone rudely closes the iocp from under the thread calling GetQueuedCompletionStatus, something that really shouldn't be done.
3. return value == 0 and lpOverlapped != NULL - GetQueuedCompletionStatus() was okay, but we dequeued a *failed* IO operation (note that lpNumberOfBytes is not set in this case)
Really? What kind of io operation? WSASend/Receive? Connect/AcceptEx?
4. return value == ERROR_SUCCESS and lpOverlapped != NULL and *lpNumberOfBytes == 0 - the handle we've come back on is actually a socket, and the remote host has closed
The handle could be other things, but ok... p.s. !GetQueuedCompletionStatus indicates success and then you always get your lpOverlapped, lpNumberOfBytes has different interpretations based on the op (mostly what zero indicates).
--- Now, the problem is this: ERROR_SUCCESS is #defined as zero!
So !return_code => success!
In other words, I don't think it's possible to differentiate between case 3 and 4, because in case 3, *lpNumberOfBytes might be 0 just by chance.
If you're talking about socket IO, don't worry - the iocp won't bother you in the case that nothing arrived or was sent, it's different to select in that it tells you about stuff that has actually happened. You can get zero bytes on a WSAReceive which indicates socket closure. Erm, what cases are you actually trying to detect, maybe we can draw up a table of return vals and numbytes non-zeroness and outcome for a given op. RF _______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkey.org/mailman/listinfo/libevent-users