fix some bug
This commit is contained in:
parent
a5e9d821b0
commit
9e0401a22c
2
client.c
2
client.c
@ -384,7 +384,7 @@ static int parse_arg(int argc,const char *argv[]){
|
|||||||
}
|
}
|
||||||
else if(strcmp("-h",argv[cur]) == 0 || strcmp("--help",argv[cur]) == 0){
|
else if(strcmp("-h",argv[cur]) == 0 || strcmp("--help",argv[cur]) == 0){
|
||||||
show_help_message(stdout,argv[0]);
|
show_help_message(stdout,argv[0]);
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
else if(strcmp("-q",argv[cur]) == 0 || strcmp("--quiet",argv[cur]) == 0){
|
else if(strcmp("-q",argv[cur]) == 0 || strcmp("--quiet",argv[cur]) == 0){
|
||||||
cmd_args.quiet_mode = true;
|
cmd_args.quiet_mode = true;
|
||||||
|
14
p-server.c
14
p-server.c
@ -58,8 +58,16 @@ static const int RESPONSE_REQUEST = DEFAULT_RESPONSE_REQUEST;
|
|||||||
#include "timerhelper.h"
|
#include "timerhelper.h"
|
||||||
|
|
||||||
enum{
|
enum{
|
||||||
|
#ifndef DEFAULT_TOP_TRACE_TIMER_ID
|
||||||
Top_Trace_Timer_ID = CLOCK_REALTIME,
|
Top_Trace_Timer_ID = CLOCK_REALTIME,
|
||||||
|
#else
|
||||||
|
Top_Trace_Timer_ID = DEFAULT_TOP_TRACE_TIMER_ID,
|
||||||
|
#endif
|
||||||
|
#ifndef DEFAULT_BOTTOM_TRACE_TIMER_ID
|
||||||
Bottom_Trace_Timer_ID = CLOCK_THREAD_CPUTIME_ID
|
Bottom_Trace_Timer_ID = CLOCK_THREAD_CPUTIME_ID
|
||||||
|
#else
|
||||||
|
Bottom_Trace_Timer_ID = DEFAULT_BOTTOM_TRACE_TIMER_ID
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void report_resolution()
|
static inline void report_resolution()
|
||||||
@ -311,7 +319,7 @@ int main(int argc, const char *argv[]){
|
|||||||
#ifdef USE_TRACE
|
#ifdef USE_TRACE
|
||||||
clock_gettime(Top_Trace_Timer_ID,&ts_top_begin);
|
clock_gettime(Top_Trace_Timer_ID,&ts_top_begin);
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr,"Connected on : %s:%d\n",msg == NULL ? "(null)" : msg , ntohs(client_addr.sin_port));
|
fprintf(stdout,"Connected on : %s:%d\n",msg == NULL ? "(null)" : msg , ntohs(client_addr.sin_port));
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if(pid == 0){
|
if(pid == 0){
|
||||||
#ifdef USE_TRACE
|
#ifdef USE_TRACE
|
||||||
@ -328,8 +336,8 @@ int main(int argc, const char *argv[]){
|
|||||||
#ifdef USE_TRACE
|
#ifdef USE_TRACE
|
||||||
clock_gettime(Bottom_Trace_Timer_ID,&ts_bottom_end);
|
clock_gettime(Bottom_Trace_Timer_ID,&ts_bottom_end);
|
||||||
struct timespec tophalf = timespec_sub(ts_top_end,ts_top_begin);
|
struct timespec tophalf = timespec_sub(ts_top_end,ts_top_begin);
|
||||||
struct timespec bottomhelf = timespec_sub(ts_bottom_end,ts_bottom_end);
|
struct timespec bottomhalf = timespec_sub(ts_bottom_end,ts_bottom_begin);
|
||||||
fprintf(stderr,"top: %ld ns, bottom: %ld ns\n",tophalf.tv_nsec,bottomhelf.tv_nsec);
|
fprintf(stderr,"top: %ld ns, bottom: %ld ns\n",tophalf.tv_nsec,bottomhalf.tv_nsec);
|
||||||
#endif
|
#endif
|
||||||
free(buf);
|
free(buf);
|
||||||
return retval;
|
return retval;
|
||||||
|
21
server.c
21
server.c
@ -68,8 +68,16 @@ static const int SLOW_SERVER_TIME = SLOW_SERVER;
|
|||||||
#ifdef USE_TRACE
|
#ifdef USE_TRACE
|
||||||
#include "timerhelper.h"
|
#include "timerhelper.h"
|
||||||
enum{
|
enum{
|
||||||
|
#ifndef DEFAULT_TOP_TRACE_TIMER_ID
|
||||||
Top_Trace_Timer_ID = CLOCK_REALTIME,
|
Top_Trace_Timer_ID = CLOCK_REALTIME,
|
||||||
|
#else
|
||||||
|
Top_Trace_Timer_ID = DEFAULT_TOP_TRACE_TIMER_ID,
|
||||||
|
#endif
|
||||||
|
#ifndef DEFAULT_BOTTOM_TRACE_TIMER_ID
|
||||||
Bottom_Trace_Timer_ID = CLOCK_THREAD_CPUTIME_ID
|
Bottom_Trace_Timer_ID = CLOCK_THREAD_CPUTIME_ID
|
||||||
|
#else
|
||||||
|
Bottom_Trace_Timer_ID = DEFAULT_BOTTOM_TRACE_TIMER_ID
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void report_resolution()
|
static inline void report_resolution()
|
||||||
@ -375,14 +383,15 @@ void * worker_proc(void * data){
|
|||||||
}
|
}
|
||||||
#ifdef USE_TRACE
|
#ifdef USE_TRACE
|
||||||
clock_gettime(Bottom_Trace_Timer_ID,&ts_bottom_end);
|
clock_gettime(Bottom_Trace_Timer_ID,&ts_bottom_end);
|
||||||
struct timespec tophalf = timespec_sub(ts_top_end,ts_top_end);
|
struct timespec tophalf = timespec_sub(ts_top_end,ts_top_begin);
|
||||||
struct timespec bottomhelf = timespec_sub(ts_bottom_end,ts_bottom_begin);
|
struct timespec bottomhalf = timespec_sub(ts_bottom_end,ts_bottom_begin);
|
||||||
if(use_gui&&isatty_file(stderr)){
|
if(use_gui&&isatty_file(stderr)){
|
||||||
lock_scrolled();
|
lock_scrolled();
|
||||||
add_scrolled_unlocked(1);
|
add_scrolled_unlocked(1);
|
||||||
fprintf(stderr,"top : %ld ns, bottom : %ld ns\n",tophalf.tv_nsec,bottomhelf.tv_nsec);
|
fprintf(stderr,"top : %ld ns, bottom : %ld ns\n",tophalf.tv_nsec,bottomhalf.tv_nsec);
|
||||||
unlock_scrolled();
|
unlock_scrolled();
|
||||||
}
|
}
|
||||||
|
else fprintf(stderr,"top : %ld ns, bottom : %ld ns\n",tophalf.tv_nsec,bottomhalf.tv_nsec);
|
||||||
#endif
|
#endif
|
||||||
if(close(csock) < 0)
|
if(close(csock) < 0)
|
||||||
server_perror("csock close error");
|
server_perror("csock close error");
|
||||||
@ -409,14 +418,14 @@ void * worker_proc(void * data){
|
|||||||
#ifdef USE_TRACE
|
#ifdef USE_TRACE
|
||||||
clock_gettime(Bottom_Trace_Timer_ID,&ts_bottom_end);
|
clock_gettime(Bottom_Trace_Timer_ID,&ts_bottom_end);
|
||||||
struct timespec tophalf = timespec_sub(ts_top_end,ts_top_begin);
|
struct timespec tophalf = timespec_sub(ts_top_end,ts_top_begin);
|
||||||
struct timespec bottomhelf = timespec_sub(ts_bottom_end,ts_bottom_begin);
|
struct timespec bottomhalf = timespec_sub(ts_bottom_end,ts_bottom_begin);
|
||||||
if(use_gui&&isatty_file(stderr)){
|
if(use_gui&&isatty_file(stderr)){
|
||||||
lock_scrolled();
|
lock_scrolled();
|
||||||
add_scrolled_unlocked(1);
|
add_scrolled_unlocked(1);
|
||||||
fprintf(stderr,"top : %ld ns, bottom : %ld ns\n",tophalf.tv_nsec,bottomhelf.tv_nsec);
|
fprintf(stderr,"top : %ld ns, bottom : %ld ns\n",tophalf.tv_nsec,bottomhalf.tv_nsec);
|
||||||
unlock_scrolled();
|
unlock_scrolled();
|
||||||
}
|
}
|
||||||
else fprintf(stderr,"top : %ld ns, bottom : %ld ns\n",tophalf.tv_nsec,bottomhelf.tv_nsec);
|
else fprintf(stderr,"top : %ld ns, bottom : %ld ns\n",tophalf.tv_nsec,bottomhalf.tv_nsec);
|
||||||
#endif
|
#endif
|
||||||
if(close(csock) < 0)
|
if(close(csock) < 0)
|
||||||
server_perror("csock close error");
|
server_perror("csock close error");
|
||||||
|
Loading…
Reference in New Issue
Block a user