[svn] commit: r3434 - in /experiments/kambe-auth-stats/src/bin/auth: asio_link.cc auth_srv.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Nov 4 02:04:46 UTC 2010
Author: naokikambe
Date: Thu Nov 4 02:04:46 2010
New Revision: 3434
Log:
- add/change error handling
- add max/min value of timeout second
Modified:
experiments/kambe-auth-stats/src/bin/auth/asio_link.cc
experiments/kambe-auth-stats/src/bin/auth/auth_srv.cc
Modified: experiments/kambe-auth-stats/src/bin/auth/asio_link.cc
==============================================================================
--- experiments/kambe-auth-stats/src/bin/auth/asio_link.cc (original)
+++ experiments/kambe-auth-stats/src/bin/auth/asio_link.cc Thu Nov 4 02:04:46 2010
@@ -621,13 +621,17 @@
IOServiceImpl::AsWaitHandler(const asio::error_code& error)
{
if (error == asio::error::operation_aborted) {
- isc_throw(IOError, "AsWaitHandler: Error: " << error.message());
+ cerr << "[b10-auth] AsWaitHandler aborted: " << error.message()
+ << endl;
return;
- }
- if (!auth_server_->sendtoStats()) {
- isc_throw(IOError, "Failed to send statistics data");
- }
- dltimer_->cancel();
+ } else if (error) {
+ cerr << "[b10-auth] AsWaitHandler Error: " << error.message()
+ << endl;
+ return;
+ }
+ if (!auth_server_->sendtoStats())
+ return;
+ dltimer_->cancel(); // cancel the last operation if not done.
dltimer_->expires_at(dltimer_->expires_at()
+ boost::posix_time::seconds(
auth_server_->getTimeoutSec()));
Modified: experiments/kambe-auth-stats/src/bin/auth/auth_srv.cc
==============================================================================
--- experiments/kambe-auth-stats/src/bin/auth/auth_srv.cc (original)
+++ experiments/kambe-auth-stats/src/bin/auth/auth_srv.cc Thu Nov 4 02:04:46 2010
@@ -116,6 +116,8 @@
unsigned long long int tcp_q_count_;
// default timeout seconds
static const size_t DEFAULT_TIMEOUT_SEC_ = 180;
+ static const size_t MIN_TIMEOUT_SEC_ = 3;
+ static const size_t MAX_TIMEOUT_SEC_ = 3600;
};
AuthSrvImpl::AuthSrvImpl(const bool use_cache,
@@ -510,19 +512,27 @@
ConstElementPtr answer = isc::config::createAnswer();
// get send timeout secs from spec file
+ size_t new_timeout_sec_(timeout_sec_);
if (config && config->contains("stats_timeout_sec")) {
- const size_t new_timeout_sec_ = config->get("stats_timeout_sec")->intValue();
- if ( new_timeout_sec_ != timeout_sec_) {
- if (verbose_mode_) {
- cerr << "[b10-auth] stats sending timeout changed from " << timeout_sec_
- << " into " << new_timeout_sec_ << endl;
- }
- timeout_sec_ = new_timeout_sec_;
- }
+ new_timeout_sec_ = config->get("stats_timeout_sec")->intValue();
} else if (config_session_ != NULL) {
bool is_default;
string item("stats_timeout_sec");
- timeout_sec_ = config_session_->getValue(is_default, item)->intValue();
+ new_timeout_sec_ = config_session_->getValue(is_default, item)->intValue();
+ }
+ if (new_timeout_sec_ != timeout_sec_) {
+ if (new_timeout_sec_ < MIN_TIMEOUT_SEC_ || MAX_TIMEOUT_SEC_ < new_timeout_sec_) {
+ if (verbose_mode_) {
+ cerr << "[b10-auth] Timeout is beyond the min or max value, no changes: "
+ << new_timeout_sec_ << endl;
+ }
+ } else {
+ if (verbose_mode_) {
+ cerr << "[b10-auth] Sending frequency to stats is changed "
+ << timeout_sec_ << " to " << new_timeout_sec_ << endl;
+ }
+ timeout_sec_ = new_timeout_sec_;
+ }
}
if (config && config->contains("database_file")) {
@@ -602,7 +612,7 @@
udp_q_count_++;
} else {
// unknown protocol
- cerr << "[b10-auth] got unknown protocol: " << protocol
+ cerr << "[b10-auth] Unknown protocol in io_maassage : " << protocol
<< endl;
return (false);
}
@@ -633,7 +643,6 @@
static const string command_foot = "} } ] }";
string udp_q_count_str_ = boost::lexical_cast<string>(udp_q_count_);
string tcp_q_count_str_ = boost::lexical_cast<string>(tcp_q_count_);
-
string command_str = command_head
+ command_udp + ":" + udp_q_count_str_ + ","
+ command_tcp + ":" + tcp_q_count_str_
@@ -646,7 +655,7 @@
stats_session_->group_sendmsg(stats_command,
"Stats", "*", "*");
if (verbose_mode_) {
- cout << "[b10-auth] send statistics: " << command_str << endl;
+ cerr << "[b10-auth] send statistics: " << command_str << endl;
}
ConstElementPtr env, answer, parsed_answer;
stats_session_->group_recvmsg(env, answer, false, seq);
More information about the bind10-changes
mailing list