fix some bug

This commit is contained in:
ubuntu201711081 2020-12-08 11:37:54 +00:00
parent a5e9d821b0
commit 9e0401a22c
3 changed files with 27 additions and 10 deletions

View File

@ -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){
show_help_message(stdout,argv[0]);
return 0;
return -1;
}
else if(strcmp("-q",argv[cur]) == 0 || strcmp("--quiet",argv[cur]) == 0){
cmd_args.quiet_mode = true;

View File

@ -58,8 +58,16 @@ static const int RESPONSE_REQUEST = DEFAULT_RESPONSE_REQUEST;
#include "timerhelper.h"
enum{
#ifndef DEFAULT_TOP_TRACE_TIMER_ID
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
#else
Bottom_Trace_Timer_ID = DEFAULT_BOTTOM_TRACE_TIMER_ID
#endif
};
static inline void report_resolution()
@ -311,7 +319,7 @@ int main(int argc, const char *argv[]){
#ifdef USE_TRACE
clock_gettime(Top_Trace_Timer_ID,&ts_top_begin);
#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();
if(pid == 0){
#ifdef USE_TRACE
@ -328,8 +336,8 @@ int main(int argc, const char *argv[]){
#ifdef USE_TRACE
clock_gettime(Bottom_Trace_Timer_ID,&ts_bottom_end);
struct timespec tophalf = timespec_sub(ts_top_end,ts_top_begin);
struct timespec bottomhelf = timespec_sub(ts_bottom_end,ts_bottom_end);
fprintf(stderr,"top: %ld ns, bottom: %ld ns\n",tophalf.tv_nsec,bottomhelf.tv_nsec);
struct timespec bottomhalf = timespec_sub(ts_bottom_end,ts_bottom_begin);
fprintf(stderr,"top: %ld ns, bottom: %ld ns\n",tophalf.tv_nsec,bottomhalf.tv_nsec);
#endif
free(buf);
return retval;

View File

@ -68,8 +68,16 @@ static const int SLOW_SERVER_TIME = SLOW_SERVER;
#ifdef USE_TRACE
#include "timerhelper.h"
enum{
#ifndef DEFAULT_TOP_TRACE_TIMER_ID
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
#else
Bottom_Trace_Timer_ID = DEFAULT_BOTTOM_TRACE_TIMER_ID
#endif
};
static inline void report_resolution()
@ -375,14 +383,15 @@ void * worker_proc(void * data){
}
#ifdef USE_TRACE
clock_gettime(Bottom_Trace_Timer_ID,&ts_bottom_end);
struct timespec tophalf = timespec_sub(ts_top_end,ts_top_end);
struct timespec bottomhelf = timespec_sub(ts_bottom_end,ts_bottom_begin);
struct timespec tophalf = timespec_sub(ts_top_end,ts_top_begin);
struct timespec bottomhalf = timespec_sub(ts_bottom_end,ts_bottom_begin);
if(use_gui&&isatty_file(stderr)){
lock_scrolled();
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();
}
else fprintf(stderr,"top : %ld ns, bottom : %ld ns\n",tophalf.tv_nsec,bottomhalf.tv_nsec);
#endif
if(close(csock) < 0)
server_perror("csock close error");
@ -409,14 +418,14 @@ void * worker_proc(void * data){
#ifdef USE_TRACE
clock_gettime(Bottom_Trace_Timer_ID,&ts_bottom_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)){
lock_scrolled();
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();
}
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
if(close(csock) < 0)
server_perror("csock close error");