示例#1
0
static
int
server_main(
    const char *                        filename)
{
    int                                 rc;
    globus_result_t                     result;
    http_test_server_t                  test_server;

    rc = globus_l_xio_test_read_file(filename);

    if (rc != 0)
    {
        goto error_exit;
    }

    result = http_test_server_init(
            &test_server,
            tcp_driver,
            http_driver,
            stack);

    if (result != GLOBUS_SUCCESS)
    {
        rc = 29;

        goto error_exit;
    }

    result = http_test_server_register_handler(
            &test_server,
            "/post-test",
            globus_l_xio_test_server_request_callback,
            &test_server);

    printf("%s\n", test_server.contact);

    fflush(stdout);

    result = http_test_server_run(&test_server);

    if (result != GLOBUS_SUCCESS)
    {
        rc = 30;

        goto error_exit;
    }
    http_test_server_destroy(&test_server);

error_exit:
    return rc;
}
int
server_test(
    http_test_info_t *			info,
    int					timer)
{
    int                                 rc = 0;
    globus_result_t                     result;
    http_test_server_t                  test_server;


    globus_utp_start_timer(timer);
    result = http_test_server_init(
            &test_server,
            info->tcp_driver,
            info->http_driver,
            info->stack);
    test_server.info = info;

    if (result != GLOBUS_SUCCESS)
    {
        rc = 29;

        goto error_exit;
    }

    result = http_test_server_register_handler(
            &test_server,
            "/post-test",
            globus_l_xio_test_server_request_callback,
            &test_server);

    printf("%s\n", test_server.contact);

    fflush(stdout);

    result = http_test_server_run(&test_server);

    if (result != GLOBUS_SUCCESS)
    {
        rc = 30;

        goto error_exit;
    }
    http_test_server_destroy(&test_server);
    globus_utp_stop_timer(timer);

error_exit:
    return rc;
}