LCOV - code coverage report
Current view: top level - core/client_config - lb_policy.c (source / functions) Hit Total Coverage
Test: tmp.CaZ6RjdVn2 Lines: 30 30 100.0 %
Date: 2015-12-10 22:15:08 Functions: 10 10 100.0 %

          Line data    Source code
       1             : /*
       2             :  *
       3             :  * Copyright 2015, Google Inc.
       4             :  * All rights reserved.
       5             :  *
       6             :  * Redistribution and use in source and binary forms, with or without
       7             :  * modification, are permitted provided that the following conditions are
       8             :  * met:
       9             :  *
      10             :  *     * Redistributions of source code must retain the above copyright
      11             :  * notice, this list of conditions and the following disclaimer.
      12             :  *     * Redistributions in binary form must reproduce the above
      13             :  * copyright notice, this list of conditions and the following disclaimer
      14             :  * in the documentation and/or other materials provided with the
      15             :  * distribution.
      16             :  *     * Neither the name of Google Inc. nor the names of its
      17             :  * contributors may be used to endorse or promote products derived from
      18             :  * this software without specific prior written permission.
      19             :  *
      20             :  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
      21             :  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
      22             :  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
      23             :  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
      24             :  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
      25             :  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
      26             :  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
      27             :  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      28             :  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      29             :  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
      30             :  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      31             :  *
      32             :  */
      33             : 
      34             : #include "src/core/client_config/lb_policy.h"
      35             : 
      36        2343 : void grpc_lb_policy_init(grpc_lb_policy *policy,
      37             :                          const grpc_lb_policy_vtable *vtable) {
      38        2343 :   policy->vtable = vtable;
      39        2343 :   gpr_ref_init(&policy->refs, 1);
      40        2343 : }
      41             : 
      42             : #ifdef GRPC_LB_POLICY_REFCOUNT_DEBUG
      43             : void grpc_lb_policy_ref(grpc_lb_policy *policy, const char *file, int line,
      44             :                         const char *reason) {
      45             :   gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "LB_POLICY:%p   ref %d -> %d %s",
      46             :           policy, (int)policy->refs.count, (int)policy->refs.count + 1, reason);
      47             : #else
      48       13613 : void grpc_lb_policy_ref(grpc_lb_policy *policy) {
      49             : #endif
      50       13613 :   gpr_ref(&policy->refs);
      51       13613 : }
      52             : 
      53             : #ifdef GRPC_LB_POLICY_REFCOUNT_DEBUG
      54             : void grpc_lb_policy_unref(grpc_lb_policy *policy,
      55             :                           grpc_closure_list *closure_list, const char *file,
      56             :                           int line, const char *reason) {
      57             :   gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "LB_POLICY:%p unref %d -> %d %s",
      58             :           policy, (int)policy->refs.count, (int)policy->refs.count - 1, reason);
      59             : #else
      60       15843 : void grpc_lb_policy_unref(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy) {
      61             : #endif
      62       15843 :   if (gpr_unref(&policy->refs)) {
      63        2305 :     policy->vtable->destroy(exec_ctx, policy);
      64             :   }
      65       15843 : }
      66             : 
      67        2187 : void grpc_lb_policy_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy) {
      68        2187 :   policy->vtable->shutdown(exec_ctx, policy);
      69        2187 : }
      70             : 
      71     2114512 : int grpc_lb_policy_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
      72             :                         grpc_pollset *pollset,
      73             :                         grpc_metadata_batch *initial_metadata,
      74             :                         grpc_subchannel **target, grpc_closure *on_complete) {
      75     2114512 :   return policy->vtable->pick(exec_ctx, policy, pollset, initial_metadata,
      76             :                               target, on_complete);
      77             : }
      78             : 
      79          37 : void grpc_lb_policy_cancel_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
      80             :                                 grpc_subchannel **target) {
      81          37 :   policy->vtable->cancel_pick(exec_ctx, policy, target);
      82          37 : }
      83             : 
      84        2187 : void grpc_lb_policy_broadcast(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
      85             :                               grpc_transport_op *op) {
      86        2187 :   policy->vtable->broadcast(exec_ctx, policy, op);
      87        2187 : }
      88             : 
      89         271 : void grpc_lb_policy_exit_idle(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy) {
      90         271 :   policy->vtable->exit_idle(exec_ctx, policy);
      91         271 : }
      92             : 
      93        8606 : void grpc_lb_policy_notify_on_state_change(grpc_exec_ctx *exec_ctx,
      94             :                                            grpc_lb_policy *policy,
      95             :                                            grpc_connectivity_state *state,
      96             :                                            grpc_closure *closure) {
      97        8606 :   policy->vtable->notify_on_state_change(exec_ctx, policy, state, closure);
      98        8606 : }
      99             : 
     100        2225 : grpc_connectivity_state grpc_lb_policy_check_connectivity(
     101             :     grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy) {
     102        2225 :   return policy->vtable->check_connectivity(exec_ctx, policy);
     103             : }

Generated by: LCOV version 1.11