mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 23:04:20 +01:00
5f68cd8242
git-svn-id: file:///svn/toku/tokudb@18191 c7de825b-a66e-492c-adef-691d508d4ae1
46 lines
995 B
C
46 lines
995 B
C
#include <test.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <toku_assert.h>
|
|
#include <fcntl.h>
|
|
#include <windows.h>
|
|
#include <winsock.h>
|
|
|
|
int usleep_socket(SOCKET s, unsigned int useconds) {
|
|
fd_set dummy;
|
|
struct timeval tv;
|
|
FD_ZERO(&dummy);
|
|
FD_SET(s, &dummy);
|
|
tv.tv_sec = useconds / 1000000;
|
|
tv.tv_usec = useconds % 1000000;
|
|
return select(0, 0, 0, &dummy, &tv);
|
|
}
|
|
|
|
int verbose;
|
|
|
|
int test_main(int argc, char *const argv[]) {
|
|
int i;
|
|
int n = 1;
|
|
WSADATA wsadata;
|
|
SOCKET s;
|
|
|
|
for (i=1; i<argc; i++) {
|
|
char *arg = argv[i];
|
|
if (strcmp(arg, "-v") == 0 || strcmp(arg, "--verbose") == 0)
|
|
verbose++;
|
|
n = atoi(arg);
|
|
}
|
|
|
|
WSAStartup(MAKEWORD(1, 0), &wsadata);
|
|
s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
|
printf("s=%"PRIu64"\n", s);
|
|
|
|
for (i=0; i<1000; i++) {
|
|
if (verbose) {
|
|
printf("usleep %d\n", i); fflush(stdout);
|
|
}
|
|
usleep_socket(s, n);
|
|
}
|
|
|
|
return 0;
|
|
}
|