diff options
author | Amitay Isaacs <amitay@gmail.com> | 2016-06-17 18:33:27 +1000 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2016-06-20 16:21:19 +0200 |
commit | a21a4de2cb13d4f762c7c1192d05edf785091910 (patch) | |
tree | e1262c73206a0c802f392b010b94fa2e3787c440 /ctdb/server | |
parent | 2828b9a8c6c067fe5cb9c5c56f2dd20f715682a5 (diff) | |
download | samba-a21a4de2cb13d4f762c7c1192d05edf785091910.tar.gz |
ctdb-locking: Conditionally set real-time priority in lock helper
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'ctdb/server')
-rw-r--r-- | ctdb/server/ctdb_lock_helper.c | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/ctdb/server/ctdb_lock_helper.c b/ctdb/server/ctdb_lock_helper.c index cdcbb4ac635..e41d2307919 100644 --- a/ctdb/server/ctdb_lock_helper.c +++ b/ctdb/server/ctdb_lock_helper.c @@ -28,6 +28,35 @@ #include "common/system.h" static char *progname = NULL; +static bool realtime = true; + +static void set_priority(void) +{ + const char *ptr; + + ptr = getenv("CTDB_NOSETSCHED"); + if (ptr != NULL) { + realtime = false; + } + + if (! realtime) { + return; + } + + realtime = set_scheduler(); + if (! realtime) { + fprintf(stderr, + "%s: Unable to set real-time scheduler priority\n", + progname); + } +} + +static void reset_priority(void) +{ + if (realtime) { + reset_scheduler(); + } +} static void send_result(int fd, char result) { @@ -69,7 +98,6 @@ static int lock_record(const char *dbpath, const char *dbflags, const char *dbke TDB_DATA key; struct tdb_context *tdb; int tdb_flags; - bool realtime; /* No error checking since CTDB always passes sane values */ tdb_flags = strtol(dbflags, NULL, 0); @@ -88,11 +116,7 @@ static int lock_record(const char *dbpath, const char *dbflags, const char *dbke return 1; } - realtime = set_scheduler(); - if (! realtime) { - fprintf(stderr, "%s: Unable to set real-time scheduler priority\n", - progname); - } + set_priority(); if (tdb_chainlock(tdb, key) < 0) { fprintf(stderr, "%s: Error getting record lock (%s)\n", @@ -100,9 +124,7 @@ static int lock_record(const char *dbpath, const char *dbflags, const char *dbke return 1; } - if (realtime) { - reset_scheduler(); - } + reset_priority(); return 0; @@ -113,7 +135,6 @@ static int lock_db(const char *dbpath, const char *dbflags) { struct tdb_context *tdb; int tdb_flags; - bool realtime; /* No error checking since CTDB always passes sane values */ tdb_flags = strtol(dbflags, NULL, 0); @@ -124,11 +145,7 @@ static int lock_db(const char *dbpath, const char *dbflags) return 1; } - realtime = set_scheduler(); - if (! realtime) { - fprintf(stderr, "%s: Unable to set real-time scheduler priority\n", - progname); - } + set_priority(); if (tdb_lockall(tdb) < 0) { fprintf(stderr, "%s: Error getting db lock (%s)\n", @@ -136,9 +153,7 @@ static int lock_db(const char *dbpath, const char *dbflags) return 1; } - if (realtime) { - reset_scheduler(); - } + reset_priority(); return 0; } |