From 226a0fbdc61206b58bbc8cd8ddaa250744eaefe4 Mon Sep 17 00:00:00 2001 From: ubuntu201711081 <201711081@jbnu.ac.kr> Date: Fri, 4 Dec 2020 10:10:40 +0000 Subject: [PATCH] add slow client --- Makefile | 2 ++ README.md | 3 ++- p-client.c | 3 +++ p-server.c | 8 ++++++++ pctest.sh | 3 +++ pstest.sh | 3 +++ 6 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 pctest.sh create mode 100755 pstest.sh diff --git a/Makefile b/Makefile index 338070d..5d57802 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/README.md b/README.md index b3d9021..f6ec5f9 100644 --- a/README.md +++ b/README.md @@ -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) \ No newline at end of file + - DEFAULT_SEND_FILE_CHUNK_SIZE : 0x100000(1MB) +- SLOW_CLIENT(second unit) \ No newline at end of file diff --git a/p-client.c b/p-client.c index 17955d3..9d1fc57 100644 --- a/p-client.c +++ b/p-client.c @@ -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; diff --git a/p-server.c b/p-server.c index 1d5f791..bb67be1 100644 --- a/p-server.c +++ b/p-server.c @@ -12,6 +12,7 @@ #include #include #include +#include #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; } \ No newline at end of file diff --git a/pctest.sh b/pctest.sh new file mode 100755 index 0000000..c15050b --- /dev/null +++ b/pctest.sh @@ -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 \ No newline at end of file diff --git a/pstest.sh b/pstest.sh new file mode 100755 index 0000000..c8cb742 --- /dev/null +++ b/pstest.sh @@ -0,0 +1,3 @@ +#! /bin/bash +cd server_test +./p-server \ No newline at end of file