NSIS-ka
A free C++ implementation of NSIS protocols

Changeset 4520


Ignore:
Timestamp:
Oct 6, 2009, 11:36:35 AM (8 years ago)
Author:
stud-lenk
Message:

Change multicast peer purging logic: Now counting missing responses up, not down

Location:
ntlp/branches/20090723-multicast/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ntlp/branches/20090723-multicast/src/routingentry.cpp

    r4498 r4520  
    120120    for (mcast_peer_it = multicast_peers.begin(); mcast_peer_it != multicast_peers.end(); mcast_peer_it++) {
    121121      os << std::endl << "  Multicast peer " << mcast_peer_it->first.get_if_address()
    122                       << ": " << mcast_peer_it->second.response_miss_allow_count << " missing responses allowed, MA re-use: "
     122                      << ": " << mcast_peer_it->second.missed_responses << " missing responses, MA re-use: "
    123123                      << mcast_peer_it->second.ma_reuse;
    124124    }
     
    145145    // This multicast peer is a new one, so add it to the list
    146146    multicast_peerstatus status;
    147     status.response_miss_allow_count = get_max_response_miss_count();
     147    status.missed_responses = 0;
    148148    status.ma_reuse = false;
    149149    multicast_peers[*peer] = status;
    150     DLog("MulticastQN", "Multicast peer " << peer->get_if_address() << " added and marked active (allowed to miss "
    151                         << status.response_miss_allow_count << " responses)");
     150    DLog("MulticastQN", "Multicast peer " << peer->get_if_address() << " added");
    152151  } else {
    153152    // this is a known multicast peer -- just re-activate it
    154     it->second.response_miss_allow_count = get_max_response_miss_count();
     153    it->second.missed_responses = 0;
    155154    DLog("MulticastQN", "Multicast peer " << peer->get_if_address() << " marked active");
    156155  }
     
    164163  for (it=multicast_peers.begin(); it != multicast_peers.end(); it++)
    165164  {
    166     it->second.response_miss_allow_count--;
     165    it->second.missed_responses++;
    167166  }
    168167}
     
    176175    return;
    177176  }
    178 
     177 
     178  // calculate maximum number of missing responses, a multicast peer
     179  // is allowed before it is purged from the multicast peer list
     180  uint32 max_missing_responses = 0;
     181  uint32 min_peer_rsv_time = get_min_peer_rs_validity_time();
     182  if (min_peer_rsv_time == 0) min_peer_rsv_time = gconf.getpar<uint32>(gistconf_rs_validity_time);
     183  do max_missing_responses++;
     184  while (max_missing_responses * (min_peer_rsv_time + get_retry_period()) < get_retry_limit());
     185  DLog("purge_multicast_peers()", "peers are allowed to miss " << max_missing_responses
     186                << " responses before being purged");
     187
     188  // iterate through list of multicast peers and purge those who exceed max_missing_responses
    179189  unsigned int purged_peer_count = 0;
    180190  mcast_peer_list_t::iterator it = multicast_peers.begin();
    181191  while (it != multicast_peers.end())
    182192  {
    183     if (it->second.response_miss_allow_count <= 0) {
     193    if (it->second.missed_responses > max_missing_responses) {
    184194      // erase_candidate is needed because otherwise `it' is invalid after multicast_peers.erase()
    185195      mcast_peer_list_t::iterator erase_candidate = it++;
    186196      purged_peer_count++;
    187       DLog("MulticastQN", "Multicast peer " << erase_candidate->first.get_if_address() << " purged");
     197      DLog("purge_multicast_peers()", "Multicast peer " << erase_candidate->first.get_if_address() << " purged");
    188198      multicast_peers.erase(erase_candidate);
    189199
     
    192202
    193203    } else {
    194       DLog("MulticastQN", "Multicast peer " << it->first.get_if_address() << " is allowed to miss "
    195                           << it->second.response_miss_allow_count << " responses without being purged");
     204      if (it->second.misses_responses != 0) {
     205        DLog("purge_multicast_peers()", "Multicast peer " << it->first.get_if_address()
     206                          << " has failed to respond to " << it->second.missed_responses
     207                          << " queries up to now");
     208      } else {
     209        DLog("purge_multicast_peers()", "Multicast peer " << it->first.get_if_address()
     210                          << " did respond to the latest query");
     211      }
    196212      it++;
    197213    }
    198214  }
    199215  if (purged_peer_count > 0)
    200     DLog("MulticastQN", "purge_multicast_peers(): " << purged_peer_count << " peers removed from list of multicast peers");
    201 }
    202 
    203 // returns the number of missed responses a multicast peer is allowed
    204 // before being purged from the multicast peer list
    205 uint32
    206 routingentry::get_max_response_miss_count() const
    207 {
    208   unsigned int miss_count = 0;
    209   uint32 min_peer_rsv_time = get_min_peer_rs_validity_time();
    210   if (min_peer_rsv_time == 0) min_peer_rsv_time = gconf.getpar<uint32>(gistconf_rs_validity_time);
    211   do {
    212     miss_count++;
    213   } while (miss_count * (min_peer_rsv_time + get_retry_period()) < get_retry_limit());
    214   return miss_count;
    215 }
     216    DLog("purge_multicast_peers()", purged_peer_count << " peers removed from list of multicast peers");
     217}
  • ntlp/branches/20090723-multicast/src/routingentry.h

    r4497 r4520  
    118118
    119119struct multicast_peerstatus {
    120   uint32 response_miss_allow_count;
     120  uint32 missed_responses;
    121121  bool ma_reuse;
    122122};
     
    332332        void expire_multicast_peers();
    333333        void purge_multicast_peers();
    334 
    335         // returns the number of missed responses a multicast peer is allowed
    336         // before being purged from the multicast peer list
    337         uint32 get_max_response_miss_count() const;
    338334
    339335        // return a const pointer to the hash_map of multicast peers
Note: See TracChangeset for help on using the changeset viewer.