ThorstenHirsch has asked for the wisdom of the Perl Monks concerning the following question:

Hi, anyone knows what Win32::GetLastError()==997 wants to tell me? I've found this one here so far:

Error: 997 Overlapped I/O operation is in progress.

So does it mean that there's already a connection on that tcp port...or what?
The error occurs when running UserGetGroups from Win32API::Net to ask the active directory groups the user belongs to - but only from within an system management framework (IBM's Tivoli to be precise). When I run the command manually it works. User and environment are exactly the same in both cases.

Regards,
Thorsten

  • Comment on Win32API::Net UserGetGroups returns error code 997

Replies are listed 'Best First'.
Re: Win32API::Net UserGetGroups returns error code 997 (irrelevant)
by tye (Sage) on Dec 10, 2004 at 18:29 UTC

    $^E [the friendly interface to Win32::GetLastError()] often gets set to "overlapped I/O". You should only check $^E or GetLastError() very soon after a function that reports errors via it has failed. If UserGetGroups() didn't fail, or if it isn't documented that it makes error reasons available via $^E or GetLastError(), or if you didn't check $^E soon enough after the failure, then the value of $^E doesn't mean anything.

    Checking the Win32API::Net documentation, I see they suggest using GetLastError(). Going further, I check the source code and see that the classic mistake of throwing away the error reason was made so I don't think they tested their assumption about the error reason being available from GetLastError(). The module needs to be patched to add a call to SetLastError() [for most of the XS functions] so that the documentation will be correct.

    As things stand, the error reason returned by GetLastError() has nothing to do with UserGetGroups(), whether it failed recently or not.

    The easiest way to get at the error reason would be to patch the module as I described and rebuild it, which requires that you get a C compiler. (Just another example of why XS code tends to suck and why one should try very hard to put less code in XS and more in Perl.)

    Alternately, you could try working around it with Win32::API (rather awkwardly).

    - tye        

Re: Win32API::Net UserGetGroups returns error code 997
by ikegami (Patriarch) on Dec 10, 2004 at 16:51 UTC

    Overlapped IO is what Windows calls its asynchronous IO mechanism. It allows one to start an IO operation (say, read from the disk) in a non-blocking fashion. Once the operation is completed, an Event is raised letting the application known the transfer completed.

    I don't know why you're seeing that in Perl. I'd consider it a bug.

    I'd try to sleep a bit and try again. Repeat until the error changes to success or a "real" error.

    By the way, keep in mind you should only check GetLastError if you were told a system error occured.