docs: fix a typo in history file
[bbaumbach/samba-autobuild/.git] / source3 / include / g_lock.h
1 /*
2    Unix SMB/CIFS implementation.
3    global locks based on dbwrap and messaging
4    Copyright (C) 2009 by Volker Lendecke
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 _G_LOCK_H_
21 #define _G_LOCK_H_
22
23 #include "dbwrap/dbwrap.h"
24
25 struct g_lock_ctx;
26 struct messaging_context;
27
28 enum g_lock_type {
29         G_LOCK_READ,
30         G_LOCK_WRITE,
31         G_LOCK_UPGRADE,
32         G_LOCK_DOWNGRADE,
33 };
34
35 struct g_lock_ctx *g_lock_ctx_init_backend(
36         TALLOC_CTX *mem_ctx,
37         struct messaging_context *msg,
38         struct db_context **backend);
39 void g_lock_set_lock_order(struct g_lock_ctx *ctx,
40                            enum dbwrap_lock_order lock_order);
41 struct g_lock_ctx *g_lock_ctx_init(TALLOC_CTX *mem_ctx,
42                                    struct messaging_context *msg);
43
44 struct tevent_req *g_lock_lock_send(TALLOC_CTX *mem_ctx,
45                                     struct tevent_context *ev,
46                                     struct g_lock_ctx *ctx,
47                                     TDB_DATA key,
48                                     enum g_lock_type type);
49 NTSTATUS g_lock_lock_recv(struct tevent_req *req);
50 NTSTATUS g_lock_lock(struct g_lock_ctx *ctx, TDB_DATA key,
51                      enum g_lock_type lock_type, struct timeval timeout);
52 NTSTATUS g_lock_unlock(struct g_lock_ctx *ctx, TDB_DATA key);
53
54 NTSTATUS g_lock_writev_data(
55         struct g_lock_ctx *ctx,
56         TDB_DATA key,
57         const TDB_DATA *dbufs,
58         size_t num_dbufs);
59 NTSTATUS g_lock_write_data(struct g_lock_ctx *ctx, TDB_DATA key,
60                            const uint8_t *buf, size_t buflen);
61
62 int g_lock_locks(struct g_lock_ctx *ctx,
63                  int (*fn)(TDB_DATA key, void *private_data),
64                  void *private_data);
65 struct tevent_req *g_lock_dump_send(
66         TALLOC_CTX *mem_ctx,
67         struct tevent_context *ev,
68         struct g_lock_ctx *ctx,
69         TDB_DATA key,
70         void (*fn)(struct server_id exclusive,
71                    size_t num_shared,
72                    struct server_id *shared,
73                    const uint8_t *data,
74                    size_t datalen,
75                    void *private_data),
76         void *private_data);
77 NTSTATUS g_lock_dump_recv(struct tevent_req *req);
78 NTSTATUS g_lock_dump(struct g_lock_ctx *ctx,
79                      TDB_DATA key,
80                      void (*fn)(struct server_id exclusive,
81                                 size_t num_shared,
82                                 struct server_id *shared,
83                                 const uint8_t *data,
84                                 size_t datalen,
85                                 void *private_data),
86                      void *private_data);
87 int g_lock_seqnum(struct g_lock_ctx *ctx);
88
89 struct tevent_req *g_lock_watch_data_send(
90         TALLOC_CTX *mem_ctx,
91         struct tevent_context *ev,
92         struct g_lock_ctx *ctx,
93         TDB_DATA key,
94         struct server_id blocker);
95 NTSTATUS g_lock_watch_data_recv(
96         struct tevent_req *req,
97         bool *blockerdead,
98         struct server_id *blocker);
99 void g_lock_wake_watchers(struct g_lock_ctx *ctx, TDB_DATA key);
100
101 #endif