1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

lib: Make g_lock_unlock use TDB_DATA

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Volker Lendecke 2017-12-03 20:47:02 +01:00 committed by Ralph Boehme
parent bdeb7e7d81
commit a104e08171
7 changed files with 23 additions and 18 deletions

View File

@ -93,7 +93,7 @@ static int netlogon_creds_cli_locked_state_destructor(
if (state->is_glocked) {
g_lock_unlock(context->db.g_ctx,
context->db.key_name);
string_term_tdb_data(context->db.key_name));
}
return 0;
@ -1014,7 +1014,8 @@ static int netlogon_creds_cli_lck_destructor(
struct netlogon_creds_cli_context *ctx = lck->context;
NTSTATUS status;
status = g_lock_unlock(ctx->db.g_ctx, ctx->db.key_name);
status = g_lock_unlock(ctx->db.g_ctx,
string_term_tdb_data(ctx->db.key_name));
if (!NT_STATUS_IS_OK(status)) {
DBG_WARNING("g_lock_unlock failed: %s\n", nt_errstr(status));
smb_panic("g_lock_unlock failed");

View File

@ -46,7 +46,7 @@ struct tevent_req *g_lock_lock_send(TALLOC_CTX *mem_ctx,
NTSTATUS g_lock_lock_recv(struct tevent_req *req);
NTSTATUS g_lock_lock(struct g_lock_ctx *ctx, TDB_DATA key,
enum g_lock_type lock_type, struct timeval timeout);
NTSTATUS g_lock_unlock(struct g_lock_ctx *ctx, const char *name);
NTSTATUS g_lock_unlock(struct g_lock_ctx *ctx, TDB_DATA key);
NTSTATUS g_lock_write_data(struct g_lock_ctx *ctx, const char *name,
const uint8_t *buf, size_t buflen);

View File

@ -328,7 +328,8 @@ static int db_ctdb_transaction_destructor(struct db_ctdb_transaction_handle *h)
{
NTSTATUS status;
status = g_lock_unlock(h->ctx->lock_ctx, h->lock_name);
status = g_lock_unlock(h->ctx->lock_ctx,
string_term_tdb_data(h->lock_name));
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("g_lock_unlock failed for %s: %s\n", h->lock_name,
nt_errstr(status)));

View File

@ -483,7 +483,7 @@ NTSTATUS g_lock_lock(struct g_lock_ctx *ctx, TDB_DATA key,
}
struct g_lock_unlock_state {
const char *name;
TDB_DATA key;
struct server_id self;
NTSTATUS status;
};
@ -501,7 +501,10 @@ static void g_lock_unlock_fn(struct db_record *rec,
ok = g_lock_parse(value.dptr, value.dsize, &lck);
if (!ok) {
DBG_DEBUG("g_lock_get for %s failed\n", state->name);
DBG_DEBUG("g_lock_get for %s failed\n",
hex_encode_talloc(talloc_tos(),
state->key.dptr,
state->key.dsize));
state->status = NT_STATUS_FILE_INVALID;
return;
}
@ -527,15 +530,14 @@ static void g_lock_unlock_fn(struct db_record *rec,
state->status = g_lock_store(rec, &lck, NULL);
}
NTSTATUS g_lock_unlock(struct g_lock_ctx *ctx, const char *name)
NTSTATUS g_lock_unlock(struct g_lock_ctx *ctx, TDB_DATA key)
{
struct g_lock_unlock_state state = {
.self = messaging_server_id(ctx->msg), .name = name
.self = messaging_server_id(ctx->msg), .key = key
};
NTSTATUS status;
status = dbwrap_do_locked(ctx->db, string_term_tdb_data(name),
g_lock_unlock_fn, &state);
status = dbwrap_do_locked(ctx->db, key, g_lock_unlock_fn, &state);
if (!NT_STATUS_IS_OK(status)) {
DBG_WARNING("dbwrap_do_locked failed: %s\n",
nt_errstr(status));
@ -788,7 +790,7 @@ NTSTATUS g_lock_do(const char *name, enum g_lock_type lock_type,
goto done;
}
fn(private_data);
g_lock_unlock(g_ctx, name);
g_lock_unlock(g_ctx, string_term_tdb_data(name));
done:
TALLOC_FREE(g_ctx);

View File

@ -45,7 +45,8 @@ struct trust_pw_change_state {
static int trust_pw_change_state_destructor(struct trust_pw_change_state *state)
{
g_lock_unlock(state->g_ctx, state->g_lock_key);
g_lock_unlock(state->g_ctx,
string_term_tdb_data(state->g_lock_key));
return 0;
}

View File

@ -1495,7 +1495,7 @@ static NTSTATUS smbd_claim_version(struct messaging_context *msg,
if (!NT_STATUS_IS_OK(status) &&
!NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
DBG_ERR("Could not read samba_version_string\n");
g_lock_unlock(ctx, name);
g_lock_unlock(ctx, string_term_tdb_data(name));
TALLOC_FREE(ctx);
return status;
}

View File

@ -84,14 +84,14 @@ bool run_g_lock1(int dummy)
goto fail;
}
status = g_lock_unlock(ctx, lockname);
status = g_lock_unlock(ctx, string_term_tdb_data(lockname));
if (!NT_STATUS_IS_OK(status)) {
fprintf(stderr, "g_lock_unlock failed: %s\n",
nt_errstr(status));
goto fail;
}
status = g_lock_unlock(ctx, lockname);
status = g_lock_unlock(ctx, string_term_tdb_data(lockname));
if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
fprintf(stderr, "g_lock_unlock returned: %s\n",
nt_errstr(status));
@ -170,7 +170,7 @@ bool run_g_lock2(int dummy)
goto fail;
}
status = g_lock_unlock(ctx, lockname);
status = g_lock_unlock(ctx, string_term_tdb_data(lockname));
if (!NT_STATUS_IS_OK(status)) {
fprintf(stderr, "g_lock_unlock failed: %s\n",
nt_errstr(status));
@ -688,7 +688,7 @@ bool run_g_lock5(int dummy)
nt_errstr(status));
return false;
}
status = g_lock_unlock(ctx, lockname);
status = g_lock_unlock(ctx, string_term_tdb_data(lockname));
if (!NT_STATUS_IS_OK(status)) {
fprintf(stderr, "g_lock_unlock failed %s\n",
nt_errstr(status));
@ -922,7 +922,7 @@ bool run_g_lock_ping_pong(int dummy)
name[10] = '0' + ((i) % torture_nprocs);
status = g_lock_unlock(ctx, name);
status = g_lock_unlock(ctx, string_term_tdb_data(name));
if (!NT_STATUS_IS_OK(status)) {
fprintf(stderr, "g_lock_unlock failed: %s\n",
nt_errstr(status));