mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
ctdb-locking: Pass additional arguments to debug locks script
1. PID of lock helper waiting for lock 2. Scope of lock: "record" or "db" 3. Path to database that lock helper is trying to lock 4. Whether the database uses mutexes: "mutex" or "fcntl" Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
2c7dbb043f
commit
d07875330a
@ -496,6 +496,50 @@ fail:
|
||||
|
||||
}
|
||||
|
||||
static const char **debug_locks_args(TALLOC_CTX *mem_ctx, struct lock_context *lock_ctx)
|
||||
{
|
||||
const char **args = NULL;
|
||||
int tdb_flags;
|
||||
int nargs, i;
|
||||
|
||||
/* Program, lock helper PID, db|record, tdb path, fcntl|mutex, NULL */
|
||||
nargs = 6;
|
||||
|
||||
args = talloc_array(mem_ctx, const char *, nargs);
|
||||
if (args == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
args[0] = talloc_strdup(args, "debug_locks");
|
||||
args[1] = talloc_asprintf(args, "%d", lock_ctx->child);
|
||||
|
||||
if (lock_ctx->type == LOCK_RECORD) {
|
||||
args[2] = talloc_strdup(args, "RECORD");
|
||||
} else {
|
||||
args[2] = talloc_strdup(args, "DB");
|
||||
}
|
||||
|
||||
args[3] = talloc_strdup(args, lock_ctx->ctdb_db->db_path);
|
||||
|
||||
tdb_flags = tdb_get_flags(lock_ctx->ctdb_db->ltdb->tdb);
|
||||
if (tdb_flags & TDB_MUTEX_LOCKING) {
|
||||
args[4] = talloc_strdup(args, "MUTEX");
|
||||
} else {
|
||||
args[4] = talloc_strdup(args, "FCNTL");
|
||||
}
|
||||
|
||||
args[5] = NULL;
|
||||
|
||||
for (i=0; i<nargs-1; i++) {
|
||||
if (args[i] == NULL) {
|
||||
talloc_free(args);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback routine when required locks are not obtained within timeout
|
||||
* Called from parent context
|
||||
@ -512,6 +556,7 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
|
||||
double elapsed_time;
|
||||
bool skip;
|
||||
char *keystr;
|
||||
const char **args;
|
||||
|
||||
lock_ctx = talloc_get_type_abort(private_data, struct lock_context);
|
||||
ctdb = lock_ctx->ctdb;
|
||||
@ -554,12 +599,18 @@ lock_debug:
|
||||
debug_locks, sizeof(debug_locks),
|
||||
"CTDB_DEBUG_LOCKS",
|
||||
getenv("CTDB_BASE"), "debug_locks.sh")) {
|
||||
pid = vfork();
|
||||
if (pid == 0) {
|
||||
execl(debug_locks, debug_locks, NULL);
|
||||
_exit(0);
|
||||
args = debug_locks_args(lock_ctx, lock_ctx);
|
||||
if (args != NULL) {
|
||||
pid = vfork();
|
||||
if (pid == 0) {
|
||||
execvp(debug_locks, discard_const(args));
|
||||
_exit(0);
|
||||
}
|
||||
talloc_free(args);
|
||||
ctdb_track_child(ctdb, pid);
|
||||
} else {
|
||||
D_WARNING("No memory for debug locks args\n");
|
||||
}
|
||||
ctdb_track_child(ctdb, pid);
|
||||
} else {
|
||||
DEBUG(DEBUG_WARNING,
|
||||
(__location__
|
||||
|
Loading…
Reference in New Issue
Block a user