Brunet.Services.Dht.Dht.GetCloseHandler C# (CSharp) Method

GetCloseHandler() protected method

This is called by the Get callbacks when all the results for a get have come in. This looks at the results, finds holes, and does a follow up put to place the data back into the dht via GetFollowUp.
protected GetCloseHandler ( object o, EventArgs args ) : void
o object The channel representing a specific get.
args System.EventArgs Unused.
return void
    protected void GetCloseHandler(object o, EventArgs args) {
      Channel queue = (Channel) o;
      queue.EnqueueEvent -= this.GetEnqueueHandler;
      queue.CloseEvent -= this.GetCloseHandler;
      // Looking up state
      AsDhtGetState adgs = (AsDhtGetState) _adgs_table[queue];

      if(adgs == null) {
        return;
      }

      int count = 0;
      lock(adgs.SyncRoot) {
        adgs.queueMapping.Remove(queue);
        count = adgs.queueMapping.Count;
      }
      lock(_adgs_table.SyncRoot) {
        _adgs_table.Remove(queue);
      }
      if(count == 0) {
        adgs.returns.Close();
        GetFollowUp(adgs);
      }
      else if(count < MAJORITY && !adgs.GotToLeaveEarly) {
        lock(adgs.SyncRoot) {
          if(!adgs.GotToLeaveEarly) {
            GetLeaveEarly(adgs);
          }
        }
      }
    }