add slow client

This commit is contained in:
ubuntu201711081 2020-12-04 10:10:40 +00:00
parent 9d012b2c6c
commit 226a0fbdc6
6 changed files with 21 additions and 1 deletions

View File

@ -18,6 +18,8 @@ p-server: socket_wrapper.o p-server.c
$(CC) -o p-server p-server.c socket_wrapper.o $(CFLAGS)
p-client: socket_wrapper.o p-client.c
$(CC) -o p-client p-client.c socket_wrapper.o $(CFLAGS)
p-slowclient: socket_wrapper.o p-client.c
$(CC) -o p-slowclient p-client.c socket_wrapper.o $(CFLAGS) -D SLOW_CLIENT=10
.PHONY: clean moveall
clean:

View File

@ -19,4 +19,5 @@ Available macro:
- DEFAULT_MAX_PATH_SIZE : 256(must be less than 1000)
- TIMEOUT : 5(second unit)
- USE_SENDFILE
- DEFAULT_SEND_FILE_CHUNK_SIZE : 0x100000(1MB)
- DEFAULT_SEND_FILE_CHUNK_SIZE : 0x100000(1MB)
- SLOW_CLIENT(second unit)

View File

@ -39,6 +39,9 @@ int sendReadOp(int sock,const char * filename){
perror("readop send fail");
return -1;
}
#ifdef SLOW_CLIENT
sleep(SLOW_CLIENT);
#endif
if(send(sock,filename,op.file_url_size,0)<0){
perror("readop filename send fail");
return -1;

View File

@ -12,6 +12,7 @@
#include <signal.h>
#include <assert.h>
#include <fcntl.h>
#include <sys/wait.h>
#include "socket_wrapper.h"
static const int MAX_LISTEN_SOCKET = 16;
@ -284,6 +285,13 @@ int main(int argc, const char *argv[]){
return 0;
}
}
for (i = 0; i < 3; i++)
{
int retval;
int pid = wait(&retval);
printf("[%d] %d: %d\n",i,pid,retval);
}
free(buf);
return 0;
}

3
pctest.sh Executable file
View File

@ -0,0 +1,3 @@
#! /bin/bash
cd client_test
./p-slowclient localhost 9091 test.txt & ./p-client localhost 9091 test.txt & ./p-client localhost 9091 test.txt

3
pstest.sh Executable file
View File

@ -0,0 +1,3 @@
#! /bin/bash
cd server_test
./p-server