2009-10-25 18:12:12 +03:00
/*
Unix SMB / CIFS implementation .
2010-03-12 14:08:19 +03:00
global locks based on dbwrap and messaging
2009-10-25 18:12:12 +03:00
Copyright ( C ) 2009 by Volker Lendecke
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 3 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
# ifndef _G_LOCK_H_
# define _G_LOCK_H_
2020-11-11 18:52:07 +03:00
# include "replace.h"
# include "librpc/gen_ndr/server_id.h"
2011-07-07 19:42:08 +04:00
# include "dbwrap/dbwrap.h"
2009-10-25 18:12:12 +03:00
struct g_lock_ctx ;
2022-08-28 12:41:46 +03:00
struct g_lock_lock_cb_state ;
2013-09-02 11:24:42 +04:00
struct messaging_context ;
2009-10-25 18:12:12 +03:00
enum g_lock_type {
2019-11-19 19:29:18 +03:00
G_LOCK_READ ,
G_LOCK_WRITE ,
G_LOCK_UPGRADE ,
G_LOCK_DOWNGRADE ,
2009-10-25 18:12:12 +03:00
} ;
2019-11-05 18:36:44 +03:00
struct g_lock_ctx * g_lock_ctx_init_backend (
TALLOC_CTX * mem_ctx ,
struct messaging_context * msg ,
struct db_context * * backend ) ;
2019-11-21 17:20:07 +03:00
void g_lock_set_lock_order ( struct g_lock_ctx * ctx ,
enum dbwrap_lock_order lock_order ) ;
2009-10-25 18:12:12 +03:00
struct g_lock_ctx * g_lock_ctx_init ( TALLOC_CTX * mem_ctx ,
struct messaging_context * msg ) ;
2022-08-28 12:41:46 +03:00
typedef void ( * g_lock_lock_cb_fn_t ) ( struct g_lock_lock_cb_state * glck ,
void * cb_private ) ;
NTSTATUS g_lock_lock_cb_dump ( struct g_lock_lock_cb_state * glck ,
void ( * fn ) ( struct server_id exclusive ,
size_t num_shared ,
const struct server_id * shared ,
const uint8_t * data ,
size_t datalen ,
void * private_data ) ,
void * private_data ) ;
NTSTATUS g_lock_lock_cb_writev ( struct g_lock_lock_cb_state * glck ,
const TDB_DATA * dbufs ,
size_t num_dbufs ) ;
void g_lock_lock_cb_unlock ( struct g_lock_lock_cb_state * glck ) ;
struct tevent_req * g_lock_lock_cb_watch_data_send (
TALLOC_CTX * mem_ctx ,
struct tevent_context * ev ,
struct g_lock_lock_cb_state * cb_state ,
struct server_id blocker ) ;
NTSTATUS g_lock_lock_cb_watch_data_recv (
struct tevent_req * req ,
bool * blockerdead ,
struct server_id * blocker ) ;
void g_lock_lock_cb_wake_watchers ( struct g_lock_lock_cb_state * cb_state ) ;
2012-05-03 20:30:38 +04:00
struct tevent_req * g_lock_lock_send ( TALLOC_CTX * mem_ctx ,
struct tevent_context * ev ,
struct g_lock_ctx * ctx ,
2017-12-03 22:47:02 +03:00
TDB_DATA key ,
2022-08-28 13:38:24 +03:00
enum g_lock_type type ,
g_lock_lock_cb_fn_t cb_fn ,
void * cb_private ) ;
2012-05-03 20:30:38 +04:00
NTSTATUS g_lock_lock_recv ( struct tevent_req * req ) ;
2017-12-03 22:47:02 +03:00
NTSTATUS g_lock_lock ( struct g_lock_ctx * ctx , TDB_DATA key ,
2022-08-28 14:08:48 +03:00
enum g_lock_type lock_type , struct timeval timeout ,
g_lock_lock_cb_fn_t cb_fn ,
void * cb_private ) ;
2017-12-03 22:47:02 +03:00
NTSTATUS g_lock_unlock ( struct g_lock_ctx * ctx , TDB_DATA key ) ;
2009-10-25 18:12:12 +03:00
2020-04-29 16:35:39 +03:00
NTSTATUS g_lock_writev_data (
struct g_lock_ctx * ctx ,
TDB_DATA key ,
const TDB_DATA * dbufs ,
size_t num_dbufs ) ;
2017-12-03 22:47:02 +03:00
NTSTATUS g_lock_write_data ( struct g_lock_ctx * ctx , TDB_DATA key ,
2017-05-23 13:32:24 +03:00
const uint8_t * buf , size_t buflen ) ;
2009-10-25 18:12:12 +03:00
int g_lock_locks ( struct g_lock_ctx * ctx ,
2017-12-03 22:47:02 +03:00
int ( * fn ) ( TDB_DATA key , void * private_data ) ,
2009-10-25 18:12:12 +03:00
void * private_data ) ;
2020-03-24 11:54:26 +03:00
struct tevent_req * g_lock_dump_send (
TALLOC_CTX * mem_ctx ,
struct tevent_context * ev ,
struct g_lock_ctx * ctx ,
TDB_DATA key ,
void ( * fn ) ( struct server_id exclusive ,
size_t num_shared ,
2022-08-18 18:52:33 +03:00
const struct server_id * shared ,
2020-03-24 11:54:26 +03:00
const uint8_t * data ,
size_t datalen ,
void * private_data ) ,
void * private_data ) ;
NTSTATUS g_lock_dump_recv ( struct tevent_req * req ) ;
2019-11-19 19:29:18 +03:00
NTSTATUS g_lock_dump ( struct g_lock_ctx * ctx ,
TDB_DATA key ,
2019-10-25 14:35:39 +03:00
void ( * fn ) ( struct server_id exclusive ,
size_t num_shared ,
2022-08-18 18:52:33 +03:00
const struct server_id * shared ,
2017-05-18 16:27:46 +03:00
const uint8_t * data ,
size_t datalen ,
void * private_data ) ,
2009-10-25 18:12:12 +03:00
void * private_data ) ;
2019-11-05 18:36:59 +03:00
int g_lock_seqnum ( struct g_lock_ctx * ctx ) ;
2009-10-25 18:12:12 +03:00
2019-10-30 18:12:11 +03:00
struct tevent_req * g_lock_watch_data_send (
TALLOC_CTX * mem_ctx ,
struct tevent_context * ev ,
struct g_lock_ctx * ctx ,
TDB_DATA key ,
struct server_id blocker ) ;
NTSTATUS g_lock_watch_data_recv (
struct tevent_req * req ,
bool * blockerdead ,
struct server_id * blocker ) ;
2019-11-04 18:03:52 +03:00
void g_lock_wake_watchers ( struct g_lock_ctx * ctx , TDB_DATA key ) ;
2019-10-30 18:12:11 +03:00
2009-10-25 18:12:12 +03:00
# endif