add comment
This commit is contained in:
parent
d177b33177
commit
f2e8bf2376
@ -1,29 +1,30 @@
|
|||||||
#include<stdio.h>
|
#include<stdio.h>
|
||||||
#include<time.h>
|
#include<time.h>
|
||||||
#include<stdbool.h>
|
#include<stdbool.h>
|
||||||
|
#include<stddef.h>
|
||||||
|
|
||||||
#ifndef _DISPLAY_BAR_H_
|
#ifndef _DISPLAY_BAR_H_
|
||||||
#define _DISPLAY_BAR_H_
|
#define _DISPLAY_BAR_H_
|
||||||
|
|
||||||
|
//declare for raw operation
|
||||||
typedef unsigned raw_progress_bar_t;
|
typedef unsigned raw_progress_bar_t;
|
||||||
|
|
||||||
void lock_scrolled();
|
void lock_scrolled();
|
||||||
|
|
||||||
void unlock_scrolled();
|
void unlock_scrolled();
|
||||||
|
|
||||||
void ready_progress_bar();
|
|
||||||
|
|
||||||
void quit_progress_bar();
|
|
||||||
|
|
||||||
void add_scrolled_unlocked(unsigned int i);
|
void add_scrolled_unlocked(unsigned int i);
|
||||||
|
|
||||||
raw_progress_bar_t create_raw_progress_bar();
|
raw_progress_bar_t create_raw_progress_bar();
|
||||||
|
|
||||||
void RawDisplayProgressBar(raw_progress_bar_t bar,size_t offset,size_t total,const char * filename);
|
void RawDisplayProgressBar(raw_progress_bar_t bar,size_t offset,size_t total,const char * filename);
|
||||||
|
|
||||||
|
//you should call before using progrees bar.
|
||||||
|
void ready_progress_bar();
|
||||||
|
//quit progress bar system.
|
||||||
|
void quit_progress_bar();
|
||||||
|
//same as isatty
|
||||||
bool isatty_file(FILE * file);
|
bool isatty_file(FILE * file);
|
||||||
|
|
||||||
|
//
|
||||||
void myd_perror(const char * msg);
|
void myd_perror(const char * msg);
|
||||||
|
int myd_vfprintf(int line,FILE * f,const char * msg,va_list arg);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
raw_progress_bar_t bar;
|
raw_progress_bar_t bar;
|
||||||
|
6
server.c
6
server.c
@ -318,7 +318,7 @@ void init_shared_state(shared_state_t * state) {
|
|||||||
pthread_cond_init(&state->ready,NULL);
|
pthread_cond_init(&state->ready,NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//
|
//argument for thread worker
|
||||||
typedef struct WorkerArgument
|
typedef struct WorkerArgument
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
@ -365,10 +365,11 @@ void * worker_proc(void * data){
|
|||||||
#endif
|
#endif
|
||||||
for(;;){
|
for(;;){
|
||||||
pthread_mutex_lock(&globalState.sock_mutex);
|
pthread_mutex_lock(&globalState.sock_mutex);
|
||||||
|
//wait until request come.
|
||||||
while (queue_isempty(&globalState.socks)){
|
while (queue_isempty(&globalState.socks)){
|
||||||
pthread_cond_wait(&globalState.ready,&globalState.sock_mutex);
|
pthread_cond_wait(&globalState.ready,&globalState.sock_mutex);
|
||||||
}
|
}
|
||||||
csock = dequeue(&globalState.socks);
|
csock = dequeue(&globalState.socks); //dequeue socket descriptor for request.
|
||||||
#ifdef USE_TRACE
|
#ifdef USE_TRACE
|
||||||
ts_top_begin = dequeue(&globalState.trace_timer);
|
ts_top_begin = dequeue(&globalState.trace_timer);
|
||||||
#endif
|
#endif
|
||||||
@ -377,6 +378,7 @@ void * worker_proc(void * data){
|
|||||||
clock_gettime(Top_Trace_Timer_ID,&ts_top_end);
|
clock_gettime(Top_Trace_Timer_ID,&ts_top_end);
|
||||||
clock_gettime(Bottom_Trace_Timer_ID,&ts_bottom_begin);
|
clock_gettime(Bottom_Trace_Timer_ID,&ts_bottom_begin);
|
||||||
#endif
|
#endif
|
||||||
|
//process request.
|
||||||
if((fd = read_request(csock,args->buf,args->bufsize)) > 0){
|
if((fd = read_request(csock,args->buf,args->bufsize)) > 0){
|
||||||
send_response(csock,fd,args->buf,args->bufsize);
|
send_response(csock,fd,args->buf,args->bufsize);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
#define _TIMERHELPER_H_
|
#define _TIMERHELPER_H_
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#ifndef __always_inline
|
||||||
|
#define __always_inline
|
||||||
|
#endif
|
||||||
|
|
||||||
__always_inline struct timespec timespec_sub(struct timespec a,struct timespec b){
|
__always_inline struct timespec timespec_sub(struct timespec a,struct timespec b){
|
||||||
struct timespec ret;
|
struct timespec ret;
|
||||||
ret.tv_sec = a.tv_sec - b.tv_sec;
|
ret.tv_sec = a.tv_sec - b.tv_sec;
|
||||||
|
Loading…
Reference in New Issue
Block a user