Sha256: 85fae11d507e057ad8af66f4459e3004bc9a162a3f11252c4297924cdb3aa15e

Contents?: true

Size: 1.93 KB

Versions: 14

Compression:

Stored size: 1.93 KB

Contents

// Copyright 2023 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_ABUSE_POLICY_H
#define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_ABUSE_POLICY_H

#include <grpc/support/port_platform.h>

#include <string>

#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gprpp/time.h"

namespace grpc_core {

class Chttp2PingAbusePolicy {
 public:
  explicit Chttp2PingAbusePolicy(const ChannelArgs& args);

  static void SetDefaults(const ChannelArgs& args);

  // Record one received ping; returns true if the connection should be closed.
  // If transport_idle is true, we increase the allowed time between pings up to
  // TCP keep-alive check time.
  GRPC_MUST_USE_RESULT bool ReceivedOnePing(bool transport_idle);

  // Reset the ping clock, strike count.
  void ResetPingStrikes();

  int TestOnlyMaxPingStrikes() const { return max_ping_strikes_; }
  Duration TestOnlyMinPingIntervalWithoutData() const {
    return min_recv_ping_interval_without_data_;
  }

  std::string GetDebugString(bool transport_idle) const;

 private:
  Duration RecvPingIntervalWithoutData(bool transport_idle) const;

  Timestamp last_ping_recv_time_ = Timestamp::InfPast();
  const Duration min_recv_ping_interval_without_data_;
  int ping_strikes_ = 0;
  const int max_ping_strikes_;
};

}  // namespace grpc_core

#endif  // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_ABUSE_POLICY_H

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
grpc-1.59.5 src/core/ext/transport/chttp2/transport/ping_abuse_policy.h
grpc-1.60.2 src/core/ext/transport/chttp2/transport/ping_abuse_policy.h
grpc-1.61.3 src/core/ext/transport/chttp2/transport/ping_abuse_policy.h
grpc-1.62.3 src/core/ext/transport/chttp2/transport/ping_abuse_policy.h
grpc-1.63.2 src/core/ext/transport/chttp2/transport/ping_abuse_policy.h
grpc-1.63.0 src/core/ext/transport/chttp2/transport/ping_abuse_policy.h
grpc-1.62.0 src/core/ext/transport/chttp2/transport/ping_abuse_policy.h
grpc-1.62.0.pre1 src/core/ext/transport/chttp2/transport/ping_abuse_policy.h
grpc-1.61.0 src/core/ext/transport/chttp2/transport/ping_abuse_policy.h
grpc-1.61.0.pre2 src/core/ext/transport/chttp2/transport/ping_abuse_policy.h
grpc-1.60.0 src/core/ext/transport/chttp2/transport/ping_abuse_policy.h
grpc-1.60.0.pre1 src/core/ext/transport/chttp2/transport/ping_abuse_policy.h
grpc-1.59.2 src/core/ext/transport/chttp2/transport/ping_abuse_policy.h
grpc-1.59.0 src/core/ext/transport/chttp2/transport/ping_abuse_policy.h