From 355411acafb12704de5214122395134ecdef1b4f Mon Sep 17 00:00:00 2001 From: ubuntu201711081 <201711081@jbnu.ac.kr> Date: Tue, 8 Dec 2020 05:06:17 +0000 Subject: [PATCH] add SLOW_SERVER --- README.md | 6 ++++-- server.c | 13 ++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3e2918a..3dd679e 100644 --- a/README.md +++ b/README.md @@ -33,11 +33,13 @@ For server - DEFAULT_RESPONSE_REQUEST(p-server only): 3(-1 is INF) - USE_TRACE - USE_NO_QUEUE +- SLOW_SERVER(microsecond unit): if turn on sendfile option, DEFAULT_SEND_FILE_CHUNK_SIZE/SLOW bytes/usec, otherwise (buf_size/SLOW_CLIENT) bytes/usec For client - MUL_CLIENT(second unit) - SLOW_CLIENT(microsecond unit, (buf_size/SLOW_CLIENT) bytes/usec) -- DEFAULT_PROGRESS_BAR_WIDTH: 30 For both -- TIMEOUT: 5(second unit) \ No newline at end of file +- TIMEOUT: 5(second unit) +- MAX_TERMINAL_ROW +- DEFAULT_PROGRESS_BAR_WIDTH: 30 \ No newline at end of file diff --git a/server.c b/server.c index 2f89ec8..6411a39 100644 --- a/server.c +++ b/server.c @@ -61,8 +61,10 @@ enum{ MAX_THREAD_NUMBER = DEFAULT_MAX_THREAD_NUMBER #endif }; -#define USE_TRACE - +#ifdef SLOW_SERVER +//micro second unit +static const int SLOW_SERVER_TIME = SLOW_SERVER; +#endif /*======== *Operation @@ -186,6 +188,9 @@ int send_response(int sock,int fd, uint8_t * buf, size_t bufsize){ return -1; } DisplayProgressBar(&pbar,offset,r.file_size,"",false); + #ifdef SLOW_SERVER + usleep(SLOW_SERVER_TIME); + #endif } #else while (offset < r.file_size) @@ -200,8 +205,10 @@ int send_response(int sock,int fd, uint8_t * buf, size_t bufsize){ return -1; } offset += readed; - usleep(500000); DisplayProgressBar(&pbar,offset,r.file_size,"",false); + #ifdef SLOW_SERVER + usleep(SLOW_SERVER_TIME); + #endif } DisplayProgressBar(&pbar,offset,r.file_size,"",true); #endif