LCOV - code coverage report
Current view: top level - source3/lib - serverid.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 11 17 64.7 %
Date: 2021-09-23 10:06:22 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    Implementation of a reliable server_exists()
       4             :    Copyright (C) Volker Lendecke 2010
       5             : 
       6             :    This program is free software; you can redistribute it and/or modify
       7             :    it under the terms of the GNU General Public License as published by
       8             :    the Free Software Foundation; either version 3 of the License, or
       9             :    (at your option) any later version.
      10             : 
      11             :    This program is distributed in the hope that it will be useful,
      12             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :    GNU General Public License for more details.
      15             : 
      16             :    You should have received a copy of the GNU General Public License
      17             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      18             : */
      19             : 
      20             : #include "includes.h"
      21             : #include "lib/util/server_id.h"
      22             : #include "serverid.h"
      23             : #include "lib/param/param.h"
      24             : #include "ctdbd_conn.h"
      25             : #include "lib/messages_ctdb.h"
      26             : #include "lib/messaging/messages_dgm.h"
      27             : 
      28       50040 : static bool serverid_exists_local(const struct server_id *id)
      29             : {
      30       50040 :         bool exists = process_exists_by_pid(id->pid);
      31             :         uint64_t unique;
      32             :         int ret;
      33             : 
      34       50040 :         if (!exists) {
      35          38 :                 return false;
      36             :         }
      37             : 
      38       49993 :         if (id->unique_id == SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
      39           0 :                 return true;
      40             :         }
      41             : 
      42       49993 :         ret = messaging_dgm_get_unique(id->pid, &unique);
      43       49993 :         if (ret != 0) {
      44           0 :                 return false;
      45             :         }
      46             : 
      47       49993 :         return (unique == id->unique_id);
      48             : }
      49             : 
      50       50040 : bool serverid_exists(const struct server_id *id)
      51             : {
      52       50040 :         if (procid_is_local(id)) {
      53       50040 :                 return serverid_exists_local(id);
      54             :         }
      55             : 
      56           0 :         if (lp_clustering()) {
      57           0 :                 return ctdbd_process_exists(messaging_ctdb_connection(),
      58           0 :                                             id->vnn, id->pid, id->unique_id);
      59             :         }
      60             : 
      61           0 :         return false;
      62             : }

Generated by: LCOV version 1.13