Пример #1
0
void
TclpExit(
    int status)		/* Ignored. */
{
    // Free the PLS
    CleanupGlobals();

    exit(status);
}
Пример #2
0
int
__cdecl
wmain(
    int argc,
    wchar_t **argv
    )

/*++

Routine Description:

    main

Arguments:

    argc -

    argv -

Return Value:

    Win32.

--*/

{
    DWORD dwError = ERROR_SUCCESS;
    PMYCONTEXT pRegularContext = NULL;
    PMYCONTEXT pCancelContext = NULL;

    if (argc != 2)
    {
        printf("Usage: %S <Server>\n", argv[0]);
        goto Exit;
    }

    dwError = InitializeGlobals(argv[1]);
    if (dwError != ERROR_SUCCESS)
    {
        goto Exit;
    }

    //
    // Kick off a regular request.
    //

    dwError = BeginRequest(L"/", &pRegularContext);
    if (dwError != ERROR_SUCCESS)
    {
        goto Exit;
    }

    //
    // Kick off a request we actually going to always cancel (for demonstration
    // purposes).
    //

    dwError = BeginRequest(L"/cancel", &pCancelContext);
    if (dwError != ERROR_SUCCESS)
    {
        goto Exit;
    }

    dwError = DemoCancel(pCancelContext);
    if (dwError != ERROR_SUCCESS)
    {
        goto Exit;
    }

    //
    // Wait for the regular request to complete normally.
    //

    dwError = EndRequest(pRegularContext);
    if (dwError != ERROR_SUCCESS)
    {
        goto Exit;
    }

    printf("pRegularContext completed successfully\n");

    //
    // Wait for the cancel request to complete normally.
    //

    dwError = EndRequest(pCancelContext);
    if (dwError != ERROR_SUCCESS)
    {
        if (dwError == ERROR_OPERATION_ABORTED ||
            dwError == ERROR_WINHTTP_OPERATION_CANCELLED)
        {
            printf("DemoCancelThreadFunc won the race and cancelled "
                   "pCancelContext\n");
        }

        goto Exit;
    }

    printf("pCancelContext completed successfully\n");

Exit:

    if (dwError != ERROR_SUCCESS) 
    {
        printf("dwError=%d\n", dwError);
    }

    if (pCancelContext != NULL)
    {
        DereferenceContext(pCancelContext);
        pCancelContext = NULL;
    }

    if (pRegularContext != NULL)
    {
        DereferenceContext(pRegularContext);
        pRegularContext = NULL;
    }

    CleanupGlobals();

    return (int)dwError;
}