From: Naoki Kambe Date: Wed, 1 Aug 2012 06:37:23 +0000 (+0900) Subject: [2136] Separated the updating process from the receiving process X-Git-Tag: trac2351_base~112^2~28 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c832cd2d0699320b1e6258a61aa34c797f796268;p=thirdparty%2Fkea.git [2136] Separated the updating process from the receiving process In the updating process, it communicates with the cfgmgr module for updating statistics specification of each module. This fix is for separating such mixed communication process. --- diff --git a/src/bin/stats/stats.py.in b/src/bin/stats/stats.py.in index 34f255577a..4ca674f103 100755 --- a/src/bin/stats/stats.py.in +++ b/src/bin/stats/stats.py.in @@ -207,6 +207,7 @@ class Stats: sequences = sequences + [ (module_name, seq) \ for i in range(cnt-1) ] # start receiving statistics data + _statistics_data = [] while len(sequences) > 0: try: (module_name, seq) = sequences.pop(0) @@ -216,23 +217,28 @@ class Stats: rcode, args = isc.config.ccsession.parse_answer( answer) if rcode == 0: - if self.update_statistics_data( - module_name, env['from'], args): - logger.warn( - STATS_RECEIVED_INVALID_STATISTICS_DATA, - module_name) - else: - if self.update_statistics_data( - self.module_name, - self.cc_session.lname, - {'last_update_time': get_datetime()}): - logger.warn( - STATS_RECEIVED_INVALID_STATISTICS_DATA, - self.module_name) + _statistics_data.append( + (module_name, env['from'], args)) # skip this module if SessionTimeout raised except isc.cc.session.SessionTimeout: pass + # update statistics data + while len(_statistics_data) > 0: + (_module_name, _lname, _args) = _statistics_data.pop(0) + if self.update_statistics_data(_module_name, _lname, _args): + logger.warn( + STATS_RECEIVED_INVALID_STATISTICS_DATA, + _module_name) + else: + if self.update_statistics_data( + self.module_name, + self.cc_session.lname, + {'last_update_time': get_datetime()}): + logger.warn( + STATS_RECEIVED_INVALID_STATISTICS_DATA, + self.module_name) + def start(self): """ Start stats module