[SCM] Samba Shared Repository - branch master updated
Martin Schwenke
martins at samba.org
Thu Jun 12 00:11:03 MDT 2014
The branch, master has been updated
via 9e6e487 ctdb-daemon: Reset scheduler policy for helper processes
via e9eed41 ctdb-daemon: Do not complain if node is inactive and db is not attached
via 79a6bd2 ctdb-build: Remove duplicate library dependency
via 71ed758 ctdb-daemon: Remove duplicate code from helper binaries
via e7c7258 ctdb-logging: Move controls handling functions from common to server
via 27d1137 ctdb-logging: Split ringbuffer handling code from ctdb_collect_log
via 49e3465 ctdb-common: Move mkdir_p_or_die to system utilities
via 4736486 ctdb-daemon: Rename ctdb_mkdir_p_or_die to mkdir_p_or_die
via 507207e ctdb-common: Move lockdown_memory to system utilities
via 8c8ef56 ctdb-daemon: Rename ctdb_lockdown_memory to lockdown_memory
via 22f7157 ctdb-daemon: Instead of passing ctdb context, pass valgrinding boolean
via e114830 ctdb-common: Keep debug level related functions with logging code
via d09f813 ctdb-daemon: Rename block_signal to ignore_signal
via da1a6a3 ctdb-common: Remove unused functions
via 0015b2a ctdb-daemon: No need to block SIGPIPE at startup
via 7226618 ctdb-common: Separate more system utilities that are independent of ctdb
via 890bd9f ctdb-common: Separate system utilties that are ctdb independent
via dd67243 ctdb-common: No dynamic memory allocation in mkdir_p()
via 8fa8b3b ctdb-common: Do not dynamically allocate memory when not necessary
via 3a9d375 ctdb-common: Drop ctdb prefix from utility functions independent of ctdb
via 5b580e5 ctdb-common: Changing scheduler policy does not require ctdb context
via fb0b389 ctdb-common: Do not abort if restoring scheduling policy fails
via 19fcf6f ctdb-common: No need to save previous scheduler priority
from 1dda098 libsmb: Put the "smb2_lease" struct into idl
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 9e6e48750d1fad8ec7cd076f7ca7d2b028007258
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 6 16:49:13 2014 +1000
ctdb-daemon: Reset scheduler policy for helper processes
Do not run helper processes with real-time priority.
This regression was caused when locking and eventscript code switched
to use vfork() and helper instead of ctdb_fork().
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
Autobuild-User(master): Martin Schwenke <martins at samba.org>
Autobuild-Date(master): Thu Jun 12 08:10:36 CEST 2014 on sn-devel-104
commit e9eed41d7ffded2dfd1406f60ad08fe070fd52c1
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Jun 10 12:17:32 2014 +1000
ctdb-daemon: Do not complain if node is inactive and db is not attached
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 79a6bd269291a4b4dabc57254b79bbfa82ac70e4
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Jun 10 11:56:39 2014 +1000
ctdb-build: Remove duplicate library dependency
LIB_FLAGS includes TDB_LIBS.
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 71ed758c72db36234209428fa54be82fe8f0899a
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 6 16:46:15 2014 +1000
ctdb-daemon: Remove duplicate code from helper binaries
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit e7c72588d187f9505444f48a1c5b19e47b15ccd9
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 6 15:43:22 2014 +1000
ctdb-logging: Move controls handling functions from common to server
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 27d1137e26703d7fa5fba638e56961384a140eb2
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Jun 10 14:52:19 2014 +1000
ctdb-logging: Split ringbuffer handling code from ctdb_collect_log
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 49e34651a95a336c9e410e4b52a8cfd491ca0a67
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 6 15:25:08 2014 +1000
ctdb-common: Move mkdir_p_or_die to system utilities
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 4736486188afb8ff6243bcc8a27daa9dbcc64b7a
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 6 15:24:20 2014 +1000
ctdb-daemon: Rename ctdb_mkdir_p_or_die to mkdir_p_or_die
This function does not require ctdb context.
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 507207e40b193ba753604666c56dfa29c29b7145
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Jun 10 17:04:34 2014 +1000
ctdb-common: Move lockdown_memory to system utilities
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 8c8ef5640e17c1acbda99921277a41442bcc4801
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Jun 10 17:00:38 2014 +1000
ctdb-daemon: Rename ctdb_lockdown_memory to lockdown_memory
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 22f71579a46203236bb6ec7e5bef3b2151700898
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 6 15:08:22 2014 +1000
ctdb-daemon: Instead of passing ctdb context, pass valgrinding boolean
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit e11483012460fd3654bd0a3640755f581d3fecf4
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 6 15:00:08 2014 +1000
ctdb-common: Keep debug level related functions with logging code
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit d09f8134c1a915ec59c502769b72a84d43a5c577
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 6 14:58:17 2014 +1000
ctdb-daemon: Rename block_signal to ignore_signal
This function does not block signals, but ignores them.
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit da1a6a3d31f0a08492b723458b882aea48bb14ec
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 6 14:55:23 2014 +1000
ctdb-common: Remove unused functions
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 0015b2a94a4c1682bc771ae265bb3764d2697a4e
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 6 14:52:02 2014 +1000
ctdb-daemon: No need to block SIGPIPE at startup
Once CTDB is daemonized, it starts ignoring SIGPIPE anyway.
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 7226618717644a6ba86e6da5afe92fdbc1cd0858
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 6 13:52:15 2014 +1000
ctdb-common: Separate more system utilities that are independent of ctdb
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 890bd9fb7f11b1236d493770fe635da9cfcad5f7
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 6 12:55:56 2014 +1000
ctdb-common: Separate system utilties that are ctdb independent
Routines in system_common and system_<os> are supposed to be ctdb
functions with OS specific implementations.
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit dd672431c0b8a3a416f6c244b131074d868250cc
Author: Martin Schwenke <martin at meltin.net>
Date: Wed Jun 11 16:58:20 2014 +1000
ctdb-common: No dynamic memory allocation in mkdir_p()
Allocate an array of size PATH_MAX on the stack instead. To stop
unnecessary recursion, try to create the desired directory before
creating ancestors and only create ancestors on ENOENT.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 8fa8b3b397853a29f12875454b890fa5c7b8cda8
Author: Martin Schwenke <martin at meltin.net>
Date: Wed Jun 11 16:04:55 2014 +1000
ctdb-common: Do not dynamically allocate memory when not necessary
Copy these values onto the stack instead. INET6_ADDRSTRLEN is 46, so
64 is plenty for an IP address and a port number.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 3a9d375328e78e58a20584cc138bd52f930f33b7
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Jun 10 16:48:03 2014 +1000
ctdb-common: Drop ctdb prefix from utility functions independent of ctdb
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 5b580e5d65ac5dce9dc07aba4fe1f31226a66ed8
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Jun 10 16:44:59 2014 +1000
ctdb-common: Changing scheduler policy does not require ctdb context
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit fb0b389dc17ee4626f07f2056edecddc51286281
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 6 12:27:29 2014 +1000
ctdb-common: Do not abort if restoring scheduling policy fails
This code is only executed in child processes, so aborting does not
really achieve much.
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 19fcf6ff5206b14c481f078371f5b407d43900b7
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 6 12:21:25 2014 +1000
ctdb-common: No need to save previous scheduler priority
When calling sched_setscheduler() with SCHED_OTHER, the only valid
priority is 0. Nice value is "restored" anyway.
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
-----------------------------------------------------------------------
Summary of changes:
ctdb/Makefile.in | 15 +-
ctdb/common/ctdb_fork.c | 2 +-
ctdb/common/ctdb_logging.c | 87 ++++++----
ctdb/common/ctdb_util.c | 368 ---------------------------------------
ctdb/common/system_common.c | 32 ----
ctdb/common/system_util.c | 365 ++++++++++++++++++++++++++++++++++++++
ctdb/include/ctdb_private.h | 13 +-
ctdb/server/ctdb_daemon.c | 10 +-
ctdb/server/ctdb_event_helper.c | 14 +--
ctdb/server/ctdb_lock_helper.c | 4 +-
ctdb/server/ctdb_logging.c | 41 +++++-
ctdb/server/ctdb_ltdb_server.c | 7 +-
ctdb/server/ctdbd.c | 7 +-
ctdb/tests/src/ctdb_test.c | 1 +
ctdb/tests/src/ctdbd_test.c | 1 +
15 files changed, 492 insertions(+), 475 deletions(-)
create mode 100644 ctdb/common/system_util.c
Changeset truncated at 500 lines:
diff --git a/ctdb/Makefile.in b/ctdb/Makefile.in
index 0843a96..e57f126 100755
--- a/ctdb/Makefile.in
+++ b/ctdb/Makefile.in
@@ -88,7 +88,7 @@ UTIL_OBJ = lib/util/idtree.o lib/util/db_wrap.o lib/util/strlist.o lib/util/util
CTDB_COMMON_OBJ = common/ctdb_io.o common/ctdb_util.o \
common/ctdb_ltdb.o common/ctdb_message.o common/cmdline.o \
lib/util/debug.o common/rb_tree.o @CTDB_SYSTEM_OBJ@ common/system_common.o \
- common/ctdb_logging.o common/ctdb_fork.o
+ common/ctdb_logging.o common/ctdb_fork.o common/system_util.o
CTDB_TCP_OBJ = tcp/tcp_connect.o tcp/tcp_io.o tcp/tcp_init.o
@@ -178,15 +178,18 @@ bin/ctdb: $(CTDB_CLIENT_OBJ) tools/ctdb.o tools/ctdb_vacuum.o
bin/ltdbtool: tools/ltdbtool.o $(TDB_OBJ)
@echo Linking $@
- $(WRAPPER) $(CC) $(CFLAGS) -o $@ $+ $(TDB_LIBS) $(LIB_FLAGS)
+ $(WRAPPER) $(CC) $(CFLAGS) -o $@ $+ $(LIB_FLAGS)
-bin/ctdb_lock_helper: server/ctdb_lock_helper.o lib/util/util_file.o $(CTDB_EXTERNAL_OBJ)
+HELPER_COMMON_OBJ = common/system_util.o common/ctdb_logging.o \
+ lib/util/debug.o lib/util/util_time.o lib/util/util_file.o
+
+bin/ctdb_lock_helper: server/ctdb_lock_helper.o $(HELPER_COMMON_OBJ) $(CTDB_EXTERNAL_OBJ)
@echo Linking $@
- $(WRAPPER) $(CC) $(CFLAGS) -o $@ server/ctdb_lock_helper.o lib/util/util_file.o $(CTDB_EXTERNAL_OBJ) $(TDB_LIBS) $(LIB_FLAGS)
+ $(WRAPPER) $(CC) $(CFLAGS) -o $@ server/ctdb_lock_helper.o $(HELPER_COMMON_OBJ) $(CTDB_EXTERNAL_OBJ) $(LIB_FLAGS)
-bin/ctdb_event_helper: server/ctdb_event_helper.o $(REPLACE_OBJ) $(SOCKET_WRAPPER_OBJ)
+bin/ctdb_event_helper: server/ctdb_event_helper.o $(HELPER_COMMON_OBJ) $(CTDB_EXTERNAL_OBJ)
@echo Linking $@
- $(WRAPPER) $(CC) $(CFLAGS) -o $@ server/ctdb_event_helper.o $(REPLACE_OBJ) $(SOCKET_WRAPPER_OBJ) $(LIB_FLAGS)
+ $(WRAPPER) $(CC) $(CFLAGS) -o $@ server/ctdb_event_helper.o $(HELPER_COMMON_OBJ) $(CTDB_EXTERNAL_OBJ) $(LIB_FLAGS)
bin/smnotify: utils/smnotify/gen_xdr.o utils/smnotify/gen_smnotify.o utils/smnotify/smnotify.o $(POPT_OBJ)
@echo Linking $@
diff --git a/ctdb/common/ctdb_fork.c b/ctdb/common/ctdb_fork.c
index 1d7d9aa..aa9bcf0 100644
--- a/ctdb/common/ctdb_fork.c
+++ b/ctdb/common/ctdb_fork.c
@@ -92,7 +92,7 @@ pid_t ctdb_fork_no_free_ringbuffer(struct ctdb_context *ctdb)
/* The child does not need to be realtime */
if (ctdb->do_setsched) {
- ctdb_restore_scheduler(ctdb);
+ reset_scheduler();
}
ctdb->can_send_controls = false;
diff --git a/ctdb/common/ctdb_logging.c b/ctdb/common/ctdb_logging.c
index ba3e861..6dd1a38 100644
--- a/ctdb/common/ctdb_logging.c
+++ b/ctdb/common/ctdb_logging.c
@@ -23,6 +23,9 @@
#include "../include/ctdb_private.h"
#include "../include/ctdb_client.h"
+int LogLevel = DEBUG_NOTICE;
+int this_log_level = 0;
+
int log_ringbuf_size;
#define MAX_LOG_SIZE 128
@@ -100,7 +103,8 @@ void ctdb_log_ringbuffer_free(void)
log_ringbuf_size = 0;
}
-void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr *log_addr)
+TDB_DATA ctdb_log_ringbuffer_collect_log(TALLOC_CTX *mem_ctx,
+ enum debug_level max_level)
{
TDB_DATA data;
FILE *f;
@@ -115,14 +119,15 @@ void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr *log_a
/* dump to a file, then send the file as a blob */
f = tmpfile();
if (f == NULL) {
- DEBUG(DEBUG_ERR,(__location__ " Unable to open tmpfile - %s\n", strerror(errno)));
- return;
+ DEBUG(DEBUG_ERR,(__location__ " Unable to open tmpfile - %s\n",
+ strerror(errno)));
+ return tdb_null;
}
for (i=0; i<ringbuf_count; i++) {
tmp_entry = (first_entry + i) % log_ringbuf_size;
- if (log_entries[tmp_entry].level > log_addr->level) {
+ if (log_entries[tmp_entry].level > max_level) {
continue;
}
@@ -140,50 +145,21 @@ void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr *log_a
if (fsize < 0) {
fclose(f);
DEBUG(DEBUG_ERR, ("Cannot get file size for log entries\n"));
- return;
+ return tdb_null;
}
rewind(f);
data.dptr = talloc_size(NULL, fsize);
if (data.dptr == NULL) {
fclose(f);
- CTDB_NO_MEMORY_VOID(ctdb, data.dptr);
+ DEBUG(DEBUG_ERR, (__location__ " Memory allocation error\n"));
+ return tdb_null;
}
data.dsize = fread(data.dptr, 1, fsize, f);
fclose(f);
DEBUG(DEBUG_ERR,("Marshalling log entries into a blob of %d bytes\n", (int)data.dsize));
- DEBUG(DEBUG_ERR,("Send log to %d:%d\n", (int)log_addr->pnn, (int)log_addr->srvid));
- ctdb_client_send_message(ctdb, log_addr->pnn, log_addr->srvid, data);
-
- talloc_free(data.dptr);
-}
-
-int32_t ctdb_control_get_log(struct ctdb_context *ctdb, TDB_DATA addr)
-{
- struct ctdb_get_log_addr *log_addr = (struct ctdb_get_log_addr *)addr.dptr;
- pid_t child;
-
- /* spawn a child process to marshall the huge log blob and send it back
- to the ctdb tool using a MESSAGE
- */
- child = ctdb_fork_no_free_ringbuffer(ctdb);
- if (child == (pid_t)-1) {
- DEBUG(DEBUG_ERR,("Failed to fork a log collector child\n"));
- return -1;
- }
-
- if (child == 0) {
- ctdb_set_process_name("ctdb_log_collector");
- if (switch_from_server_to_client(ctdb, "log-collector") != 0) {
- DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch log collector child into client mode.\n"));
- _exit(1);
- }
- ctdb_collect_log(ctdb, log_addr);
- _exit(0);
- }
-
- return 0;
+ return data;
}
void ctdb_clear_log(struct ctdb_context *ctdb)
@@ -198,3 +174,40 @@ int32_t ctdb_control_clear_log(struct ctdb_context *ctdb)
return 0;
}
+
+struct debug_levels debug_levels[] = {
+ {DEBUG_EMERG, "EMERG"},
+ {DEBUG_ALERT, "ALERT"},
+ {DEBUG_CRIT, "CRIT"},
+ {DEBUG_ERR, "ERR"},
+ {DEBUG_WARNING, "WARNING"},
+ {DEBUG_NOTICE, "NOTICE"},
+ {DEBUG_INFO, "INFO"},
+ {DEBUG_DEBUG, "DEBUG"},
+ {0, NULL}
+};
+
+const char *get_debug_by_level(int32_t level)
+{
+ int i;
+
+ for (i=0; debug_levels[i].description != NULL; i++) {
+ if (debug_levels[i].level == level) {
+ return debug_levels[i].description;
+ }
+ }
+ return "Unknown";
+}
+
+int32_t get_debug_by_desc(const char *desc)
+{
+ int i;
+
+ for (i=0; debug_levels[i].description != NULL; i++) {
+ if (!strcasecmp(debug_levels[i].description, desc)) {
+ return debug_levels[i].level;
+ }
+ }
+
+ return DEBUG_ERR;
+}
diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c
index fd0d7da..f71f74a 100644
--- a/ctdb/common/ctdb_util.c
+++ b/ctdb/common/ctdb_util.c
@@ -22,12 +22,8 @@
#include "system/network.h"
#include "system/filesys.h"
#include "system/wait.h"
-#include "system/shmem.h"
#include "../include/ctdb_private.h"
-int LogLevel = DEBUG_NOTICE;
-int this_log_level = 0;
-
/*
return error string for last error
*/
@@ -317,277 +313,6 @@ struct ctdb_rec_data *ctdb_marshall_loop_next(struct ctdb_marshall_buffer *m, st
return r;
}
-
-#if HAVE_SCHED_H
-#include <sched.h>
-#endif
-
-#if HAVE_PROCINFO_H
-#include <procinfo.h>
-#endif
-
-/*
- if possible, make this task real time
- */
-void ctdb_set_scheduler(struct ctdb_context *ctdb)
-{
-#ifdef _AIX_
-#if HAVE_THREAD_SETSCHED
- struct thrdentry64 te;
- tid64_t ti;
-
- ti = 0ULL;
- if (getthrds64(getpid(), &te, sizeof(te), &ti, 1) != 1) {
- DEBUG(DEBUG_ERR, ("Unable to get thread information\n"));
- return;
- }
-
- if (ctdb->saved_scheduler_param == NULL) {
- ctdb->saved_scheduler_param = talloc_size(ctdb, sizeof(te));
- }
- *(struct thrdentry64 *)ctdb->saved_scheduler_param = te;
-
- if (thread_setsched(te.ti_tid, 0, SCHED_RR) == -1) {
- DEBUG(DEBUG_ERR, ("Unable to set scheduler to SCHED_RR (%s)\n",
- strerror(errno)));
- } else {
- DEBUG(DEBUG_NOTICE, ("Set scheduler to SCHED_RR\n"));
- }
-#endif
-#else /* no AIX */
-#if HAVE_SCHED_SETSCHEDULER
- struct sched_param p;
- 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(DEBUG_ERR,("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(DEBUG_CRIT,("Unable to set scheduler to SCHED_FIFO (%s)\n",
- strerror(errno)));
- } else {
- DEBUG(DEBUG_NOTICE,("Set scheduler to SCHED_FIFO\n"));
- }
-#endif
-#endif
-}
-
-/*
- restore previous scheduler parameters
- */
-void ctdb_restore_scheduler(struct ctdb_context *ctdb)
-{
-#ifdef _AIX_
-#if HAVE_THREAD_SETSCHED
- struct thrdentry64 te, *saved;
- tid64_t ti;
-
- ti = 0ULL;
- if (getthrds64(getpid(), &te, sizeof(te), &ti, 1) != 1) {
- ctdb_fatal(ctdb, "Unable to get thread information\n");
- }
- if (ctdb->saved_scheduler_param == NULL) {
- ctdb_fatal(ctdb, "No saved scheduler parameters\n");
- }
- saved = (struct thrdentry64 *)ctdb->saved_scheduler_param;
- if (thread_setsched(te.ti_tid, saved->ti_pri, saved->ti_policy) == -1) {
- ctdb_fatal(ctdb, "Unable to restore old scheduler parameters\n");
- }
-#endif
-#else /* no AIX */
-#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
-#endif
-}
-
-void set_nonblocking(int fd)
-{
- int v;
-
- v = fcntl(fd, F_GETFL, 0);
- if (v == -1) {
- DEBUG(DEBUG_WARNING, ("Failed to get file status flags - %s\n",
- strerror(errno)));
- return;
- }
- if (fcntl(fd, F_SETFL, v | O_NONBLOCK) == -1) {
- DEBUG(DEBUG_WARNING, ("Failed to set non_blocking on fd - %s\n",
- strerror(errno)));
- }
-}
-
-void set_close_on_exec(int fd)
-{
- int v;
-
- v = fcntl(fd, F_GETFD, 0);
- if (v == -1) {
- DEBUG(DEBUG_WARNING, ("Failed to get file descriptor flags - %s\n",
- strerror(errno)));
- return;
- }
- if (fcntl(fd, F_SETFD, v | FD_CLOEXEC) != 0) {
- DEBUG(DEBUG_WARNING, ("Failed to set close_on_exec on fd - %s\n",
- strerror(errno)));
- }
-}
-
-
-bool parse_ipv4(const char *s, unsigned port, struct sockaddr_in *sin)
-{
- sin->sin_family = AF_INET;
- sin->sin_port = htons(port);
-
- if (inet_pton(AF_INET, s, &sin->sin_addr) != 1) {
- DEBUG(DEBUG_ERR, (__location__ " Failed to translate %s into sin_addr\n", s));
- return false;
- }
-
- return true;
-}
-
-static bool parse_ipv6(const char *s, const char *ifaces, unsigned port, ctdb_sock_addr *saddr)
-{
- saddr->ip6.sin6_family = AF_INET6;
- saddr->ip6.sin6_port = htons(port);
- saddr->ip6.sin6_flowinfo = 0;
- saddr->ip6.sin6_scope_id = 0;
-
- if (inet_pton(AF_INET6, s, &saddr->ip6.sin6_addr) != 1) {
- DEBUG(DEBUG_ERR, (__location__ " Failed to translate %s into sin6_addr\n", s));
- return false;
- }
-
- if (ifaces && IN6_IS_ADDR_LINKLOCAL(&saddr->ip6.sin6_addr)) {
- if (strchr(ifaces, ',')) {
- DEBUG(DEBUG_ERR, (__location__ " Link local address %s "
- "is specified for multiple ifaces %s\n",
- s, ifaces));
- return false;
- }
- saddr->ip6.sin6_scope_id = if_nametoindex(ifaces);
- }
-
- return true;
-}
-/*
- parse a ip:port pair
- */
-bool parse_ip_port(const char *addr, ctdb_sock_addr *saddr)
-{
- TALLOC_CTX *tmp_ctx = talloc_new(NULL);
- char *s, *p;
- unsigned port;
- char *endp = NULL;
- bool ret;
-
- s = talloc_strdup(tmp_ctx, addr);
- if (s == NULL) {
- DEBUG(DEBUG_ERR, (__location__ " Failed strdup()\n"));
- talloc_free(tmp_ctx);
- return false;
- }
-
- p = rindex(s, ':');
- if (p == NULL) {
- DEBUG(DEBUG_ERR, (__location__ " This addr: %s does not contain a port number\n", s));
- talloc_free(tmp_ctx);
- return false;
- }
-
- port = strtoul(p+1, &endp, 10);
- if (endp == NULL || *endp != 0) {
- /* trailing garbage */
- DEBUG(DEBUG_ERR, (__location__ " Trailing garbage after the port in %s\n", s));
- talloc_free(tmp_ctx);
- return false;
- }
- *p = 0;
-
-
- /* now is this a ipv4 or ipv6 address ?*/
- ret = parse_ip(s, NULL, port, saddr);
-
- talloc_free(tmp_ctx);
- return ret;
-}
-
-/*
- parse an ip
- */
-bool parse_ip(const char *addr, const char *ifaces, unsigned port, ctdb_sock_addr *saddr)
-{
- char *p;
- bool ret;
-
- ZERO_STRUCTP(saddr); /* valgrind :-) */
-
- /* now is this a ipv4 or ipv6 address ?*/
- p = index(addr, ':');
- if (p == NULL) {
- ret = parse_ipv4(addr, port, &saddr->ip);
- } else {
- ret = parse_ipv6(addr, ifaces, port, saddr);
- }
-
- return ret;
-}
-
-/*
- parse a ip/mask pair
- */
-bool parse_ip_mask(const char *str, const char *ifaces, ctdb_sock_addr *addr, unsigned *mask)
-{
- TALLOC_CTX *tmp_ctx = talloc_new(NULL);
- char *s, *p;
- char *endp = NULL;
- bool ret;
-
- ZERO_STRUCT(*addr);
- s = talloc_strdup(tmp_ctx, str);
- if (s == NULL) {
- DEBUG(DEBUG_ERR, (__location__ " Failed strdup()\n"));
- talloc_free(tmp_ctx);
- return false;
- }
-
- p = rindex(s, '/');
- if (p == NULL) {
- DEBUG(DEBUG_ERR, (__location__ " This addr: %s does not contain a mask\n", s));
- talloc_free(tmp_ctx);
- return false;
- }
-
- *mask = strtoul(p+1, &endp, 10);
- if (endp == NULL || *endp != 0) {
- /* trailing garbage */
- DEBUG(DEBUG_ERR, (__location__ " Trailing garbage after the mask in %s\n", s));
- talloc_free(tmp_ctx);
- return false;
- }
- *p = 0;
-
-
- /* now is this a ipv4 or ipv6 address ?*/
- ret = parse_ip(s, ifaces, 0, addr);
-
- talloc_free(tmp_ctx);
- return ret;
-}
-
/*
This is used to canonicalize a ctdb_sock_addr structure.
*/
@@ -678,85 +403,6 @@ unsigned ctdb_addr_to_port(ctdb_sock_addr *addr)
return 0;
}
-void ctdb_block_signal(int signum)
-{
- sigset_t set;
- sigemptyset(&set);
- sigaddset(&set,signum);
- sigprocmask(SIG_BLOCK,&set,NULL);
-}
-
-void ctdb_unblock_signal(int signum)
-{
- sigset_t set;
- sigemptyset(&set);
--
Samba Shared Repository
More information about the samba-cvs
mailing list