Skip to content

Special case HttpCreateRequestQueue? #2215

@BrennanConroy

Description

@BrennanConroy

The docs for HttpCreateRequestQueue state that

The handle to the request queue created by HttpCreateRequestQueue must be closed by calling HttpCloseRequestQueue before the application terminates or when the session is no longer required.

Similarly, the docs for HttpCloseRequestQueue say

Applications should not call CloseHandle on the request queue handle; instead, they should call HttpCloseRequestQueue to ensure that all the resources are released.

The problem is that the SafeHandle created by the generator is a SafeFileHandle which calls CloseHandle which directly goes against the docs guidance.

Ideally, the generated code would use a custom SafeHandle implementation that overrides SafeHandle.ReleaseHandle with a call to HttpCloseRequestQueue so we wouldn't need to do something like:

PInvoke.HttpCreateRequestQueue(
                        HttpApi.Version,
                        requestQueueName,
                        SecurityAttributes: default,
                        flags,
                        out requestQueueHandle);

PInvoke.HttpCloseRequestQueue(requestQueueHandle);

// Avoid SafeHandle double disposing since we already called HttpCloseRequestQueue
requestQueueHandle.SetHandleAsInvalid();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions