LCOV - code coverage report
Current view: top level - source4/cluster - cluster.c (source / functions) Hit Total Coverage
Test: coverage report for master 469b22b8 Lines: 12 20 60.0 %
Date: 2024-06-10 12:05:21 Functions: 4 7 57.1 %

          Line data    Source code
       1             : /* 
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    core clustering code
       5             : 
       6             :    Copyright (C) Andrew Tridgell 2006
       7             :    
       8             :    This program is free software; you can redistribute it and/or modify
       9             :    it under the terms of the GNU General Public License as published by
      10             :    the Free Software Foundation; either version 3 of the License, or
      11             :    (at your option) any later version.
      12             :    
      13             :    This program is distributed in the hope that it will be useful,
      14             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :    GNU General Public License for more details.
      17             :    
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      20             : */
      21             : 
      22             : #include "includes.h"
      23             : #include "cluster/cluster.h"
      24             : #include "cluster/cluster_private.h"
      25             : #include "librpc/gen_ndr/misc.h"
      26             : #include "librpc/gen_ndr/server_id.h"
      27             : 
      28             : static struct cluster_ops *ops;
      29             : 
      30             : /* set cluster operations */
      31        1359 : void cluster_set_ops(struct cluster_ops *new_ops)
      32             : {
      33        1359 :         ops = new_ops;
      34        1359 : }
      35             : 
      36             : /*
      37             :   an ugly way of getting at the backend handle (eg. ctdb context) via the cluster API
      38             : */
      39           0 : void *cluster_backend_handle(void)
      40             : {
      41           0 :         return ops->backend_handle(ops);
      42             : }
      43             : 
      44             : /* by default use the local ops */
      45      254912 : static void cluster_init(void)
      46             : {
      47      232242 :         if (ops == NULL) cluster_local_init();
      48      232124 : }
      49             : 
      50             : /*
      51             :   create a server_id for the local node
      52             : */
      53      144534 : struct server_id cluster_id(uint64_t pid, uint32_t task_id)
      54             : {
      55      144534 :         cluster_init();
      56      144534 :         return ops->cluster_id(ops, pid, task_id);
      57             : }
      58             : 
      59             : /*
      60             :   open a temporary tdb in a cluster friendly manner
      61             : */
      62      110378 : struct db_context *cluster_db_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *dbbase, int flags)
      63             : {
      64      110378 :         cluster_init();
      65      110378 :         return ops->cluster_db_tmp_open(ops, mem_ctx, lp_ctx, dbbase, flags);
      66             : }
      67             : 
      68             : 
      69             : /*
      70             :   register a callback function for a messaging endpoint
      71             : */
      72           0 : NTSTATUS cluster_message_init(struct imessaging_context *msg, struct server_id server,
      73             :                               cluster_message_fn_t handler)
      74             : {
      75           0 :         cluster_init();
      76           0 :         return ops->message_init(ops, msg, server, handler);
      77             : }
      78             : 
      79             : /*
      80             :   send a message to another node in the cluster
      81             : */
      82           0 : NTSTATUS cluster_message_send(struct server_id server, DATA_BLOB *data)
      83             : {
      84           0 :         cluster_init();
      85           0 :         return ops->message_send(ops, server, data);
      86             : }

Generated by: LCOV version 1.14