Blame test/test_select.c

Packit 90a5c9
/* Licensed to the Apache Software Foundation (ASF) under one or more
Packit 90a5c9
 * contributor license agreements.  See the NOTICE file distributed with
Packit 90a5c9
 * this work for additional information regarding copyright ownership.
Packit 90a5c9
 * The ASF licenses this file to You under the Apache License, Version 2.0
Packit 90a5c9
 * (the "License"); you may not use this file except in compliance with
Packit 90a5c9
 * the License.  You may obtain a copy of the License at
Packit 90a5c9
 *
Packit 90a5c9
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 90a5c9
 *
Packit 90a5c9
 * Unless required by applicable law or agreed to in writing, software
Packit 90a5c9
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 90a5c9
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 90a5c9
 * See the License for the specific language governing permissions and
Packit 90a5c9
 * limitations under the License.
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
/* This is just a quick test program to see how long a wait is
Packit 90a5c9
 * produced by a select loop with an exponential backoff.
Packit 90a5c9
 *
Packit 90a5c9
 *   gcc -g -O2 -o test_select test_select.c
Packit 90a5c9
 *   test_select
Packit 90a5c9
 *
Packit 90a5c9
 * Roy Fielding, 1996
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
#include <stdio.h>
Packit 90a5c9
#include <stdlib.h>
Packit 90a5c9
#include <sys/time.h>
Packit 90a5c9
Packit 90a5c9
int main (void)
Packit 90a5c9
{
Packit 90a5c9
    int srv;
Packit 90a5c9
    long waittime = 4096;
Packit 90a5c9
    struct timeval tv;
Packit 90a5c9
Packit 90a5c9
    printf("Start\n");
Packit 90a5c9
    while ((waittime > 0) && (waittime < 3000000)) {
Packit 90a5c9
        printf("%d\n", waittime);
Packit 90a5c9
        tv.tv_sec  = waittime/1000000;
Packit 90a5c9
        tv.tv_usec = waittime%1000000;
Packit 90a5c9
        waittime <<= 1;
Packit 90a5c9
        srv = select(0, NULL, NULL, NULL, &tv;;
Packit 90a5c9
    }
Packit 90a5c9
    printf("End\n");
Packit 90a5c9
    exit(0);
Packit 90a5c9
}