1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

dbwrap_ctdb: Pass in ctdbd_connection

This removes one circular dependency of dbwrap_ctdb to messages.c: No call to
messaging_ctdbd_connection() anymore from dbwrap_ctdb.c.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Volker Lendecke 2016-04-11 16:20:32 +02:00 committed by Ralph Boehme
parent 0a367f5fd4
commit 3fe3226daa
5 changed files with 26 additions and 10 deletions

View File

@ -64,6 +64,7 @@ bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn, pid_t pid
}
struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
struct ctdbd_connection *conn,
const char *name,
int hash_size, int tdb_flags,
int open_flags, mode_t mode,

View File

@ -1578,6 +1578,7 @@ static size_t db_ctdb_id(struct db_context *db, uint8_t *id, size_t idlen)
}
struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
struct ctdbd_connection *conn,
const char *name,
int hash_size, int tdb_flags,
int open_flags, mode_t mode,
@ -1618,13 +1619,7 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
db_ctdb->transaction = NULL;
db_ctdb->db = result;
db_ctdb->conn = messaging_ctdbd_connection();
if (db_ctdb->conn == NULL) {
DEBUG(1, ("Could not connect to ctdb\n"));
TALLOC_FREE(result);
return NULL;
}
db_ctdb->conn = conn;
ret = ctdbd_db_attach(db_ctdb->conn, name, &db_ctdb->db_id, tdb_flags);
if (ret != 0) {

View File

@ -26,8 +26,10 @@
#include "dbwrap/dbwrap_private.h"
struct db_context;
struct ctdbd_connection;
struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
struct ctdbd_connection *conn,
const char *name,
int hash_size, int tdb_flags,
int open_flags, mode_t mode,

View File

@ -28,6 +28,7 @@
#include "lib/cluster_support.h"
#include "util_tdb.h"
#include "ctdbd_conn.h"
#include "messages.h"
bool db_is_local(const char *name)
{
@ -143,7 +144,16 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
}
/* allow ctdb for individual databases to be disabled */
if (lp_parm_bool(-1, "ctdb", partname, True)) {
result = db_open_ctdb(mem_ctx, partname, hash_size,
struct ctdbd_connection *conn;
conn = messaging_ctdbd_connection();
if (conn == NULL) {
DBG_WARNING("No ctdb connection\n");
errno = EIO;
return NULL;
}
result = db_open_ctdb(mem_ctx, conn, partname,
hash_size,
tdb_flags, open_flags, mode,
lock_order, dbwrap_flags);
if (result == NULL) {

View File

@ -22,16 +22,24 @@
#include "system/filesys.h"
#include "lib/dbwrap/dbwrap.h"
#include "lib/dbwrap/dbwrap_ctdb.h"
#include "messages.h"
bool run_local_dbwrap_ctdb(int dummy)
{
struct db_context *db;
struct db_context *db = NULL;
int res;
bool ret = false;
NTSTATUS status;
uint32_t val;
struct ctdbd_connection *conn;
db = db_open_ctdb(talloc_tos(), "torture.tdb", 0, TDB_DEFAULT,
conn = messaging_ctdbd_connection();
if (conn == NULL) {
fprintf(stderr, "no ctdbd connection\n");
goto fail;
}
db = db_open_ctdb(talloc_tos(), conn, "torture.tdb", 0, TDB_DEFAULT,
O_RDWR, 0755, DBWRAP_LOCK_ORDER_1, DBWRAP_FLAG_NONE);
if (db == NULL) {
perror("db_open_ctdb failed");