diff options
-rw-r--r-- | ctdb/common/system_util.c | 11 | ||||
-rw-r--r-- | ctdb/include/ctdb_private.h | 2 | ||||
-rw-r--r-- | ctdb/server/ctdb_daemon.c | 5 | ||||
-rw-r--r-- | ctdb/server/ctdb_lock_helper.c | 5 |
4 files changed, 16 insertions, 7 deletions
diff --git a/ctdb/common/system_util.c b/ctdb/common/system_util.c index 692bc25623..8e8f4ac217 100644 --- a/ctdb/common/system_util.c +++ b/ctdb/common/system_util.c @@ -37,7 +37,7 @@ /* if possible, make this task real time */ -void set_scheduler(void) +bool set_scheduler(void) { #ifdef _AIX_ #if HAVE_THREAD_SETSCHED @@ -47,14 +47,15 @@ void set_scheduler(void) ti = 0ULL; if (getthrds64(getpid(), &te, sizeof(te), &ti, 1) != 1) { DEBUG(DEBUG_ERR, ("Unable to get thread information\n")); - return; + return false; } if (thread_setsched(te.ti_tid, 0, SCHED_RR) == -1) { DEBUG(DEBUG_ERR, ("Unable to set scheduler to SCHED_RR (%s)\n", strerror(errno))); + return false; } else { - DEBUG(DEBUG_NOTICE, ("Set scheduler to SCHED_RR\n")); + return true; } #endif #else /* no AIX */ @@ -70,11 +71,13 @@ void set_scheduler(void) if (sched_setscheduler(0, policy, &p) == -1) { DEBUG(DEBUG_CRIT,("Unable to set scheduler to SCHED_FIFO (%s)\n", strerror(errno))); + return false; } else { - DEBUG(DEBUG_NOTICE,("Set scheduler to SCHED_FIFO\n")); + return true; } #endif #endif + return false; } /* diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 285e13cdf8..43daf360b1 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -1090,7 +1090,7 @@ void ctdb_call_resend_all(struct ctdb_context *ctdb); void ctdb_node_dead(struct ctdb_node *node); void ctdb_node_connected(struct ctdb_node *node); bool ctdb_blocking_freeze(struct ctdb_context *ctdb); -void set_scheduler(void); +bool set_scheduler(void); void reset_scheduler(void); struct tevent_signal *ctdb_init_sigchld(struct ctdb_context *ctdb); diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c index 4ae56a9eb7..46a134c60d 100644 --- a/ctdb/server/ctdb_daemon.c +++ b/ctdb/server/ctdb_daemon.c @@ -1183,7 +1183,10 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog) if (ctdb->do_setsched) { /* try to set us up as realtime */ - set_scheduler(); + if (!set_scheduler()) { + exit(1); + } + DEBUG(DEBUG_NOTICE, ("Set real-time scheduler priority\n")); } /* ensure the socket is deleted on exit of the daemon */ diff --git a/ctdb/server/ctdb_lock_helper.c b/ctdb/server/ctdb_lock_helper.c index 3de07768ae..49c317e30f 100644 --- a/ctdb/server/ctdb_lock_helper.c +++ b/ctdb/server/ctdb_lock_helper.c @@ -123,7 +123,10 @@ int main(int argc, char *argv[]) exit(1); } - set_scheduler(); + if (!set_scheduler()) { + fprintf(stderr, "%s: Unable to set real-time scheduler priority\n", + progname); + } log_fd = atoi(argv[1]); close(STDOUT_FILENO); |