diff --git a/jsonparse/web_cmd_parse.cpp b/jsonparse/web_cmd_parse.cpp index 711ea8a..e59b47d 100644 --- a/jsonparse/web_cmd_parse.cpp +++ b/jsonparse/web_cmd_parse.cpp @@ -77,9 +77,19 @@ std::string JsonData::JsonCmd_Cgi_02(Param_02 ¶m) { if (0 == param.mMode) { jsonVal["type"] = "SET"; if (param.mMode == 0) { //本地校时 - SetTime((unsigned long)param.mTimeStamp); - mssleep(200); - system("hwclock -w"); + unsigned long set_timestamp = (unsigned long)param.mTimeStamp; + char localtimestamp[32] = {0}; + GetTimeNet(localtimestamp, 1); + std::string current_system_timestamp = std::string(localtimestamp); + unsigned long current_timestamp = boost::lexical_cast(current_system_timestamp); + unsigned long diff_seconds = abs(current_timestamp - set_timestamp); + if (diff_seconds > 5) { + SetTime((unsigned long)param.mTimeStamp); + mssleep(200); + system("hwclock -w"); + } else { + zlog_warn(zct, "diff seconds:%ld lesser than 5, not to modify", diff_seconds); + } } else if (param.mMode == 1) { //与服务器校时 char buf[256] = {0}; sprintf(buf, "{\"dataNodeGatewayNo\":\"%s\",\"cmd\":\"12\",\"status\":\"REQ\"}", GlobalConfig::MacAddr_G.c_str());