source: vendor/current/ctdb/common/reqid.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: 2.6 KB
Line 
1/*
2 Request id database
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_REQID_H__
21#define __CTDB_REQID_H__
22
23#include <talloc.h>
24
25/**
26 * @file reqid.h
27 *
28 * @brief Request id database
29 *
30 * CTDB tracks messsages using request id. CTDB stores client state for each
31 * request id to process the replies correctly.
32 */
33
34/**
35 * @brief Abstract struct to store request id database
36 */
37struct reqid_context;
38
39#define REQID_INVALID 0xffffffff
40
41/**
42 * @brief Initialize request id database
43 *
44 * This returns a new request id context. Freeing this context will free
45 * all the memory associated with request id database.
46 *
47 * @param[in] mem_ctx Talloc memory context
48 * @param[in] start_id The initial id
49 * @param[out] result The new talloc_context structure
50 * @return 0 on success, errno on failure
51 */
52int reqid_init(TALLOC_CTX *mem_ctx, int start_id,
53 struct reqid_context **result);
54
55/**
56 * @brief Generate new request id and associate given data with the request id
57 *
58 * @param[in] reqid_ctx The request id context
59 * @param[in] private_data The state to associate with new request id
60 * @return new request id, REQID_INVALID on failure
61 */
62uint32_t reqid_new(struct reqid_context *reqid_ctx, void *private_data);
63
64#ifdef DOXYGEN
65/**
66 * @brief Fetch the data associated with the request id
67 *
68 * @param[in] reqid_ctx The request id context
69 * @param[in] reqid The request id
70 * @param[in] type The data type of the stored data
71 * @return the data stored for the reqid, NULL on failure
72 */
73type *reqid_find(struct reqid_context *reqid_ctx, uint32_t reqid, #type);
74#else
75void *_reqid_find(struct reqid_context *reqid_ctx, uint32_t reqid);
76#define reqid_find(ctx, reqid, type) \
77 (type *)talloc_check_name(_reqid_find(ctx, reqid), #type)
78#endif
79
80/**
81 * @brief Remove the data associated with the request id
82 *
83 * @param[in] reqid_ctx The request id context
84 * @param[in] reqid The request id
85 * @return 0 on success, errno on failure
86 */
87int reqid_remove(struct reqid_context *reqid_ctx, uint32_t reqid);
88
89#endif /* __CTDB_REQID_H__ */
Note: See TracBrowser for help on using the repository browser.