|
@@ -23,9 +23,6 @@
|
|
|
#include "crc.h"
|
|
|
|
|
|
extern config_file config;
|
|
|
-static int recv_timeout_first=config.get("service.recv_timeout_first",10);
|
|
|
-static int site_sync_freq=config.get("site_sync.freq",60);//分站时间同步间隔
|
|
|
-static int site_sync=config.get("site_sync",0);//分站时间同步,考虑到双IP双机情况,缺省关闭
|
|
|
struct client_ex:client
|
|
|
{
|
|
|
virtual void on_notify()=0;
|
|
@@ -219,11 +216,20 @@ struct sock_client:fd_io,client_ex
|
|
|
|
|
|
// m_recv_timer.set(ic);
|
|
|
m_recv_timer.set<sock_client,&sock_client::on_recv_timeout>(this);
|
|
|
+ int recv_timeout_first=config.get("service.recv_timeout_first",10);
|
|
|
+
|
|
|
+
|
|
|
m_recv_timer.start(recv_timeout_first,0);
|
|
|
|
|
|
+ int site_sync=config.get("site_sync",0);//分站时间同步,考虑到双IP双机情况,缺省关闭
|
|
|
+ int site_sync_freq=config.get("site_sync.freq",10*60);//分站时间同步间隔
|
|
|
+
|
|
|
m_sync_timer.set<sock_client,&sock_client::on_sync_timeout>(this);
|
|
|
+
|
|
|
+ log_info("检测同步定时器:%s,%d",name,site_sync_freq);
|
|
|
if(site_sync)
|
|
|
{
|
|
|
+ log_info("启动分站同步定时器:%s,%d",name,site_sync_freq);
|
|
|
m_sync_timer.start(0,site_sync_freq);
|
|
|
}
|
|
|
|
|
@@ -289,6 +295,8 @@ struct sock_client:fd_io,client_ex
|
|
|
void on_sync_timeout()
|
|
|
{
|
|
|
// 从第一个字节开始,分别表示毫秒(2字节)、秒、分、时、天、月、年
|
|
|
+
|
|
|
+ log_info("分站同步:%s",m_name.c_str());
|
|
|
char buf[14]={0,12,0x78,0x3b};
|
|
|
|
|
|
struct timeval tv;
|
|
@@ -307,7 +315,7 @@ struct sock_client:fd_io,client_ex
|
|
|
buf[p++]=t->tm_hour;
|
|
|
buf[p++]=t->tm_mday;
|
|
|
buf[p++]=t->tm_mon;
|
|
|
- buf[p++]=t->tm_year;
|
|
|
+ buf[p++]=t->tm_year-100;
|
|
|
|
|
|
uint16_t ccrc=do_crc((unsigned char*)buf+2,10);
|
|
|
|