From b7b3e3e0d40f257942ec528cf069b3451caa699f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 8 Aug 2007 03:18:51 +0000 Subject: r24274: - merge from ctdb bzr tree - use ctdb_attach() instead of ctdb_db_handle() - make ctdb_attach() return an existing db handle if it exists (This used to be commit be85c48f8d4a22fd4ed922be6f7f1979f349d291) --- source4/cluster/ctdb/common/cmdline.c | 6 ++--- source4/cluster/ctdb/common/ctdb_util.c | 44 ++++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 14 deletions(-) (limited to 'source4/cluster/ctdb/common') diff --git a/source4/cluster/ctdb/common/cmdline.c b/source4/cluster/ctdb/common/cmdline.c index f8fca5e4a0..df01110e8a 100644 --- a/source4/cluster/ctdb/common/cmdline.c +++ b/source4/cluster/ctdb/common/cmdline.c @@ -102,20 +102,20 @@ struct ctdb_context *ctdb_cmdline_client(struct event_context *ev) /* initialise ctdb */ ctdb = ctdb_init(ev); if (ctdb == NULL) { - printf("Failed to init ctdb\n"); + fprintf(stderr, "Failed to init ctdb\n"); exit(1); } /* tell ctdb the socket address */ ret = ctdb_set_socketname(ctdb, ctdb_cmdline.socketname); if (ret == -1) { - printf("ctdb_set_socketname failed - %s\n", ctdb_errstr(ctdb)); + fprintf(stderr, "ctdb_set_socketname failed - %s\n", ctdb_errstr(ctdb)); exit(1); } ret = ctdb_socket_connect(ctdb); if (ret != 0) { - DEBUG(0,(__location__ " Failed to connect to daemon\n")); + fprintf(stderr, __location__ " Failed to connect to daemon\n"); talloc_free(ctdb); return NULL; } diff --git a/source4/cluster/ctdb/common/ctdb_util.c b/source4/cluster/ctdb/common/ctdb_util.c index f8f7cb5150..54b1e4e7ff 100644 --- a/source4/cluster/ctdb/common/ctdb_util.c +++ b/source4/cluster/ctdb/common/ctdb_util.c @@ -192,20 +192,42 @@ 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(bool enable) +void ctdb_set_scheduler(struct ctdb_context *ctdb) { -#if HAVE_SCHED_SETSCHEDULER +#if HAVE_SCHED_SETSCHEDULER struct sched_param p; - p.__sched_priority = 1; - - 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")); - } + if (ctdb->saved_scheduler_param == NULL) { + ctdb->saved_scheduler_param = talloc_size(ctdb, sizeof(p)); + } + + if (sched_getparam(0, (struct sched_param *)ctdb->saved_scheduler_param) == -1) { + DEBUG(0,("Unable to get old scheduler params\n")); + return; + } + + p = *(struct sched_param *)ctdb->saved_scheduler_param; + p.sched_priority = 1; + + if (sched_setscheduler(0, SCHED_FIFO, &p) == -1) { + DEBUG(0,("Unable to set scheduler to SCHED_FIFO (%s)\n", + strerror(errno))); } else { - sched_setscheduler(getpid(), SCHED_OTHER, &p); + DEBUG(0,("Set scheduler to SCHED_FIFO\n")); + } +#endif +} + +/* + restore previous scheduler parameters + */ +void ctdb_restore_scheduler(struct ctdb_context *ctdb) +{ +#if HAVE_SCHED_SETSCHEDULER + if (ctdb->saved_scheduler_param == NULL) { + ctdb_fatal(ctdb, "No saved scheduler parameters\n"); + } + if (sched_setscheduler(0, SCHED_OTHER, (struct sched_param *)ctdb->saved_scheduler_param) == -1) { + ctdb_fatal(ctdb, "Unable to restore old scheduler parameters\n"); } #endif } -- cgit