LCOV - code coverage report
Current view: top level - source3/lib - serverid.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 13 19 68.4 %
Date: 2024-04-21 15:09:00 Functions: 2 2 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       53082 : static bool serverid_exists_local(const struct server_id *id)
      29             : {
      30       53082 :         bool exists = process_exists_by_pid(id->pid);
      31         596 :         uint64_t unique;
      32         596 :         int ret;
      33             : 
      34       53082 :         if (!exists) {
      35          46 :                 return false;
      36             :         }
      37             : 
      38       53027 :         if (id->unique_id == SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
      39           0 :                 return true;
      40             :         }
      41             : 
      42       53027 :         ret = messaging_dgm_get_unique(id->pid, &unique);
      43       53027 :         if (ret != 0) {
      44           0 :                 return false;
      45             :         }
      46             : 
      47       53027 :         return (unique == id->unique_id);
      48             : }
      49             : 
      50       53082 : bool serverid_exists(const struct server_id *id)
      51             : {
      52       53082 :         if (procid_is_local(id)) {
      53       53082 :                 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.14