]> git.ipfire.org Git - thirdparty/squid.git/blob - test-suite/waiter.c
Source Format Enforcement (#763)
[thirdparty/squid.git] / test-suite / waiter.c
1 /*
2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #include "squid.h"
10
11 #if HAVE_ASSERT_H
12 #include <assert.h>
13 #endif
14
15 int
16 main(int argc, char *argv[])
17 {
18 int i;
19 struct timeval now;
20 struct timeval alarm;
21 struct timeval to;
22 assert(argc == 2);
23 i = atoi(argv[1]);
24 gettimeofday(&now, NULL);
25 alarm.tv_sec = now.tv_sec + i + (now.tv_sec % i);
26 alarm.tv_usec = 0;
27 to.tv_sec = alarm.tv_sec - now.tv_sec;
28 to.tv_usec = alarm.tv_usec - now.tv_usec;
29 if (to.tv_usec < 0) {
30 to.tv_usec += 1000000;
31 to.tv_sec -= 1;
32 }
33 select(1, NULL, NULL, NULL, &to);
34 return 0;
35 }
36