lib: Remove unused serverid.tdb
[samba.git] / source3 / lib / serverid.c
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/messages_dgm.h"
27
28 static bool serverid_exists_local(const struct server_id *id)
29 {
30         bool exists = process_exists_by_pid(id->pid);
31         uint64_t unique;
32         int ret;
33
34         if (!exists) {
35                 return false;
36         }
37
38         if (id->unique_id == SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
39                 return true;
40         }
41
42         ret = messaging_dgm_get_unique(id->pid, &unique);
43         if (ret != 0) {
44                 return false;
45         }
46
47         return (unique == id->unique_id);
48 }
49
50 bool serverid_exists(const struct server_id *id)
51 {
52         if (procid_is_local(id)) {
53                 return serverid_exists_local(id);
54         }
55
56         if (lp_clustering()) {
57                 return ctdbd_process_exists(messaging_ctdb_connection(),
58                                             id->vnn, id->pid, id->unique_id);
59         }
60
61         return false;
62 }