mirror of
https://github.com/fumiama/simple-kanban.git
synced 2026-06-29 23:51:09 +08:00
optimize: keep timer on send_all
This commit is contained in:
4
config.h
4
config.h
@@ -13,4 +13,8 @@ struct const_config_t {
|
|||||||
};
|
};
|
||||||
typedef struct const_config_t const_config_t;
|
typedef struct const_config_t const_config_t;
|
||||||
|
|
||||||
|
#define TCPOOL_THREAD_TIMER_T_SZ 65536
|
||||||
|
|
||||||
|
#define TCPOOL_MAXWAITSEC 16
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
11
server.c
11
server.c
@@ -38,10 +38,6 @@ static file_cache_t kanban_file_cache;
|
|||||||
static uint8_t _cfg[sizeof(simple_pb_t)+sizeof(config_t)];
|
static uint8_t _cfg[sizeof(simple_pb_t)+sizeof(config_t)];
|
||||||
#define cfg ((const const_config_t*)(_cfg+sizeof(simple_pb_t))) // 存储 pwd 和 sps
|
#define cfg ((const const_config_t*)(_cfg+sizeof(simple_pb_t))) // 存储 pwd 和 sps
|
||||||
|
|
||||||
#define TCPOOL_THREAD_TIMER_T_SZ 65536
|
|
||||||
|
|
||||||
#define TCPOOL_MAXWAITSEC 16
|
|
||||||
|
|
||||||
#define SERVER_THREAD_BUFSZ ( \
|
#define SERVER_THREAD_BUFSZ ( \
|
||||||
TCPOOL_THREAD_TIMER_T_SZ \
|
TCPOOL_THREAD_TIMER_T_SZ \
|
||||||
-TCPOOL_THREAD_TIMER_T_HEAD_SZ \
|
-TCPOOL_THREAD_TIMER_T_HEAD_SZ \
|
||||||
@@ -55,7 +51,7 @@ static uint8_t _cfg[sizeof(simple_pb_t)+sizeof(config_t)];
|
|||||||
uint8_t isopen; /* 是否获得了文件锁 */ \
|
uint8_t isopen; /* 是否获得了文件锁 */ \
|
||||||
char data[SERVER_THREAD_BUFSZ]
|
char data[SERVER_THREAD_BUFSZ]
|
||||||
|
|
||||||
#define TCPOOL_TOUCH_TIMER_CONDITION 0
|
#define TCPOOL_TOUCH_TIMER_CONDITION (is_sending_all[index])
|
||||||
|
|
||||||
#define TCPOOL_INIT_ACTION \
|
#define TCPOOL_INIT_ACTION \
|
||||||
file_cache_init(&data_file_cache, data_path); \
|
file_cache_init(&data_file_cache, data_path); \
|
||||||
@@ -69,10 +65,13 @@ static uint8_t _cfg[sizeof(simple_pb_t)+sizeof(config_t)];
|
|||||||
if(timer->isopen) file_cache_unlock(timer->isdata?&data_file_cache:&kanban_file_cache); \
|
if(timer->isopen) file_cache_unlock(timer->isdata?&data_file_cache:&kanban_file_cache); \
|
||||||
timer->isopen = 0; \
|
timer->isopen = 0; \
|
||||||
timer->isdata = 0; \
|
timer->isdata = 0; \
|
||||||
|
is_sending_all[timer->index] = 0; \
|
||||||
timer->status = -1;
|
timer->status = -1;
|
||||||
|
|
||||||
#include "tcpool.h"
|
#include "tcpool.h"
|
||||||
|
|
||||||
|
static volatile uintptr_t is_sending_all[TCPOOL_THREADCNT];
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check_buffer 检查接收到的数据,结合
|
* check_buffer 检查接收到的数据,结合
|
||||||
@@ -172,7 +171,9 @@ static int send_all(tcpool_thread_timer_t *timer) {
|
|||||||
#endif
|
#endif
|
||||||
{(void*)fc->data, file_size}
|
{(void*)fc->data, file_size}
|
||||||
};
|
};
|
||||||
|
is_sending_all[timer->index] = 1;
|
||||||
re = writev(timer->accept_fd, (const struct iovec *)&iov, 2);
|
re = writev(timer->accept_fd, (const struct iovec *)&iov, 2);
|
||||||
|
is_sending_all[timer->index] = 0;
|
||||||
pthread_cleanup_pop(1);
|
pthread_cleanup_pop(1);
|
||||||
if(re <= 0) {
|
if(re <= 0) {
|
||||||
perror("writev");
|
perror("writev");
|
||||||
|
|||||||
Reference in New Issue
Block a user