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