add SLOW_SERVER

This commit is contained in:
ubuntu201711081 2020-12-08 05:06:17 +00:00
parent 5183083888
commit 355411acaf
2 changed files with 14 additions and 5 deletions

View File

@ -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)
- TIMEOUT: 5(second unit)
- MAX_TERMINAL_ROW
- DEFAULT_PROGRESS_BAR_WIDTH: 30

View File

@ -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