add SLOW_SERVER
This commit is contained in:
parent
5183083888
commit
355411acaf
@ -33,11 +33,13 @@ For server
|
|||||||
- DEFAULT_RESPONSE_REQUEST(p-server only): 3(-1 is INF)
|
- DEFAULT_RESPONSE_REQUEST(p-server only): 3(-1 is INF)
|
||||||
- USE_TRACE
|
- USE_TRACE
|
||||||
- USE_NO_QUEUE
|
- 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
|
For client
|
||||||
- MUL_CLIENT(second unit)
|
- MUL_CLIENT(second unit)
|
||||||
- SLOW_CLIENT(microsecond unit, (buf_size/SLOW_CLIENT) bytes/usec)
|
- SLOW_CLIENT(microsecond unit, (buf_size/SLOW_CLIENT) bytes/usec)
|
||||||
- DEFAULT_PROGRESS_BAR_WIDTH: 30
|
|
||||||
|
|
||||||
For both
|
For both
|
||||||
- TIMEOUT: 5(second unit)
|
- TIMEOUT: 5(second unit)
|
||||||
|
- MAX_TERMINAL_ROW
|
||||||
|
- DEFAULT_PROGRESS_BAR_WIDTH: 30
|
13
server.c
13
server.c
@ -61,8 +61,10 @@ enum{
|
|||||||
MAX_THREAD_NUMBER = DEFAULT_MAX_THREAD_NUMBER
|
MAX_THREAD_NUMBER = DEFAULT_MAX_THREAD_NUMBER
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
#define USE_TRACE
|
#ifdef SLOW_SERVER
|
||||||
|
//micro second unit
|
||||||
|
static const int SLOW_SERVER_TIME = SLOW_SERVER;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*========
|
/*========
|
||||||
*Operation
|
*Operation
|
||||||
@ -186,6 +188,9 @@ int send_response(int sock,int fd, uint8_t * buf, size_t bufsize){
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
DisplayProgressBar(&pbar,offset,r.file_size,"",false);
|
DisplayProgressBar(&pbar,offset,r.file_size,"",false);
|
||||||
|
#ifdef SLOW_SERVER
|
||||||
|
usleep(SLOW_SERVER_TIME);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
while (offset < r.file_size)
|
while (offset < r.file_size)
|
||||||
@ -200,8 +205,10 @@ int send_response(int sock,int fd, uint8_t * buf, size_t bufsize){
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
offset += readed;
|
offset += readed;
|
||||||
usleep(500000);
|
|
||||||
DisplayProgressBar(&pbar,offset,r.file_size,"",false);
|
DisplayProgressBar(&pbar,offset,r.file_size,"",false);
|
||||||
|
#ifdef SLOW_SERVER
|
||||||
|
usleep(SLOW_SERVER_TIME);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
DisplayProgressBar(&pbar,offset,r.file_size,"",true);
|
DisplayProgressBar(&pbar,offset,r.file_size,"",true);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user