From: Andrew Tridgell Date: Fri, 1 Jun 2007 22:46:49 +0000 (+1000) Subject: disable realtime scheduler in event scripts X-Git-Tag: tevent-0.9.20~348^2~2604 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=27b0e323e64444d2f3ac55a108f196373939add4;p=thirdparty%2Fsamba.git disable realtime scheduler in event scripts (This used to be ctdb commit 56225ac6fdfe754289bc7d5e0fc8d21c81a7aa8e) --- diff --git a/ctdb/common/ctdb_daemon.c b/ctdb/common/ctdb_daemon.c index 3309d375e48..ecd095f115f 100644 --- a/ctdb/common/ctdb_daemon.c +++ b/ctdb/common/ctdb_daemon.c @@ -766,7 +766,7 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork) block_signal(SIGPIPE); /* try to set us up as realtime */ - ctdb_set_realtime(); + ctdb_set_realtime(true); /* ensure the socket is deleted on exit of the daemon */ domain_socket_name = talloc_strdup(talloc_autofree_context(), ctdb->daemon.name); diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c index ad00428c02c..3fbf9882e1c 100644 --- a/ctdb/common/ctdb_util.c +++ b/ctdb/common/ctdb_util.c @@ -204,16 +204,20 @@ struct ctdb_rec_data *ctdb_marshall_record(TALLOC_CTX *mem_ctx, uint32_t reqid, /* if possible, make this task real time */ -void ctdb_set_realtime(void) +void ctdb_set_realtime(bool enable) { #if HAVE_SCHED_SETSCHEDULER struct sched_param p; p.__sched_priority = 1; - if (sched_setscheduler(getpid(), SCHED_FIFO, &p) == -1) { - DEBUG(0,("Unable to set scheduler to SCHED_FIFO (%s)\n", strerror(errno))); + if (enable) { + if (sched_setscheduler(getpid(), SCHED_FIFO, &p) == -1) { + DEBUG(0,("Unable to set scheduler to SCHED_FIFO (%s)\n", strerror(errno))); + } else { + DEBUG(0,("Set scheduler to SCHED_FIFO\n")); + } } else { - DEBUG(0,("Set scheduler to SCHED_FIFO\n")); + sched_setscheduler(getpid(), SCHED_OTHER, &p); } #endif } diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 5bc9a60fd64..d366c5071d8 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -928,7 +928,7 @@ int ctdb_ctrl_set_rsn_nonempty(struct ctdb_context *ctdb, struct timeval timeout uint32_t destnode, uint32_t db_id, uint64_t rsn); int ctdb_ctrl_delete_low_rsn(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t db_id, uint64_t rsn); -void ctdb_set_realtime(void); +void ctdb_set_realtime(bool enable); int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA indata, diff --git a/ctdb/takeover/system.c b/ctdb/takeover/system.c index 95c790fc1a0..a628f5b2956 100644 --- a/ctdb/takeover/system.c +++ b/ctdb/takeover/system.c @@ -385,6 +385,7 @@ int ctdb_event_script_callback(struct ctdb_context *ctdb, if (state->child == 0) { close(state->fd[0]); + ctdb_set_realtime(false); va_start(ap, fmt); ret = ctdb_event_script_v(ctdb, fmt, ap); va_end(ap);