// package-private
  void drop(MembershipKeyImpl key) {
    assert key.channel() == this;

    synchronized (stateLock) {
      if (!key.isValid()) return;

      try {
        if (key instanceof MembershipKeyImpl.Type6) {
          MembershipKeyImpl.Type6 key6 = (MembershipKeyImpl.Type6) key;
          Net.drop6(fd, key6.groupAddress(), key6.index(), key6.source());
        } else {
          MembershipKeyImpl.Type4 key4 = (MembershipKeyImpl.Type4) key;
          Net.drop4(fd, key4.groupAddress(), key4.interfaceAddress(), key4.source());
        }
      } catch (IOException ioe) {
        // should not happen
        throw new AssertionError(ioe);
      }

      key.invalidate();
      registry.remove(key);
    }
  }