source: vendor/current/ctdb/common/srvid.h

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 3.7 KB
Line 
1/*
2 Message handler database based on srvid
3
4 Copyright (C) Amitay Isaacs 2015
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#ifndef __CTDB_SRVID_H__
21#define __CTDB_SRVID_H__
22
23#include <talloc.h>
24#include <tdb.h>
25
26/**
27 * @file srvid.h
28 *
29 * @brief Database of message handlers based on srvid
30 *
31 * CTDB can be used to send messages between clients across nodes using
32 * CTDB_REQ_MESSAGE. Clients register for mesages based on srvid. CTDB itself
33 * uses a small set of srvid messages. A large range (2^56) of srvid messages
34 * is reserved for Samba.
35 */
36
37/**
38 * @brief Message handler function
39 *
40 * To receive messages for a specific srvid, register a message handler function
41 * for the srvid.
42 */
43typedef void (*srvid_handler_fn)(uint64_t srvid, TDB_DATA data,
44 void *private_data);
45
46/**
47 * @brief Abstract struct to store srvid message handler database
48 */
49struct srvid_context;
50
51/**
52 * @brief Initialize srvid message handler database
53 *
54 * This returns a new srvid message handler database context. Freeing
55 * this context will free all the memory associated with the hash table.
56 *
57 * @param[in] mem_ctx Talloc memory context
58 * @param[out] result The new db_hash_context structure
59 * @return 0 on success, errno on failure
60 */
61int srvid_init(TALLOC_CTX *mem_ctx, struct srvid_context **result);
62
63/**
64 * @brief Register a message handler for a srvid
65 *
66 * The message handler is allocated using the specified talloc context. Freeing
67 * this talloc context, removes the message handler.
68 *
69 * @param[in] srv The srvid message handler database context
70 * @param[in] mem_ctx Talloc memory context for message handler
71 * @param[in] srvid The srvid
72 * @param[in] handler The message handler function for srvid
73 * @param[in] private_data Private data for message handler function
74 * @return 0 on success, errno on failure
75 */
76int srvid_register(struct srvid_context *srv, TALLOC_CTX *mem_ctx,
77 uint64_t srvid, srvid_handler_fn handler,
78 void *private_data);
79
80/**
81 * @brief Unregister a message handler for a srvid
82 *
83 * @param[in] srv The srvid message handler database context
84 * @param[in] srvid The srvid
85 * @param[in] private_data Private data of message handler function
86 * @return 0 on success, errno on failure
87 */
88int srvid_deregister(struct srvid_context *srv, uint64_t srvid,
89 void *private_data);
90
91/**
92 * @brief Check if any message handler is registered for srvid
93 *
94 * @param[in] srv The srvid message handler database context
95 * @param[in] srvid The srvid
96 * @return 0 on success, errno on failure
97 */
98int srvid_exists(struct srvid_context *srv, uint64_t srvid);
99
100/**
101 * @brief Call message handlers for given srvid
102 *
103 * @param[in] srv The srvid message handler database context
104 * @param[in] srvid The srvid
105 * @param[in] srvid_all The srvid that gets all messages
106 * @param[in] data The data passed to each message handler
107 * @return 0 on success, errno on failure
108 *
109 * If srvid_all passed is 0, the message is not sent to message handlers
110 * registered with special srvid to receive all messages.
111 */
112int srvid_dispatch(struct srvid_context *srv, uint64_t srvid,
113 uint64_t srvid_all, TDB_DATA data);
114
115#endif /* __CTDB_SRVID_H__ */
Note: See TracBrowser for help on using the repository browser.