From 2ab0bd0d1637c7d2d3d2223fe1179fb4cad24654 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 22 Sep 2014 18:14:53 +1000 Subject: [PATCH 01/34] lib/util: Clean up includes for blocking.c Add blocking.h. Allows standalone compile without external includes.h. Signed-off-by: Martin Schwenke Reviewed-by: Jeremy Allison (cherry picked from commit 3d6675fd1ee32ba0795f7f09f42a1b005ba5e621) --- lib/util/blocking.c | 3 ++- lib/util/blocking.h | 32 ++++++++++++++++++++++++++++++++ lib/util/samba_util.h | 13 +------------ lib/util/wscript_build | 2 +- 4 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 lib/util/blocking.h diff --git a/lib/util/blocking.c b/lib/util/blocking.c index 157804a..358eda0 100644 --- a/lib/util/blocking.c +++ b/lib/util/blocking.c @@ -21,10 +21,11 @@ along with this program. If not, see . */ -#include "includes.h" +#include "replace.h" #include "system/network.h" #include "system/filesys.h" #include "system/locale.h" +#include "blocking.h" #undef malloc #undef strcasecmp #undef strncasecmp diff --git a/lib/util/blocking.h b/lib/util/blocking.h new file mode 100644 index 0000000..017e424 --- /dev/null +++ b/lib/util/blocking.h @@ -0,0 +1,32 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Andrew Tridgell 1992-1998 + Copyright (C) Jeremy Allison 2001-2002 + Copyright (C) Simo Sorce 2001 + Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003. + Copyright (C) James J Myers 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _SAMBA_BLOCKING_H_ +#define _SAMBA_BLOCKING_H_ + +#include + +int set_blocking(int fd, bool set); +bool smb_set_close_on_exec(int fd); + +#endif /* _SAMBA_BLOCKING_H_ */ diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index e9de6fa..35eef42 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -649,18 +649,7 @@ _PUBLIC_ bool directory_create_or_exist_strict(const char *dname, uid_t uid, mode_t dir_perms); -/** - Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available, - else - if SYSV use O_NDELAY - if BSD use FNDELAY -**/ -_PUBLIC_ int set_blocking(int fd, bool set); - -/** - set close on exec on a file descriptor if available - **/ -_PUBLIC_ bool smb_set_close_on_exec(int fd); +#include "blocking.h" /** Sleep for a specified number of milliseconds. diff --git a/lib/util/wscript_build b/lib/util/wscript_build index d7e5b03..9bdf812 100755 --- a/lib/util/wscript_build +++ b/lib/util/wscript_build @@ -42,7 +42,7 @@ bld.SAMBA_LIBRARY('samba-util', tevent_debug.c util_process.c memcache.c''', deps='DYNCONFIG time-basic close-low-fd samba-debug tini tiniparser socket-blocking', public_deps='talloc tevent execinfo pthread LIBCRYPTO charset util_setid systemd-daemon', - public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h xfile.h dlinklist.h samba_util.h string_wrappers.h idtree.h idtree_random.h', + public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h xfile.h dlinklist.h samba_util.h string_wrappers.h idtree.h idtree_random.h blocking.h', header_path= [ ('dlinklist.h samba_util.h', '.'), ('*', 'util') ], local_include=False, vnum='0.0.1', -- 2.1.1 From 9f3ed8cf49ebb29adc59516b53974fef8f03d2b7 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 22 Sep 2014 19:21:42 +1000 Subject: [PATCH 02/34] lib/util: Clean up includes for xfile.[ch] The include files added to xfile.h are already included unconditionally elsewhere (replace.h, samba_util.h, ...) so Samba can't be built without them. To minimise dependencies, only include specific util headers instead of samba_util.h. Signed-off-by: Martin Schwenke Reviewed-by: Jeremy Allison (cherry picked from commit 2d7dfe3d68c39f11afdece3281f9fbca0b48fb3f) --- lib/util/xfile.c | 3 ++- lib/util/xfile.h | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/util/xfile.c b/lib/util/xfile.c index 58a34bf..62dd121 100644 --- a/lib/util/xfile.c +++ b/lib/util/xfile.c @@ -35,7 +35,8 @@ #include "replace.h" #include "system/filesys.h" -#include "lib/util/samba_util.h" +#include "memory.h" +#include "xfile.h" #define XBUFSIZE BUFSIZ diff --git a/lib/util/xfile.h b/lib/util/xfile.h index 1b15929..f52596d 100644 --- a/lib/util/xfile.h +++ b/lib/util/xfile.h @@ -19,6 +19,12 @@ #ifndef _XFILE_H_ #define _XFILE_H_ + +#include +#include +#include +#include "attr.h" + /* see xfile.c for explanations */ -- 2.1.1 From 8749dff39d3d89e1579d35767be67433c4aad060 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 22 Sep 2014 19:31:23 +1000 Subject: [PATCH 03/34] lib/util: Clean up includes for data_blob.[ch] Allows standalone compile without external includes.h. Signed-off-by: Martin Schwenke Reviewed-by: Jeremy Allison (cherry picked from commit 1f0e5cb38c6d444d33b7736d43a32439cdf04d81) --- lib/util/data_blob.c | 4 +++- lib/util/data_blob.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/util/data_blob.c b/lib/util/data_blob.c index 10864a0..1b0e6ab 100644 --- a/lib/util/data_blob.c +++ b/lib/util/data_blob.c @@ -18,7 +18,9 @@ along with this program. If not, see . */ -#include "includes.h" +#include "replace.h" +#include "attr.h" +#include "data_blob.h" const DATA_BLOB data_blob_null = { NULL, 0 }; diff --git a/lib/util/data_blob.h b/lib/util/data_blob.h index 09a9292..a5caa92 100644 --- a/lib/util/data_blob.h +++ b/lib/util/data_blob.h @@ -31,6 +31,7 @@ #endif #include +#include #include /* used to hold an arbitrary blob of data */ -- 2.1.1 From 10c6ce93a5fe1da8916eb71fdbbfd6f3acf64325 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 22 Sep 2014 19:38:18 +1000 Subject: [PATCH 04/34] lib/util: Clean up includes for time.[ch] Allows standalone compile without external includes.h. Signed-off-by: Martin Schwenke Reviewed-by: Jeremy Allison (cherry picked from commit fd9f0c27e71cdda833e9dd24f0eb87ad524e73cf) --- lib/util/time.c | 6 ++++-- lib/util/time.h | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/util/time.c b/lib/util/time.c index 78611e4..4b78e71 100644 --- a/lib/util/time.c +++ b/lib/util/time.c @@ -21,9 +21,11 @@ along with this program. If not, see . */ -#include "includes.h" +#include "replace.h" #include "system/time.h" -#include "lib/util/time_basic.h" +#include "byteorder.h" +#include "time_basic.h" +#include "lib/util/time.h" /* Avoid /usr/include/time.h */ /** * @file diff --git a/lib/util/time.h b/lib/util/time.h index 8595bb0..42d2386 100644 --- a/lib/util/time.h +++ b/lib/util/time.h @@ -24,6 +24,10 @@ #ifndef _SAMBA_TIME_H_ #define _SAMBA_TIME_H_ +#include +#include +#include + #ifndef TIME_T_MIN /* we use 0 here, because (time_t)-1 means error */ #define TIME_T_MIN 0 -- 2.1.1 From 38ff1ea507ee2cabaca0cb982c4cc36f417a8a0b Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 22 Sep 2014 19:57:52 +1000 Subject: [PATCH 05/34] lib/util: Clean up includes for signal.c Add signal.h. Allows standalone compiles without external includes.h. Signed-off-by: Martin Schwenke Reviewed-by: Jeremy Allison (cherry picked from commit b69edfed7db299e53e95bcb26cc2899ddd3adb28) --- lib/util/samba_util.h | 26 +------------------------- lib/util/signal.c | 4 +++- lib/util/signal.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/util/wscript_build | 2 +- 4 files changed, 54 insertions(+), 27 deletions(-) create mode 100644 lib/util/signal.h diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index 35eef42..0507de6 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -89,31 +89,7 @@ _PUBLIC_ _NORETURN_ void smb_panic(const char *reason); */ _PUBLIC_ bool register_fault_handler(const char *name, void (*fault_handler)(int sig)); -/* The following definitions come from lib/util/signal.c */ - - -/** - Block sigs. -**/ -void BlockSignals(bool block, int signum); - -/** - Catch a signal. This should implement the following semantics: - - 1) The handler remains installed after being called. - 2) The signal should be blocked during handler execution. -**/ -void (*CatchSignal(int signum,void (*handler)(int )))(int); - -/** - Ignore SIGCLD via whatever means is necessary for this OS. -**/ -void (*CatchChild(void))(int); - -/** - Catch SIGCLD but leave the child around so it's status can be reaped. -**/ -void (*CatchChildLeaveStatus(void))(int); +#include "lib/util/signal.h" /* Avoid /usr/include/signal.h */ struct sockaddr; diff --git a/lib/util/signal.c b/lib/util/signal.c index 33a9900..3fc63b2 100644 --- a/lib/util/signal.c +++ b/lib/util/signal.c @@ -18,8 +18,10 @@ along with this program. If not, see . */ -#include "includes.h" +#include "replace.h" #include "system/wait.h" +#include "debug.h" +#include "lib/util/signal.h" /* Avoid /usr/include/signal.h */ /** * @file diff --git a/lib/util/signal.h b/lib/util/signal.h new file mode 100644 index 0000000..0663af6 --- /dev/null +++ b/lib/util/signal.h @@ -0,0 +1,49 @@ +/* + Unix SMB/CIFS implementation. + signal handling functions + + Copyright (C) Andrew Tridgell 1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _SAMBA_UTIL_SIGNAL_H_ +#define _SAMBA_UTIL_SIGNAL_H_ + +#include + +/** + Block sigs. +**/ +void BlockSignals(bool block, int signum); + +/** + Catch a signal. This should implement the following semantics: + + 1) The handler remains installed after being called. + 2) The signal should be blocked during handler execution. +**/ +void (*CatchSignal(int signum,void (*handler)(int )))(int); + +/** + Ignore SIGCLD via whatever means is necessary for this OS. +**/ +void (*CatchChild(void))(int); + +/** + Catch SIGCLD but leave the child around so it's status can be reaped. +**/ +void (*CatchChildLeaveStatus(void))(int); + +#endif /* _SAMBA_UTIL_SIGNAL_H_ */ diff --git a/lib/util/wscript_build b/lib/util/wscript_build index 9bdf812..151c87a 100755 --- a/lib/util/wscript_build +++ b/lib/util/wscript_build @@ -42,7 +42,7 @@ bld.SAMBA_LIBRARY('samba-util', tevent_debug.c util_process.c memcache.c''', deps='DYNCONFIG time-basic close-low-fd samba-debug tini tiniparser socket-blocking', public_deps='talloc tevent execinfo pthread LIBCRYPTO charset util_setid systemd-daemon', - public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h xfile.h dlinklist.h samba_util.h string_wrappers.h idtree.h idtree_random.h blocking.h', + public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h xfile.h dlinklist.h samba_util.h string_wrappers.h idtree.h idtree_random.h blocking.h signal.h', header_path= [ ('dlinklist.h samba_util.h', '.'), ('*', 'util') ], local_include=False, vnum='0.0.1', -- 2.1.1 From 788e1d95c24358c85d693524720499811e692187 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 24 Sep 2014 04:41:25 +1000 Subject: [PATCH 06/34] lib/util: Replace an SMB_ASSERT() Avoid a cyclic dependency. Signed-off-by: Martin Schwenke Reviewed-by: Jeremy Allison (cherry picked from commit 2426130c90b216d131330e896daf7302cc198b4a) --- lib/util/substitute.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/util/substitute.c b/lib/util/substitute.c index 500d127..30b4e00 100644 --- a/lib/util/substitute.c +++ b/lib/util/substitute.c @@ -146,7 +146,11 @@ _PUBLIC_ char *string_sub_talloc(TALLOC_CTX *mem_ctx, const char *s, if (ret == NULL) return NULL; - SMB_ASSERT(ret[len] == '\0'); + if (ret[len] != '\0') { + DEBUG(0,("Internal error at %s(%d): string not terminated\n", + __FILE__, __LINE__)); + abort(); + } talloc_set_name_const(ret, ret); -- 2.1.1 From d694ce96b41abe484b164cb6b396fae2b0a6909e Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 22 Sep 2014 20:38:52 +1000 Subject: [PATCH 07/34] lib/util: Clean up includes for substitute.c Add substitute.h. Allows standalone compiles without external includes.h. Signed-off-by: Martin Schwenke Reviewed-by: Jeremy Allison (cherry picked from commit d92940819f4162985a70f6b2c79032f75f9fce49) --- lib/util/samba_util.h | 27 +----------------------- lib/util/substitute.c | 5 ++++- lib/util/substitute.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ lib/util/wscript_build | 2 +- 4 files changed, 62 insertions(+), 28 deletions(-) create mode 100644 lib/util/substitute.h diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index 0507de6..b9ee211 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -229,32 +229,7 @@ _PUBLIC_ void hex_encode(const unsigned char *buff_in, size_t len, char **out_he */ _PUBLIC_ char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len); -/** - Substitute a string for a pattern in another string. Make sure there is - enough room! - - This routine looks for pattern in s and replaces it with - insert. It may do multiple replacements. - - Any of " ; ' $ or ` in the insert string are replaced with _ - if len==0 then the string cannot be extended. This is different from the old - use of len==0 which was for no length checks to be done. -**/ -_PUBLIC_ void string_sub(char *s,const char *pattern, const char *insert, size_t len); - -_PUBLIC_ void string_sub_once(char *s, const char *pattern, - const char *insert, size_t len); - -_PUBLIC_ char *string_sub_talloc(TALLOC_CTX *mem_ctx, const char *s, - const char *pattern, const char *insert); - -/** - Similar to string_sub() but allows for any character to be substituted. - Use with caution! - if len==0 then the string cannot be extended. This is different from the old - use of len==0 which was for no length checks to be done. -**/ -_PUBLIC_ void all_string_sub(char *s,const char *pattern,const char *insert, size_t len); +#include "substitute.h" /** Unescape a URL encoded string, in place. diff --git a/lib/util/substitute.c b/lib/util/substitute.c index 30b4e00..70cc441 100644 --- a/lib/util/substitute.c +++ b/lib/util/substitute.c @@ -21,7 +21,10 @@ along with this program. If not, see . */ -#include "includes.h" +#include "replace.h" +#include "debug.h" +#include "charset/charset.h" +#include "substitute.h" /** * @file diff --git a/lib/util/substitute.h b/lib/util/substitute.h new file mode 100644 index 0000000..5ba469c --- /dev/null +++ b/lib/util/substitute.h @@ -0,0 +1,56 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + + Copyright (C) Andrew Tridgell 1992-2001 + Copyright (C) Simo Sorce 2001-2002 + Copyright (C) Martin Pool 2003 + Copyright (C) James Peach 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _SAMBA_SUBSTITUTE_H_ +#define _SAMBA_SUBSTITUTE_H_ + +#include + +/** + Substitute a string for a pattern in another string. Make sure there is + enough room! + + This routine looks for pattern in s and replaces it with + insert. It may do multiple replacements. + + Any of " ; ' $ or ` in the insert string are replaced with _ + if len==0 then the string cannot be extended. This is different from the old + use of len==0 which was for no length checks to be done. +**/ +void string_sub(char *s,const char *pattern, const char *insert, size_t len); + +void string_sub_once(char *s, const char *pattern, + const char *insert, size_t len); + +char *string_sub_talloc(TALLOC_CTX *mem_ctx, const char *s, + const char *pattern, const char *insert); + +/** + Similar to string_sub() but allows for any character to be substituted. + Use with caution! + if len==0 then the string cannot be extended. This is different from the old + use of len==0 which was for no length checks to be done. +**/ +void all_string_sub(char *s,const char *pattern,const char *insert, size_t len); + +#endif /* _SAMBA_SUBSTITUTE_H_ */ diff --git a/lib/util/wscript_build b/lib/util/wscript_build index 151c87a..88fb171 100755 --- a/lib/util/wscript_build +++ b/lib/util/wscript_build @@ -42,7 +42,7 @@ bld.SAMBA_LIBRARY('samba-util', tevent_debug.c util_process.c memcache.c''', deps='DYNCONFIG time-basic close-low-fd samba-debug tini tiniparser socket-blocking', public_deps='talloc tevent execinfo pthread LIBCRYPTO charset util_setid systemd-daemon', - public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h xfile.h dlinklist.h samba_util.h string_wrappers.h idtree.h idtree_random.h blocking.h signal.h', + public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h xfile.h dlinklist.h samba_util.h string_wrappers.h idtree.h idtree_random.h blocking.h signal.h substitute.h', header_path= [ ('dlinklist.h samba_util.h', '.'), ('*', 'util') ], local_include=False, vnum='0.0.1', -- 2.1.1 From d07953943177e605231535ae677ed7dd3d3ec47b Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 22 Sep 2014 19:43:27 +1000 Subject: [PATCH 08/34] lib/util: Clean up includes for fault.c Add fault.h. Allows standalone compiles without external includes.h. Signed-off-by: Martin Schwenke Reviewed-by: Jeremy Allison (cherry picked from commit 8dac190ee1bc0e7f6d17eeca097f027fcaf584ed) --- lib/util/fault.c | 8 +++++++- lib/util/fault.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ lib/util/samba_util.h | 24 ++-------------------- lib/util/wscript_build | 2 +- 4 files changed, 64 insertions(+), 24 deletions(-) create mode 100644 lib/util/fault.h diff --git a/lib/util/fault.c b/lib/util/fault.c index 78d9177..54d8471 100644 --- a/lib/util/fault.c +++ b/lib/util/fault.c @@ -18,8 +18,9 @@ along with this program. If not, see . */ -#include "includes.h" +#include "replace.h" #include "system/filesys.h" +#include "system/wait.h" #include "version.h" #ifdef HAVE_SYS_SYSCTL_H @@ -31,6 +32,11 @@ #include #endif +#include "debug.h" +#include "lib/util/signal.h" /* Avoid /usr/include/signal.h */ +#include "substitute.h" +#include "fault.h" + static struct { bool disabled; smb_panic_handler_t panic_handler; diff --git a/lib/util/fault.h b/lib/util/fault.h new file mode 100644 index 0000000..98a24a3 --- /dev/null +++ b/lib/util/fault.h @@ -0,0 +1,54 @@ +/* + Unix SMB/CIFS implementation. + Critical Fault handling + Copyright (C) Andrew Tridgell 1992-1998 + Copyright (C) Tim Prouty 2009 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _SAMBA_FAULT_H_ +#define _SAMBA_FAULT_H_ + +#include + +#include "attr.h" +#include "debug.h" + +/** + * assert macros + */ +#define SMB_ASSERT(b) \ +do { \ + if (!(b)) { \ + DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \ + __FILE__, __LINE__, #b)); \ + smb_panic("assert failed: " #b); \ + } \ +} while(0) + +extern const char *panic_action; + +/** + Something really nasty happened - panic ! +**/ +typedef void (*smb_panic_handler_t)(const char *why); + +void fault_configure(smb_panic_handler_t panic_handler); +void fault_setup(void); +void fault_setup_disable(void); +_NORETURN_ void smb_panic(const char *reason); + + +#endif /* _SAMBA_FAULT_H_ */ diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index b9ee211..2578af8 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -45,18 +45,6 @@ extern const char *panic_action; #include "lib/util/byteorder.h" #include "lib/util/talloc_stack.h" -/** - * assert macros - */ -#define SMB_ASSERT(b) \ -do { \ - if (!(b)) { \ - DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \ - __FILE__, __LINE__, #b)); \ - smb_panic("assert failed: " #b); \ - } \ -} while(0) - #ifndef ABS #define ABS(a) ((a)>0?(a):(-(a))) #endif @@ -66,22 +54,14 @@ do { \ #include "../libcli/util/ntstatus.h" #include "lib/util/string_wrappers.h" +#include "fault.h" + /** * Write backtrace to debug log */ _PUBLIC_ void call_backtrace(void); -/** - Something really nasty happened - panic ! -**/ -typedef void (*smb_panic_handler_t)(const char *why); - -_PUBLIC_ void fault_configure(smb_panic_handler_t panic_handler); -_PUBLIC_ void fault_setup(void); -_PUBLIC_ void fault_setup_disable(void); _PUBLIC_ void dump_core_setup(const char *progname, const char *logfile); -_PUBLIC_ _NORETURN_ void smb_panic(const char *reason); - /** register a fault handler. diff --git a/lib/util/wscript_build b/lib/util/wscript_build index 88fb171..0a29fbc 100755 --- a/lib/util/wscript_build +++ b/lib/util/wscript_build @@ -42,7 +42,7 @@ bld.SAMBA_LIBRARY('samba-util', tevent_debug.c util_process.c memcache.c''', deps='DYNCONFIG time-basic close-low-fd samba-debug tini tiniparser socket-blocking', public_deps='talloc tevent execinfo pthread LIBCRYPTO charset util_setid systemd-daemon', - public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h xfile.h dlinklist.h samba_util.h string_wrappers.h idtree.h idtree_random.h blocking.h signal.h substitute.h', + public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h xfile.h dlinklist.h samba_util.h string_wrappers.h idtree.h idtree_random.h blocking.h signal.h substitute.h fault.h', header_path= [ ('dlinklist.h samba_util.h', '.'), ('*', 'util') ], local_include=False, vnum='0.0.1', -- 2.1.1 From d28f505265df02a759c966282ecbb3af7105acf4 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 22 Sep 2014 18:28:53 +1000 Subject: [PATCH 09/34] lib/util: Clean up includes for util.c Allows standalone compiles without external includes.h. Signed-off-by: Martin Schwenke Reviewed-by: Jeremy Allison (cherry picked from commit db15cc5388efdb0803bd2f785f8b6eee7f46ecbf) --- lib/util/util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/util/util.c b/lib/util/util.c index 3ba7e4d..157a4aa 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -22,12 +22,17 @@ along with this program. If not, see . */ -#include "includes.h" +#include +#include "replace.h" #include "system/network.h" #include "system/filesys.h" #include "system/locale.h" #include "system/shmem.h" #include "system/passwd.h" +#include "system/time.h" +#include "system/wait.h" +#include "debug.h" +#include "samba_util.h" #undef malloc #undef strcasecmp -- 2.1.1 From fedb1246751fd3ca67a32bf77a04852fb878b4a4 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 15 Aug 2014 16:00:32 +1000 Subject: [PATCH 10/34] lib/util: Factor out subsystem samba-util-core from samba-util samba-util depends on Samba-specific code. Exclude this code from samba-util-core. When told to, via SAMBA_UTIL_CORE_ONLY, only build samba-util-core and dependencies. When SAMBA_UTIL_CORE_ONLY is not defined then the behaviour should be unchanged. Standalone builds of CTDB will be done against samba-util-core to avoid pulling in Samba-specific code. An alternative would be to remove the Samba-dependent code from samba-util. However, some of it is used by OpenChange. Signed-off-by: Martin Schwenke Reviewed-by: Jeremy Allison (cherry picked from commit 1fd4556917df5d7e2aff4997ff7e5b57f2569b40) --- lib/util/wscript_build | 169 ++++++++++++++++++++++++++----------------------- 1 file changed, 90 insertions(+), 79 deletions(-) diff --git a/lib/util/wscript_build b/lib/util/wscript_build index 0a29fbc..d3865d8 100755 --- a/lib/util/wscript_build +++ b/lib/util/wscript_build @@ -31,16 +31,27 @@ bld.SAMBA_LIBRARY('socket-blocking', local_include=False, private_library=True) -bld.SAMBA_LIBRARY('samba-util', - source='''talloc_stack.c smb_threads.c xfile.c data_blob.c - util_file.c time.c rbtree.c rfc1738.c select.c getpass.c - genrand.c fsusage.c become_daemon.c signal.c system.c - params.c util.c util_id.c util_net.c util_strlist.c - util_paths.c idtree.c idtree_random.c fault.c base64.c - util_str.c util_str_common.c substitute.c ms_fnmatch.c +bld.SAMBA_SUBSYSTEM('samba-util-core', + source='''xfile.c data_blob.c util_file.c time.c + signal.c util.c idtree.c fault.c + substitute.c''', + deps='''time-basic samba-debug socket-blocking talloc + tevent execinfo pthread''', + local_include=False) + +if not bld.env.SAMBA_UTIL_CORE_ONLY: + + bld.SAMBA_LIBRARY('samba-util', + source='''talloc_stack.c smb_threads.c + rbtree.c rfc1738.c become_daemon.c system.c select.c getpass.c + genrand.c fsusage.c + params.c util_id.c util_net.c + util_strlist.c util_paths.c idtree_random.c base64.c + util_str.c util_str_common.c ms_fnmatch.c server_id.c dprintf.c parmlist.c bitmap.c pidfile.c tevent_debug.c util_process.c memcache.c''', - deps='DYNCONFIG time-basic close-low-fd samba-debug tini tiniparser socket-blocking', + deps='samba-util-core DYNCONFIG close-low-fd tini tiniparser', + public_deps='talloc tevent execinfo pthread LIBCRYPTO charset util_setid systemd-daemon', public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h xfile.h dlinklist.h samba_util.h string_wrappers.h idtree.h idtree_random.h blocking.h signal.h substitute.h fault.h', header_path= [ ('dlinklist.h samba_util.h', '.'), ('*', 'util') ], @@ -49,75 +60,75 @@ bld.SAMBA_LIBRARY('samba-util', pc_files='samba-util.pc' ) -bld.SAMBA_LIBRARY('samba-modules', - source='modules.c', - deps='errors samba-util', - local_include=False, - private_library=True) - -bld.SAMBA_LIBRARY('asn1util', - source='asn1.c', - deps='talloc samba-util', - private_library=True, - local_include=False) - - -bld.SAMBA_SUBSYSTEM('UNIX_PRIVS', - source='unix_privs.c', - autoproto='unix_privs.h', - deps='replace talloc', - local_include=False, - ) - - -bld.SAMBA_LIBRARY('util_tdb', - source='util_tdb.c', - local_include=False, - public_deps='tdb talloc', - private_library=True - ) - -if not bld.env.disable_ntdb: - bld.SAMBA_LIBRARY('util_ntdb', - source='util_ntdb.c', - local_include=False, - public_deps='ntdb talloc samba-util samba-hostconfig', - private_library=True - ) - -bld.SAMBA_LIBRARY('tevent-util', - source='tevent_unix.c tevent_ntstatus.c tevent_werror.c', - local_include=False, - public_deps='tevent errors', - public_headers='tevent_ntstatus.h tevent_unix.h tevent_werror.h', - header_path=[ ('*', 'util') ], - pc_files=[], - vnum='0.0.1' - ) - -bld.SAMBA_LIBRARY('util_setid', - source='setid.c', - local_include=False, - private_library=True - ) - -bld.SAMBA_SUBSYSTEM('util_ldb', - source='util_ldb.c', - local_include=False, - public_deps='ldb', - public_headers='util_ldb.h' - ) - - -bld.SAMBA_SUBSYSTEM('UTIL_RUNCMD', - source='util_runcmd.c', - local_include=False, - public_deps='tevent' - ) - -bld.SAMBA_SUBSYSTEM('UTIL_PW', - source='util_pw.c', - local_include=False, - public_deps='talloc' - ) + bld.SAMBA_LIBRARY('samba-modules', + source='modules.c', + deps='errors samba-util', + local_include=False, + private_library=True) + + bld.SAMBA_LIBRARY('asn1util', + source='asn1.c', + deps='talloc samba-util', + private_library=True, + local_include=False) + + + bld.SAMBA_SUBSYSTEM('UNIX_PRIVS', + source='unix_privs.c', + autoproto='unix_privs.h', + deps='replace talloc', + local_include=False, + ) + + + bld.SAMBA_LIBRARY('util_tdb', + source='util_tdb.c', + local_include=False, + public_deps='tdb talloc', + private_library=True + ) + + if not bld.env.disable_ntdb: + bld.SAMBA_LIBRARY('util_ntdb', + source='util_ntdb.c', + local_include=False, + public_deps='ntdb talloc samba-util samba-hostconfig', + private_library=True + ) + + bld.SAMBA_LIBRARY('tevent-util', + source='tevent_unix.c tevent_ntstatus.c tevent_werror.c', + local_include=False, + public_deps='tevent errors', + public_headers='tevent_ntstatus.h tevent_unix.h tevent_werror.h', + header_path=[ ('*', 'util') ], + pc_files=[], + vnum='0.0.1' + ) + + bld.SAMBA_LIBRARY('util_setid', + source='setid.c', + local_include=False, + private_library=True + ) + + bld.SAMBA_SUBSYSTEM('util_ldb', + source='util_ldb.c', + local_include=False, + public_deps='ldb', + public_headers='util_ldb.h' + ) + + + bld.SAMBA_SUBSYSTEM('UTIL_RUNCMD', + source='util_runcmd.c', + local_include=False, + public_deps='tevent' + ) + + bld.SAMBA_SUBSYSTEM('UTIL_PW', + source='util_pw.c', + local_include=False, + public_deps='talloc' + ) -- 2.1.1 From 37f2039d5d61e82e7bc7abe73531f34682961292 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 22 Sep 2014 20:26:24 +1000 Subject: [PATCH 11/34] lib/util: Use charset_compat.h if SAMBA_UTIL_CORE_ONLY When doing a CTDB standalone build we don't want to use dynconfig, since this introduces a lot of unwanted complexity. To avoid this, either: * charset needs to be nobbled to avoid loading the case tables, since this depends on dynconfig; or * charset needs to be avoid completely, so some functions need to be replaced with their ASCII counterparts. The 2nd options seems more honest and less error-prone. Signed-off-by: Martin Schwenke Reviewed-by: Jeremy Allison (cherry picked from commit c12aa0c444555f2c8051492083abba69fb94586f) --- lib/util/charset_compat.h | 9 +++++++++ lib/util/samba_util.h | 5 +++++ lib/util/substitute.c | 4 ++++ lib/util/wscript_build | 2 ++ 4 files changed, 20 insertions(+) create mode 100644 lib/util/charset_compat.h diff --git a/lib/util/charset_compat.h b/lib/util/charset_compat.h new file mode 100644 index 0000000..cb3b625 --- /dev/null +++ b/lib/util/charset_compat.h @@ -0,0 +1,9 @@ +#ifndef _SAMBA_CHARSET_COMPAT_H_ +#define _SAMBA_CHARSET_COMPAT_H_ + +#include + +#define strchr_m(h, n) strchr(h, n) +#define strstr_m(h, n) strstr(h, n) + +#endif /* _SAMBA_CHARSET_COMPAT_H_ */ diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index 2578af8..41b3fc8 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -21,7 +21,12 @@ #ifndef _SAMBA_UTIL_H_ #define _SAMBA_UTIL_H_ +#ifndef SAMBA_UTIL_CORE_ONLY #include "lib/util/charset/charset.h" +#else +#include "charset_compat.h" +#endif + #include "lib/util/attr.h" /* for TALLOC_CTX */ diff --git a/lib/util/substitute.c b/lib/util/substitute.c index 70cc441..49adeaf 100644 --- a/lib/util/substitute.c +++ b/lib/util/substitute.c @@ -23,7 +23,11 @@ #include "replace.h" #include "debug.h" +#ifndef SAMBA_UTIL_CORE_ONLY #include "charset/charset.h" +#else +#include "charset_compat.h" +#endif #include "substitute.h" /** diff --git a/lib/util/wscript_build b/lib/util/wscript_build index d3865d8..cd23231 100755 --- a/lib/util/wscript_build +++ b/lib/util/wscript_build @@ -41,6 +41,8 @@ bld.SAMBA_SUBSYSTEM('samba-util-core', if not bld.env.SAMBA_UTIL_CORE_ONLY: + bld.env.public_headers_skip.append('charset_compat.h') + bld.SAMBA_LIBRARY('samba-util', source='''talloc_stack.c smb_threads.c rbtree.c rfc1738.c become_daemon.c system.c select.c getpass.c -- 2.1.1 From ca1f4c343003aa56261d781bc0c2c4c657d82615 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 8 Aug 2014 12:51:03 +1000 Subject: [PATCH 12/34] ctdb-logging: Remove log ringbuffer As far as we know, nobody uses this and it just complicates the logging subsystem. Remove all ringbuffer code and documentation. Update the local daemons startup code correspondingly. Signed-off-by: Martin Schwenke Reviewed-by: Volker Lendecke (cherry picked from commit b544073653a5b54ba8ec2621c7314136656cfaeb) --- ctdb/common/ctdb_fork.c | 15 +-- ctdb/common/ctdb_logging.c | 149 --------------------------- ctdb/config/ctdbd_wrapper | 1 - ctdb/doc/ctdb.1.xml | 38 ------- ctdb/doc/ctdbd.1.xml | 19 ---- ctdb/doc/ctdbd.conf.5.xml | 10 -- ctdb/include/ctdb_logging.h | 2 +- ctdb/include/ctdb_private.h | 12 --- ctdb/include/ctdb_protocol.h | 4 +- ctdb/lib/util/debug.h | 1 - ctdb/server/ctdb_control.c | 5 +- ctdb/server/ctdb_logging.c | 42 -------- ctdb/server/ctdb_recoverd.c | 52 +--------- ctdb/server/ctdbd.c | 1 - ctdb/tests/simple/scripts/local_daemons.bash | 2 +- ctdb/tools/ctdb.c | 123 ---------------------- 16 files changed, 8 insertions(+), 468 deletions(-) diff --git a/ctdb/common/ctdb_fork.c b/ctdb/common/ctdb_fork.c index d7eef76..8d38150 100644 --- a/ctdb/common/ctdb_fork.c +++ b/ctdb/common/ctdb_fork.c @@ -54,7 +54,7 @@ void ctdb_track_child(struct ctdb_context *ctdb, pid_t pid) * This function forks a child process and drops the realtime * scheduler for the child process. */ -pid_t ctdb_fork_no_free_ringbuffer(struct ctdb_context *ctdb) +pid_t ctdb_fork(struct ctdb_context *ctdb) { pid_t pid; @@ -95,19 +95,6 @@ pid_t ctdb_fork_no_free_ringbuffer(struct ctdb_context *ctdb) return pid; } -pid_t ctdb_fork(struct ctdb_context *ctdb) -{ - pid_t pid; - - pid = ctdb_fork_no_free_ringbuffer(ctdb); - if (pid == 0) { - ctdb_log_ringbuffer_free(); - } - - return pid; -} - - static void ctdb_sigchld_handler(struct tevent_context *ev, struct tevent_signal *te, int signum, int count, void *dont_care, diff --git a/ctdb/common/ctdb_logging.c b/ctdb/common/ctdb_logging.c index 5390156..1490eef 100644 --- a/ctdb/common/ctdb_logging.c +++ b/ctdb/common/ctdb_logging.c @@ -27,155 +27,6 @@ int LogLevel = DEBUG_NOTICE; int this_log_level = 0; const char *debug_extra = ""; -int log_ringbuf_size; - -#define MAX_LOG_SIZE 128 - -static int first_entry = 0; -static int ringbuf_count = 0; - -struct ctdb_log_entry { - int32_t level; - struct timeval t; - char message[MAX_LOG_SIZE]; -}; - - -static struct ctdb_log_entry *log_entries; - -/* - * this function logs all messages for all levels to a ringbuffer - */ -static void log_ringbuffer_v(const char *format, va_list ap) -{ - int ret; - int next_entry; - - if (log_entries == NULL && log_ringbuf_size != 0) { - /* Hope this works. We cant log anything if it doesnt anyway */ - log_entries = malloc(sizeof(struct ctdb_log_entry) * log_ringbuf_size); - } - if (log_entries == NULL) { - return; - } - - next_entry = (first_entry + ringbuf_count) % log_ringbuf_size; - - if (ringbuf_count > 0 && first_entry == next_entry) { - first_entry = (first_entry + 1) % log_ringbuf_size; - } - - log_entries[next_entry].message[0] = '\0'; - - ret = vsnprintf(&log_entries[next_entry].message[0], MAX_LOG_SIZE, format, ap); - if (ret == -1) { - return; - } - /* Log messages longer than MAX_LOG_SIZE are truncated to MAX_LOG_SIZE-1 - * bytes. In that case, add a newline. - */ - if (ret >= MAX_LOG_SIZE) { - log_entries[next_entry].message[MAX_LOG_SIZE-2] = '\n'; - } - - log_entries[next_entry].level = this_log_level; - log_entries[next_entry].t = timeval_current(); - - if (ringbuf_count < log_ringbuf_size) { - ringbuf_count++; - } -} - -void log_ringbuffer(const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - log_ringbuffer_v(format, ap); - va_end(ap); -} - -void ctdb_log_ringbuffer_free(void) -{ - if (log_entries != NULL) { - free(log_entries); - log_entries = NULL; - } - log_ringbuf_size = 0; -} - -TDB_DATA ctdb_log_ringbuffer_collect_log(TALLOC_CTX *mem_ctx, - enum debug_level max_level) -{ - TDB_DATA data; - FILE *f; - long fsize; - int tmp_entry; - struct tm *tm; - char tbuf[100]; - int i; - - DEBUG(DEBUG_ERR,("Marshalling %d log entries\n", ringbuf_count)); - - /* 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 tdb_null; - } - - for (i=0; i max_level) { - continue; - } - - tm = localtime(&log_entries[tmp_entry].t.tv_sec); - strftime(tbuf, sizeof(tbuf)-1,"%Y/%m/%d %H:%M:%S", tm); - - if (log_entries[tmp_entry].message[0] != '\0') { - fprintf(f, "%s:%s %s", tbuf, - get_debug_by_level(log_entries[tmp_entry].level), - log_entries[tmp_entry].message); - } - } - - fsize = ftell(f); - if (fsize < 0) { - fclose(f); - DEBUG(DEBUG_ERR, ("Cannot get file size for log entries\n")); - return tdb_null; - } - rewind(f); - data.dptr = talloc_size(NULL, fsize); - if (data.dptr == NULL) { - fclose(f); - 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)); - - return data; -} - -void ctdb_clear_log(struct ctdb_context *ctdb) -{ - first_entry = 0; - ringbuf_count = 0; -} - -int32_t ctdb_control_clear_log(struct ctdb_context *ctdb) -{ - ctdb_clear_log(ctdb); - - return 0; -} - struct debug_levels debug_levels[] = { {DEBUG_EMERG, "EMERG"}, {DEBUG_ALERT, "ALERT"}, diff --git a/ctdb/config/ctdbd_wrapper b/ctdb/config/ctdbd_wrapper index cbde6ba..c2c5c1a 100755 --- a/ctdb/config/ctdbd_wrapper +++ b/ctdb/config/ctdbd_wrapper @@ -129,7 +129,6 @@ build_ctdb_options () maybe_set "--no-lmaster" "$CTDB_CAPABILITY_LMASTER" "no" maybe_set "--lvs --single-public-ip" "$CTDB_LVS_PUBLIC_IP" maybe_set "--script-log-level" "$CTDB_SCRIPT_LOG_LEVEL" - maybe_set "--log-ringbuf-size" "$CTDB_LOG_RINGBUF_SIZE" maybe_set "--syslog" "$CTDB_SYSLOG" "yes" maybe_set "--max-persistent-check-errors" "$CTDB_MAX_PERSISTENT_CHECK_ERRORS" } diff --git a/ctdb/doc/ctdb.1.xml b/ctdb/doc/ctdb.1.xml index 87840cd..efa5d85 100644 --- a/ctdb/doc/ctdb.1.xml +++ b/ctdb/doc/ctdb.1.xml @@ -1185,44 +1185,6 @@ dbid:0xb775fff6 name:secrets.tdb path:/var/ctdb/persistent/secrets.tdb.0 PERSIST - getlog [<parameter>LEVEL</parameter>] [recoverd] - - In addition to the normal logging to a log file, CTDB also - keeps a in-memory ringbuffer containing the most recent log - entries for all log levels (except DEBUG). - - - This is useful since it allows for keeping continuous logs to a file - at a reasonable non-verbose level, but shortly after an incident has - occured, a much more detailed log can be pulled from memory. This - can allow you to avoid having to reproduce an issue due to the - on-disk logs being of insufficient detail. - - - This command extracts all messages of level or lower log level - from memory and prints it to the screen. The level is not - specified it defaults to NOTICE. - - - By default, logs are extracted from the main CTDB daemon. If - the recoverd option is given then logs are extracted from the - recovery daemon. - - - - - clearlog [recoverd] - - This command clears the in-memory logging ringbuffer. - - - By default, logs are cleared in the main CTDB daemon. If the - recoverd option is given then logs are cleared in the recovery - daemon. - - - - setdbreadonly <parameter>DB</parameter> This command will enable the read-only record support for a diff --git a/ctdb/doc/ctdbd.1.xml b/ctdb/doc/ctdbd.1.xml index ab222bc..20f2d8b 100644 --- a/ctdb/doc/ctdbd.1.xml +++ b/ctdb/doc/ctdbd.1.xml @@ -137,25 +137,6 @@ - --log-ringbuf-size=NUM - - - Set the size of the log ringbuffer to NUM entries. - - - CTDB uses an in-memory ringbuffer containing NUM most - recent log entries for all log levels (except DEBUG). The - ringbugger can be useful for extracting detailed logs even - if some entries are not logged to the regular logs. - - - Use the ctdb getlog command to retrieve - log entries from the ringbuffer. - - - - - --lvs diff --git a/ctdb/doc/ctdbd.conf.5.xml b/ctdb/doc/ctdbd.conf.5.xml index 149aa62..e316abb 100644 --- a/ctdb/doc/ctdbd.conf.5.xml +++ b/ctdb/doc/ctdbd.conf.5.xml @@ -231,16 +231,6 @@ - CTDB_LOG_RINGBUF_SIZE=NUM - - - Default is 0. Corresponds to - . - - - - - CTDB_LVS_PUBLIC_IP=IPADDR diff --git a/ctdb/include/ctdb_logging.h b/ctdb/include/ctdb_logging.h index 710864e..41bbed5 100644 --- a/ctdb/include/ctdb_logging.h +++ b/ctdb/include/ctdb_logging.h @@ -36,7 +36,7 @@ enum debug_level { }; #define DEBUGLVL(lvl) ((lvl) <= LogLevel) -#define DEBUG(lvl, x) do { this_log_level = (lvl); if ((lvl) < DEBUG_DEBUG) { log_ringbuffer x; } if ((lvl) <= LogLevel) { do_debug x; }} while (0) +#define DEBUG(lvl, x) do { this_log_level = (lvl); if ((lvl) <= LogLevel) { do_debug x; }} while (0) #define DEBUGADD(lvl, x) do { if ((lvl) <= LogLevel) { this_log_level = (lvl); do_debug_add x; }} while (0) #endif /* _CTDB_LOGGING_H_ */ diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 02602e1..3b6bdc7 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -1096,7 +1096,6 @@ void reset_scheduler(void); struct tevent_signal *ctdb_init_sigchld(struct ctdb_context *ctdb); void ctdb_track_child(struct ctdb_context *ctdb, pid_t pid); pid_t ctdb_fork(struct ctdb_context *ctdb); -pid_t ctdb_fork_no_free_ringbuffer(struct ctdb_context *ctdb); void ctdb_set_child_info(TALLOC_CTX *mem_ctx, const char *child_name_fmt, ...); bool ctdb_is_child_process(void); int ctdb_kill(struct ctdb_context *ctdb, pid_t pid, int signum); @@ -1459,17 +1458,6 @@ struct ctdb_get_log_addr { int32_t level; }; -extern int log_ringbuf_size; - -enum debug_level; -TDB_DATA ctdb_log_ringbuffer_collect_log(TALLOC_CTX *mem_ctx, - enum debug_level max_level); -void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr *log_addr); -void ctdb_clear_log(struct ctdb_context *ctdb); -int32_t ctdb_control_get_log(struct ctdb_context *ctdb, TDB_DATA addr); -int32_t ctdb_control_clear_log(struct ctdb_context *ctdb); -void ctdb_log_ringbuffer_free(void); - struct ctdb_log_state *ctdb_vfork_with_logging(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, const char *log_prefix, diff --git a/ctdb/include/ctdb_protocol.h b/ctdb/include/ctdb_protocol.h index 629c91c..61d5735 100644 --- a/ctdb/include/ctdb_protocol.h +++ b/ctdb/include/ctdb_protocol.h @@ -386,8 +386,8 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0, CTDB_CONTROL_REGISTER_NOTIFY = 114, CTDB_CONTROL_DEREGISTER_NOTIFY = 115, CTDB_CONTROL_TRANS2_ACTIVE = 116, /* obsolete */ - CTDB_CONTROL_GET_LOG = 117, - CTDB_CONTROL_CLEAR_LOG = 118, + CTDB_CONTROL_GET_LOG = 117, /* obsolete */ + CTDB_CONTROL_CLEAR_LOG = 118, /* obsolete */ CTDB_CONTROL_TRANS3_COMMIT = 119, CTDB_CONTROL_GET_DB_SEQNUM = 120, CTDB_CONTROL_DB_SET_HEALTHY = 121, diff --git a/ctdb/lib/util/debug.h b/ctdb/lib/util/debug.h index 4902352..a590bc0 100644 --- a/ctdb/lib/util/debug.h +++ b/ctdb/lib/util/debug.h @@ -22,7 +22,6 @@ extern void (*do_debug_v)(const char *, va_list ap); extern void (*do_debug_add_v)(const char *, va_list ap); -void log_ringbuffer(const char *format, ...); void do_debug(const char *format, ...) PRINTF_ATTRIBUTE(1, 2); void do_debug_add(const char *format, ...) PRINTF_ATTRIBUTE(1, 2); void dump_data(int level, const uint8_t *buf1, size_t len); diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c index c350cde..98972ca 100644 --- a/ctdb/server/ctdb_control.c +++ b/ctdb/server/ctdb_control.c @@ -619,11 +619,10 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, return ctdb_control_deregister_notify(ctdb, client_id, indata); case CTDB_CONTROL_GET_LOG: - CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_get_log_addr)); - return ctdb_control_get_log(ctdb, indata); + return control_not_implemented("GET_LOG", NULL); case CTDB_CONTROL_CLEAR_LOG: - return ctdb_control_clear_log(ctdb); + return control_not_implemented("CLEAR_LOG", NULL); case CTDB_CONTROL_GET_DB_SEQNUM: CHECK_CONTROL_DATA_SIZE(sizeof(uint64_t)); diff --git a/ctdb/server/ctdb_logging.c b/ctdb/server/ctdb_logging.c index 9f6f3b5..f46b3bb 100644 --- a/ctdb/server/ctdb_logging.c +++ b/ctdb/server/ctdb_logging.c @@ -643,45 +643,3 @@ int ctdb_init_tevent_logging(struct ctdb_context *ctdb) ctdb); return ret; } - -void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr *log_addr) -{ - TDB_DATA data; - - data = ctdb_log_ringbuffer_collect_log(ctdb, log_addr->level); - - 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); - - if (data.dptr) { - 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); - } - /* do logging here */ - ctdb_collect_log(ctdb, log_addr); - _exit(0); - } - - return 0; -} diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index 945b01c..b817668 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -2340,47 +2340,6 @@ DEBUG(DEBUG_ERR, ("recovery master memory dump\n")); } /* - handler for getlog -*/ -static void getlog_handler(struct ctdb_context *ctdb, uint64_t srvid, - TDB_DATA data, void *private_data) -{ - struct ctdb_get_log_addr *log_addr; - pid_t child; - - if (data.dsize != sizeof(struct ctdb_get_log_addr)) { - DEBUG(DEBUG_ERR, (__location__ " Wrong size of return address.\n")); - return; - } - log_addr = (struct ctdb_get_log_addr *)data.dptr; - - child = ctdb_fork_no_free_ringbuffer(ctdb); - if (child == (pid_t)-1) { - DEBUG(DEBUG_ERR,("Failed to fork a log collector child\n")); - return; - } - - if (child == 0) { - ctdb_set_process_name("ctdb_rec_log_collector"); - if (switch_from_server_to_client(ctdb, "recoverd-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); - } -} - -/* - handler for clearlog -*/ -static void clearlog_handler(struct ctdb_context *ctdb, uint64_t srvid, - TDB_DATA data, void *private_data) -{ - ctdb_clear_log(ctdb); -} - -/* handler for reload_nodes */ static void reload_nodes_handler(struct ctdb_context *ctdb, uint64_t srvid, @@ -4172,12 +4131,6 @@ static void monitor_cluster(struct ctdb_context *ctdb) /* register a message port for sending memory dumps */ ctdb_client_set_message_handler(ctdb, CTDB_SRVID_MEM_DUMP, mem_dump_handler, rec); - /* register a message port for requesting logs */ - ctdb_client_set_message_handler(ctdb, CTDB_SRVID_GETLOG, getlog_handler, rec); - - /* register a message port for clearing logs */ - ctdb_client_set_message_handler(ctdb, CTDB_SRVID_CLEARLOG, clearlog_handler, rec); - /* register a message port for recovery elections */ ctdb_client_set_message_handler(ctdb, CTDB_SRVID_RECOVERY, election_handler, rec); @@ -4308,7 +4261,7 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb) return -1; } - ctdb->recoverd_pid = ctdb_fork_no_free_ringbuffer(ctdb); + ctdb->recoverd_pid = ctdb_fork(ctdb); if (ctdb->recoverd_pid == -1) { return -1; } @@ -4329,9 +4282,6 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb) srandom(getpid() ^ time(NULL)); - /* Clear the log ringbuffer */ - ctdb_clear_log(ctdb); - ctdb_set_process_name("ctdb_recovered"); if (switch_from_server_to_client(ctdb, "recoverd") != 0) { DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch recovery daemon into client mode. shutting down.\n")); diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c index 0b24549..1e5e380 100644 --- a/ctdb/server/ctdbd.c +++ b/ctdb/server/ctdbd.c @@ -134,7 +134,6 @@ int main(int argc, const char *argv[]) { "max-persistent-check-errors", 0, POPT_ARG_INT, &options.max_persistent_check_errors, 0, "max allowed persistent check errors (default 0)", NULL }, - { "log-ringbuf-size", 0, POPT_ARG_INT, &log_ringbuf_size, 0, "Number of log messages we can store in the memory ringbuffer", NULL }, { "sloppy-start", 0, POPT_ARG_NONE, &fast_start, 0, "Do not perform full recovery on start", NULL }, POPT_TABLEEND }; diff --git a/ctdb/tests/simple/scripts/local_daemons.bash b/ctdb/tests/simple/scripts/local_daemons.bash index 5e5e7fd..a227a5d 100644 --- a/ctdb/tests/simple/scripts/local_daemons.bash +++ b/ctdb/tests/simple/scripts/local_daemons.bash @@ -97,7 +97,7 @@ daemons_start_1 () fi local node_ip=$(sed -n -e "$(($pnn + 1))p" "$CTDB_NODES") - local ctdb_options="--sloppy-start --reclock=${TEST_VAR_DIR}/rec.lock --nlist $CTDB_NODES --nopublicipcheck --listen=${node_ip} --event-script-dir=${TEST_VAR_DIR}/events.d --logfile=${TEST_VAR_DIR}/daemon.${pnn}.log -d 3 --log-ringbuf-size=10000 --dbdir=${TEST_VAR_DIR}/test.db --dbdir-persistent=${TEST_VAR_DIR}/test.db/persistent --dbdir-state=${TEST_VAR_DIR}/test.db/state --nosetsched" + local ctdb_options="--sloppy-start --reclock=${TEST_VAR_DIR}/rec.lock --nlist $CTDB_NODES --nopublicipcheck --listen=${node_ip} --event-script-dir=${TEST_VAR_DIR}/events.d --logfile=${TEST_VAR_DIR}/daemon.${pnn}.log -d 3 --dbdir=${TEST_VAR_DIR}/test.db --dbdir-persistent=${TEST_VAR_DIR}/test.db/persistent --dbdir-state=${TEST_VAR_DIR}/test.db/state --nosetsched" if [ $pnn -eq $no_public_ips ] ; then ctdb_options="$ctdb_options --public-addresses=/dev/null" diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index 82783d8..71dfc28 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -4503,127 +4503,6 @@ static int control_chktcpport(struct ctdb_context *ctdb, int argc, const char ** } - -static void log_handler(struct ctdb_context *ctdb, uint64_t srvid, - TDB_DATA data, void *private_data) -{ - DEBUG(DEBUG_ERR,("Log data received\n")); - if (data.dsize > 0) { - printf("%s", data.dptr); - } - - exit(0); -} - -/* - display a list of log messages from the in memory ringbuffer - */ -static int control_getlog(struct ctdb_context *ctdb, int argc, const char **argv) -{ - int ret, i; - bool main_daemon; - struct ctdb_get_log_addr log_addr; - TDB_DATA data; - struct timeval tv; - - /* Process options */ - main_daemon = true; - log_addr.pnn = ctdb_get_pnn(ctdb); - log_addr.level = DEBUG_NOTICE; - for (i = 0; i < argc; i++) { - if (strcmp(argv[i], "recoverd") == 0) { - main_daemon = false; - } else { - if (isalpha(argv[i][0]) || argv[i][0] == '-') { - log_addr.level = get_debug_by_desc(argv[i]); - } else { - log_addr.level = strtol(argv[i], NULL, 0); - } - } - } - - /* Our message port is our PID */ - log_addr.srvid = getpid(); - - data.dptr = (unsigned char *)&log_addr; - data.dsize = sizeof(log_addr); - - DEBUG(DEBUG_ERR, ("Pulling logs from node %u\n", options.pnn)); - - ctdb_client_set_message_handler(ctdb, log_addr.srvid, log_handler, NULL); - sleep(1); - - DEBUG(DEBUG_ERR,("Listen for response on %d\n", (int)log_addr.srvid)); - - if (main_daemon) { - int32_t res; - char *errmsg; - TALLOC_CTX *tmp_ctx = talloc_new(ctdb); - - ret = ctdb_control(ctdb, options.pnn, 0, CTDB_CONTROL_GET_LOG, - 0, data, tmp_ctx, NULL, &res, NULL, &errmsg); - if (ret != 0 || res != 0) { - DEBUG(DEBUG_ERR,("Failed to get logs - %s\n", errmsg)); - talloc_free(tmp_ctx); - return -1; - } - talloc_free(tmp_ctx); - } else { - ret = ctdb_client_send_message(ctdb, options.pnn, - CTDB_SRVID_GETLOG, data); - if (ret != 0) { - DEBUG(DEBUG_ERR,("Failed to send getlog request message to %u\n", options.pnn)); - return -1; - } - } - - tv = timeval_current(); - /* this loop will terminate when we have received the reply */ - while (timeval_elapsed(&tv) < (double)options.timelimit) { - event_loop_once(ctdb->ev); - } - - DEBUG(DEBUG_INFO,("Timed out waiting for log data.\n")); - - return 0; -} - -/* - clear the in memory log area - */ -static int control_clearlog(struct ctdb_context *ctdb, int argc, const char **argv) -{ - int ret; - - if (argc == 0 || (argc >= 1 && strcmp(argv[0], "recoverd") != 0)) { - /* "recoverd" not given - get logs from main daemon */ - int32_t res; - char *errmsg; - TALLOC_CTX *tmp_ctx = talloc_new(ctdb); - - ret = ctdb_control(ctdb, options.pnn, 0, CTDB_CONTROL_CLEAR_LOG, - 0, tdb_null, tmp_ctx, NULL, &res, NULL, &errmsg); - if (ret != 0 || res != 0) { - DEBUG(DEBUG_ERR,("Failed to clear logs\n")); - talloc_free(tmp_ctx); - return -1; - } - - talloc_free(tmp_ctx); - } else { - TDB_DATA data; /* unused in recoverd... */ - data.dsize = 0; - - ret = ctdb_client_send_message(ctdb, options.pnn, CTDB_SRVID_CLEARLOG, data); - if (ret != 0) { - DEBUG(DEBUG_ERR,("Failed to send clearlog request message to %u\n", options.pnn)); - return -1; - } - } - - return 0; -} - /* Reload public IPs on a specified nodes */ static int control_reloadips(struct ctdb_context *ctdb, int argc, const char **argv) { @@ -6356,8 +6235,6 @@ static const struct { { "enablemonitor", control_enable_monmode, true, false, "set monitoring mode to ACTIVE" }, { "setdebug", control_setdebug, true, false, "set debug level", "" }, { "getdebug", control_getdebug, true, false, "get debug level" }, - { "getlog", control_getlog, true, false, "get the log data from the in memory ringbuffer", "[] [recoverd]" }, - { "clearlog", control_clearlog, true, false, "clear the log data from the in memory ringbuffer", "[recoverd]" }, { "attach", control_attach, true, false, "attach to a database", " [persistent]" }, { "detach", control_detach, false, false, "detach from a database", " [ ...]" }, { "dumpmemory", control_dumpmemory, true, false, "dump memory map to stdout" }, -- 2.1.1 From b721a4a25029905bfaeac0bcdbc69c3eae026aa8 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 24 Sep 2014 17:07:12 +1000 Subject: [PATCH 13/34] ctdb-tests: Make the fake log timestamp string easy to modify Use a variable to allow easy change of this string in case future logging changes modify the timestamp format or do not support timestamping. Signed-off-by: Martin Schwenke Reviewed-by: Volker Lendecke (cherry picked from commit 1c8c0be6f97f74169c0b46be4df2245aa631186a) --- ctdb/tests/scripts/unit.sh | 1 + ctdb/tests/takeover/det.001.sh | 14 +- ctdb/tests/takeover/det.002.sh | 8 +- ctdb/tests/takeover/det.003.sh | 2 +- ctdb/tests/takeover/lcp2.004.sh | 12 +- ctdb/tests/takeover/lcp2.005.sh | 334 +++++++++++++------------- ctdb/tests/takeover/lcp2.023.sh | 132 +++++----- ctdb/tests/takeover/lcp2.024.sh | 18 +- ctdb/tests/takeover/lcp2.029.sh | 6 +- ctdb/tests/takeover/lcp2.031.sh | 196 +++++++-------- ctdb/tests/takeover/nondet.001.sh | 12 +- ctdb/tests/takeover/nondet.002.sh | 6 +- ctdb/tests/tool/func.parse_nodestring.003.sh | 2 +- ctdb/tests/tool/stubby.getcapabilities.003.sh | 2 +- ctdb/tests/tool/stubby.listnodes.001.sh | 2 +- ctdb/tests/tool/stubby.lvsmaster.002.sh | 2 +- ctdb/tests/tool/stubby.natgwlist.009.sh | 8 +- ctdb/tests/tool/stubby.xpnn.003.sh | 2 +- 18 files changed, 380 insertions(+), 379 deletions(-) diff --git a/ctdb/tests/scripts/unit.sh b/ctdb/tests/scripts/unit.sh index afa0c1f..4eccada 100644 --- a/ctdb/tests/scripts/unit.sh +++ b/ctdb/tests/scripts/unit.sh @@ -124,6 +124,7 @@ result_filter_default () _date_time_pid='[0-9/][0-9/]*\ [0-9:\.][0-9:\.]*\ \[[\ 0-9][\ 0-9]*\]' sed -e "s@^${_date_time_pid}:@DATE\ TIME\ \[PID\]:@" } +TEST_DATE_STAMP="DATE TIME [PID]: " # Override this function to customise output filtering. result_filter () diff --git a/ctdb/tests/takeover/det.001.sh b/ctdb/tests/takeover/det.001.sh index 2387f12..ead8f21 100755 --- a/ctdb/tests/takeover/det.001.sh +++ b/ctdb/tests/takeover/det.001.sh @@ -5,13 +5,13 @@ define_test "3 nodes, 1 healthy" required_result < all healthy" required_result < all healthy, info logging" export CTDB_TEST_LOGLEVEL=3 required_result < 192.168.20.253 -> 0 [+0] -DATE TIME [PID]: 1 [-105738] -> 192.168.20.251 -> 2 [+0] -DATE TIME [PID]: 1 [-88649] -> 192.168.21.253 -> 0 [+14161] -DATE TIME [PID]: 1 [-75448] -> 192.168.20.254 -> 2 [+15625] -DATE TIME [PID]: 1 [-59823] -> 192.168.20.250 -> 0 [+29786] -DATE TIME [PID]: 1 [-44198] -> 192.168.21.254 -> 2 [+28322] +${TEST_DATE_STAMP}1 [-121363] -> 192.168.20.253 -> 0 [+0] +${TEST_DATE_STAMP}1 [-105738] -> 192.168.20.251 -> 2 [+0] +${TEST_DATE_STAMP}1 [-88649] -> 192.168.21.253 -> 0 [+14161] +${TEST_DATE_STAMP}1 [-75448] -> 192.168.20.254 -> 2 [+15625] +${TEST_DATE_STAMP}1 [-59823] -> 192.168.20.250 -> 0 [+29786] +${TEST_DATE_STAMP}1 [-44198] -> 192.168.21.254 -> 2 [+28322] 192.168.21.254 2 192.168.21.253 0 192.168.21.252 1 diff --git a/ctdb/tests/takeover/lcp2.005.sh b/ctdb/tests/takeover/lcp2.005.sh index 4e0bed8..2ac5652 100755 --- a/ctdb/tests/takeover/lcp2.005.sh +++ b/ctdb/tests/takeover/lcp2.005.sh @@ -7,173 +7,173 @@ define_test "3 nodes, 1 -> all healthy, debug logging" export CTDB_TEST_LOGLEVEL=4 required_result < 192.168.21.254 -> 0 [+0] -DATE TIME [PID]: 1 [-116718] -> 192.168.21.254 -> 2 [+0] -DATE TIME [PID]: 1 [-116971] -> 192.168.21.253 -> 0 [+0] -DATE TIME [PID]: 1 [-116971] -> 192.168.21.253 -> 2 [+0] -DATE TIME [PID]: 1 [-116971] -> 192.168.21.252 -> 0 [+0] -DATE TIME [PID]: 1 [-116971] -> 192.168.21.252 -> 2 [+0] -DATE TIME [PID]: 1 [-121110] -> 192.168.20.254 -> 0 [+0] -DATE TIME [PID]: 1 [-121110] -> 192.168.20.254 -> 2 [+0] -DATE TIME [PID]: 1 [-121363] -> 192.168.20.253 -> 0 [+0] -DATE TIME [PID]: 1 [-121363] -> 192.168.20.253 -> 2 [+0] -DATE TIME [PID]: 1 [-121363] -> 192.168.20.252 -> 0 [+0] -DATE TIME [PID]: 1 [-121363] -> 192.168.20.252 -> 2 [+0] -DATE TIME [PID]: 1 [-121363] -> 192.168.20.251 -> 0 [+0] -DATE TIME [PID]: 1 [-121363] -> 192.168.20.251 -> 2 [+0] -DATE TIME [PID]: 1 [-121363] -> 192.168.20.250 -> 0 [+0] -DATE TIME [PID]: 1 [-121363] -> 192.168.20.250 -> 2 [+0] -DATE TIME [PID]: 1 [-121110] -> 192.168.20.249 -> 0 [+0] -DATE TIME [PID]: 1 [-121110] -> 192.168.20.249 -> 2 [+0] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: 1 [-121363] -> 192.168.20.253 -> 0 [+0] -DATE TIME [PID]: +++++++++++++++++++++++++++++++++++++++++ -DATE TIME [PID]: Selecting most imbalanced node from: -DATE TIME [PID]: 0 [0] -DATE TIME [PID]: 1 [417803] -DATE TIME [PID]: 2 [0] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 1 [417803] -DATE TIME [PID]: 1 [-102557] -> 192.168.21.254 -> 0 [+14161] -DATE TIME [PID]: 1 [-102557] -> 192.168.21.254 -> 2 [+0] -DATE TIME [PID]: 1 [-102810] -> 192.168.21.253 -> 0 [+14161] -DATE TIME [PID]: 1 [-102810] -> 192.168.21.253 -> 2 [+0] -DATE TIME [PID]: 1 [-102810] -> 192.168.21.252 -> 0 [+14161] -DATE TIME [PID]: 1 [-102810] -> 192.168.21.252 -> 2 [+0] -DATE TIME [PID]: 1 [-105234] -> 192.168.20.254 -> 0 [+15876] -DATE TIME [PID]: 1 [-105234] -> 192.168.20.254 -> 2 [+0] -DATE TIME [PID]: 1 [-105234] -> 192.168.20.252 -> 0 [+16129] -DATE TIME [PID]: 1 [-105234] -> 192.168.20.252 -> 2 [+0] -DATE TIME [PID]: 1 [-105738] -> 192.168.20.251 -> 0 [+15625] -DATE TIME [PID]: 1 [-105738] -> 192.168.20.251 -> 2 [+0] -DATE TIME [PID]: 1 [-105738] -> 192.168.20.250 -> 0 [+15625] -DATE TIME [PID]: 1 [-105738] -> 192.168.20.250 -> 2 [+0] -DATE TIME [PID]: 1 [-105485] -> 192.168.20.249 -> 0 [+15625] -DATE TIME [PID]: 1 [-105485] -> 192.168.20.249 -> 2 [+0] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: 1 [-105738] -> 192.168.20.251 -> 2 [+0] -DATE TIME [PID]: +++++++++++++++++++++++++++++++++++++++++ -DATE TIME [PID]: Selecting most imbalanced node from: -DATE TIME [PID]: 0 [0] -DATE TIME [PID]: 1 [312065] -DATE TIME [PID]: 2 [0] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 1 [312065] -DATE TIME [PID]: 1 [-88396] -> 192.168.21.254 -> 0 [+14161] -DATE TIME [PID]: 1 [-88396] -> 192.168.21.254 -> 2 [+14161] -DATE TIME [PID]: 1 [-88649] -> 192.168.21.253 -> 0 [+14161] -DATE TIME [PID]: 1 [-88649] -> 192.168.21.253 -> 2 [+14161] -DATE TIME [PID]: 1 [-88649] -> 192.168.21.252 -> 0 [+14161] -DATE TIME [PID]: 1 [-88649] -> 192.168.21.252 -> 2 [+14161] -DATE TIME [PID]: 1 [-89609] -> 192.168.20.254 -> 0 [+15876] -DATE TIME [PID]: 1 [-89609] -> 192.168.20.254 -> 2 [+15625] -DATE TIME [PID]: 1 [-89609] -> 192.168.20.252 -> 0 [+16129] -DATE TIME [PID]: 1 [-89609] -> 192.168.20.252 -> 2 [+15625] -DATE TIME [PID]: 1 [-89609] -> 192.168.20.250 -> 0 [+15625] -DATE TIME [PID]: 1 [-89609] -> 192.168.20.250 -> 2 [+16129] -DATE TIME [PID]: 1 [-89609] -> 192.168.20.249 -> 0 [+15625] -DATE TIME [PID]: 1 [-89609] -> 192.168.20.249 -> 2 [+15876] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: 1 [-88649] -> 192.168.21.253 -> 0 [+14161] -DATE TIME [PID]: +++++++++++++++++++++++++++++++++++++++++ -DATE TIME [PID]: Selecting most imbalanced node from: -DATE TIME [PID]: 0 [14161] -DATE TIME [PID]: 1 [223416] -DATE TIME [PID]: 2 [0] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 1 [223416] -DATE TIME [PID]: 1 [-72520] -> 192.168.21.254 -> 0 [+30037] -DATE TIME [PID]: 1 [-72520] -> 192.168.21.254 -> 2 [+14161] -DATE TIME [PID]: 1 [-72520] -> 192.168.21.252 -> 0 [+30290] -DATE TIME [PID]: 1 [-72520] -> 192.168.21.252 -> 2 [+14161] -DATE TIME [PID]: 1 [-75448] -> 192.168.20.254 -> 0 [+30037] -DATE TIME [PID]: 1 [-75448] -> 192.168.20.254 -> 2 [+15625] -DATE TIME [PID]: 1 [-75448] -> 192.168.20.252 -> 0 [+30290] -DATE TIME [PID]: 1 [-75448] -> 192.168.20.252 -> 2 [+15625] -DATE TIME [PID]: 1 [-75448] -> 192.168.20.250 -> 0 [+29786] -DATE TIME [PID]: 1 [-75448] -> 192.168.20.250 -> 2 [+16129] -DATE TIME [PID]: 1 [-75448] -> 192.168.20.249 -> 0 [+29786] -DATE TIME [PID]: 1 [-75448] -> 192.168.20.249 -> 2 [+15876] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: 1 [-75448] -> 192.168.20.254 -> 2 [+15625] -DATE TIME [PID]: +++++++++++++++++++++++++++++++++++++++++ -DATE TIME [PID]: Selecting most imbalanced node from: -DATE TIME [PID]: 0 [14161] -DATE TIME [PID]: 1 [147968] -DATE TIME [PID]: 2 [15625] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 1 [147968] -DATE TIME [PID]: 1 [-58359] -> 192.168.21.254 -> 0 [+30037] -DATE TIME [PID]: 1 [-58359] -> 192.168.21.254 -> 2 [+28322] -DATE TIME [PID]: 1 [-58359] -> 192.168.21.252 -> 0 [+30290] -DATE TIME [PID]: 1 [-58359] -> 192.168.21.252 -> 2 [+28322] -DATE TIME [PID]: 1 [-59572] -> 192.168.20.252 -> 0 [+30290] -DATE TIME [PID]: 1 [-59572] -> 192.168.20.252 -> 2 [+31501] -DATE TIME [PID]: 1 [-59823] -> 192.168.20.250 -> 0 [+29786] -DATE TIME [PID]: 1 [-59823] -> 192.168.20.250 -> 2 [+31754] -DATE TIME [PID]: 1 [-59823] -> 192.168.20.249 -> 0 [+29786] -DATE TIME [PID]: 1 [-59823] -> 192.168.20.249 -> 2 [+31501] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: 1 [-59823] -> 192.168.20.250 -> 0 [+29786] -DATE TIME [PID]: +++++++++++++++++++++++++++++++++++++++++ -DATE TIME [PID]: Selecting most imbalanced node from: -DATE TIME [PID]: 0 [43947] -DATE TIME [PID]: 1 [88145] -DATE TIME [PID]: 2 [15625] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 1 [88145] -DATE TIME [PID]: 1 [-44198] -> 192.168.21.254 -> 0 [+44198] -DATE TIME [PID]: 1 [-44198] -> 192.168.21.254 -> 2 [+28322] -DATE TIME [PID]: 1 [-44198] -> 192.168.21.252 -> 0 [+44451] -DATE TIME [PID]: 1 [-44198] -> 192.168.21.252 -> 2 [+28322] -DATE TIME [PID]: 1 [-43947] -> 192.168.20.252 -> 0 [+45915] -DATE TIME [PID]: 1 [-43947] -> 192.168.20.252 -> 2 [+31501] -DATE TIME [PID]: 1 [-43947] -> 192.168.20.249 -> 0 [+45662] -DATE TIME [PID]: 1 [-43947] -> 192.168.20.249 -> 2 [+31501] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: 1 [-44198] -> 192.168.21.254 -> 2 [+28322] -DATE TIME [PID]: +++++++++++++++++++++++++++++++++++++++++ -DATE TIME [PID]: Selecting most imbalanced node from: -DATE TIME [PID]: 0 [43947] -DATE TIME [PID]: 1 [43947] -DATE TIME [PID]: 2 [43947] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 0 [43947] -DATE TIME [PID]: 0 [-28322] -> 192.168.21.253 -> 0 [+28322] -DATE TIME [PID]: 0 [-28322] -> 192.168.21.253 -> 2 [+44198] -DATE TIME [PID]: 0 [-29786] -> 192.168.20.253 -> 0 [+29786] -DATE TIME [PID]: 0 [-29786] -> 192.168.20.253 -> 2 [+45662] -DATE TIME [PID]: 0 [-29786] -> 192.168.20.250 -> 0 [+29786] -DATE TIME [PID]: 0 [-29786] -> 192.168.20.250 -> 2 [+45915] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 1 [43947] -DATE TIME [PID]: 1 [-28322] -> 192.168.21.252 -> 0 [+44451] -DATE TIME [PID]: 1 [-28322] -> 192.168.21.252 -> 2 [+44198] -DATE TIME [PID]: 1 [-29786] -> 192.168.20.252 -> 0 [+45915] -DATE TIME [PID]: 1 [-29786] -> 192.168.20.252 -> 2 [+45662] -DATE TIME [PID]: 1 [-29786] -> 192.168.20.249 -> 0 [+45662] -DATE TIME [PID]: 1 [-29786] -> 192.168.20.249 -> 2 [+45662] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 2 [43947] -DATE TIME [PID]: 2 [-28322] -> 192.168.21.254 -> 0 [+44198] -DATE TIME [PID]: 2 [-28322] -> 192.168.21.254 -> 2 [+28322] -DATE TIME [PID]: 2 [-29786] -> 192.168.20.254 -> 0 [+45662] -DATE TIME [PID]: 2 [-29786] -> 192.168.20.254 -> 2 [+29786] -DATE TIME [PID]: 2 [-29786] -> 192.168.20.251 -> 0 [+45915] -DATE TIME [PID]: 2 [-29786] -> 192.168.20.251 -> 2 [+29786] -DATE TIME [PID]: ---------------------------------------- +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES (UNASSIGNED) +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [0] +${TEST_DATE_STAMP} 1 [539166] +${TEST_DATE_STAMP} 2 [0] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 1 [539166] +${TEST_DATE_STAMP} 1 [-116718] -> 192.168.21.254 -> 0 [+0] +${TEST_DATE_STAMP} 1 [-116718] -> 192.168.21.254 -> 2 [+0] +${TEST_DATE_STAMP} 1 [-116971] -> 192.168.21.253 -> 0 [+0] +${TEST_DATE_STAMP} 1 [-116971] -> 192.168.21.253 -> 2 [+0] +${TEST_DATE_STAMP} 1 [-116971] -> 192.168.21.252 -> 0 [+0] +${TEST_DATE_STAMP} 1 [-116971] -> 192.168.21.252 -> 2 [+0] +${TEST_DATE_STAMP} 1 [-121110] -> 192.168.20.254 -> 0 [+0] +${TEST_DATE_STAMP} 1 [-121110] -> 192.168.20.254 -> 2 [+0] +${TEST_DATE_STAMP} 1 [-121363] -> 192.168.20.253 -> 0 [+0] +${TEST_DATE_STAMP} 1 [-121363] -> 192.168.20.253 -> 2 [+0] +${TEST_DATE_STAMP} 1 [-121363] -> 192.168.20.252 -> 0 [+0] +${TEST_DATE_STAMP} 1 [-121363] -> 192.168.20.252 -> 2 [+0] +${TEST_DATE_STAMP} 1 [-121363] -> 192.168.20.251 -> 0 [+0] +${TEST_DATE_STAMP} 1 [-121363] -> 192.168.20.251 -> 2 [+0] +${TEST_DATE_STAMP} 1 [-121363] -> 192.168.20.250 -> 0 [+0] +${TEST_DATE_STAMP} 1 [-121363] -> 192.168.20.250 -> 2 [+0] +${TEST_DATE_STAMP} 1 [-121110] -> 192.168.20.249 -> 0 [+0] +${TEST_DATE_STAMP} 1 [-121110] -> 192.168.20.249 -> 2 [+0] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}1 [-121363] -> 192.168.20.253 -> 0 [+0] +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [0] +${TEST_DATE_STAMP} 1 [417803] +${TEST_DATE_STAMP} 2 [0] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 1 [417803] +${TEST_DATE_STAMP} 1 [-102557] -> 192.168.21.254 -> 0 [+14161] +${TEST_DATE_STAMP} 1 [-102557] -> 192.168.21.254 -> 2 [+0] +${TEST_DATE_STAMP} 1 [-102810] -> 192.168.21.253 -> 0 [+14161] +${TEST_DATE_STAMP} 1 [-102810] -> 192.168.21.253 -> 2 [+0] +${TEST_DATE_STAMP} 1 [-102810] -> 192.168.21.252 -> 0 [+14161] +${TEST_DATE_STAMP} 1 [-102810] -> 192.168.21.252 -> 2 [+0] +${TEST_DATE_STAMP} 1 [-105234] -> 192.168.20.254 -> 0 [+15876] +${TEST_DATE_STAMP} 1 [-105234] -> 192.168.20.254 -> 2 [+0] +${TEST_DATE_STAMP} 1 [-105234] -> 192.168.20.252 -> 0 [+16129] +${TEST_DATE_STAMP} 1 [-105234] -> 192.168.20.252 -> 2 [+0] +${TEST_DATE_STAMP} 1 [-105738] -> 192.168.20.251 -> 0 [+15625] +${TEST_DATE_STAMP} 1 [-105738] -> 192.168.20.251 -> 2 [+0] +${TEST_DATE_STAMP} 1 [-105738] -> 192.168.20.250 -> 0 [+15625] +${TEST_DATE_STAMP} 1 [-105738] -> 192.168.20.250 -> 2 [+0] +${TEST_DATE_STAMP} 1 [-105485] -> 192.168.20.249 -> 0 [+15625] +${TEST_DATE_STAMP} 1 [-105485] -> 192.168.20.249 -> 2 [+0] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}1 [-105738] -> 192.168.20.251 -> 2 [+0] +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [0] +${TEST_DATE_STAMP} 1 [312065] +${TEST_DATE_STAMP} 2 [0] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 1 [312065] +${TEST_DATE_STAMP} 1 [-88396] -> 192.168.21.254 -> 0 [+14161] +${TEST_DATE_STAMP} 1 [-88396] -> 192.168.21.254 -> 2 [+14161] +${TEST_DATE_STAMP} 1 [-88649] -> 192.168.21.253 -> 0 [+14161] +${TEST_DATE_STAMP} 1 [-88649] -> 192.168.21.253 -> 2 [+14161] +${TEST_DATE_STAMP} 1 [-88649] -> 192.168.21.252 -> 0 [+14161] +${TEST_DATE_STAMP} 1 [-88649] -> 192.168.21.252 -> 2 [+14161] +${TEST_DATE_STAMP} 1 [-89609] -> 192.168.20.254 -> 0 [+15876] +${TEST_DATE_STAMP} 1 [-89609] -> 192.168.20.254 -> 2 [+15625] +${TEST_DATE_STAMP} 1 [-89609] -> 192.168.20.252 -> 0 [+16129] +${TEST_DATE_STAMP} 1 [-89609] -> 192.168.20.252 -> 2 [+15625] +${TEST_DATE_STAMP} 1 [-89609] -> 192.168.20.250 -> 0 [+15625] +${TEST_DATE_STAMP} 1 [-89609] -> 192.168.20.250 -> 2 [+16129] +${TEST_DATE_STAMP} 1 [-89609] -> 192.168.20.249 -> 0 [+15625] +${TEST_DATE_STAMP} 1 [-89609] -> 192.168.20.249 -> 2 [+15876] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}1 [-88649] -> 192.168.21.253 -> 0 [+14161] +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [14161] +${TEST_DATE_STAMP} 1 [223416] +${TEST_DATE_STAMP} 2 [0] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 1 [223416] +${TEST_DATE_STAMP} 1 [-72520] -> 192.168.21.254 -> 0 [+30037] +${TEST_DATE_STAMP} 1 [-72520] -> 192.168.21.254 -> 2 [+14161] +${TEST_DATE_STAMP} 1 [-72520] -> 192.168.21.252 -> 0 [+30290] +${TEST_DATE_STAMP} 1 [-72520] -> 192.168.21.252 -> 2 [+14161] +${TEST_DATE_STAMP} 1 [-75448] -> 192.168.20.254 -> 0 [+30037] +${TEST_DATE_STAMP} 1 [-75448] -> 192.168.20.254 -> 2 [+15625] +${TEST_DATE_STAMP} 1 [-75448] -> 192.168.20.252 -> 0 [+30290] +${TEST_DATE_STAMP} 1 [-75448] -> 192.168.20.252 -> 2 [+15625] +${TEST_DATE_STAMP} 1 [-75448] -> 192.168.20.250 -> 0 [+29786] +${TEST_DATE_STAMP} 1 [-75448] -> 192.168.20.250 -> 2 [+16129] +${TEST_DATE_STAMP} 1 [-75448] -> 192.168.20.249 -> 0 [+29786] +${TEST_DATE_STAMP} 1 [-75448] -> 192.168.20.249 -> 2 [+15876] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}1 [-75448] -> 192.168.20.254 -> 2 [+15625] +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [14161] +${TEST_DATE_STAMP} 1 [147968] +${TEST_DATE_STAMP} 2 [15625] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 1 [147968] +${TEST_DATE_STAMP} 1 [-58359] -> 192.168.21.254 -> 0 [+30037] +${TEST_DATE_STAMP} 1 [-58359] -> 192.168.21.254 -> 2 [+28322] +${TEST_DATE_STAMP} 1 [-58359] -> 192.168.21.252 -> 0 [+30290] +${TEST_DATE_STAMP} 1 [-58359] -> 192.168.21.252 -> 2 [+28322] +${TEST_DATE_STAMP} 1 [-59572] -> 192.168.20.252 -> 0 [+30290] +${TEST_DATE_STAMP} 1 [-59572] -> 192.168.20.252 -> 2 [+31501] +${TEST_DATE_STAMP} 1 [-59823] -> 192.168.20.250 -> 0 [+29786] +${TEST_DATE_STAMP} 1 [-59823] -> 192.168.20.250 -> 2 [+31754] +${TEST_DATE_STAMP} 1 [-59823] -> 192.168.20.249 -> 0 [+29786] +${TEST_DATE_STAMP} 1 [-59823] -> 192.168.20.249 -> 2 [+31501] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}1 [-59823] -> 192.168.20.250 -> 0 [+29786] +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [43947] +${TEST_DATE_STAMP} 1 [88145] +${TEST_DATE_STAMP} 2 [15625] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 1 [88145] +${TEST_DATE_STAMP} 1 [-44198] -> 192.168.21.254 -> 0 [+44198] +${TEST_DATE_STAMP} 1 [-44198] -> 192.168.21.254 -> 2 [+28322] +${TEST_DATE_STAMP} 1 [-44198] -> 192.168.21.252 -> 0 [+44451] +${TEST_DATE_STAMP} 1 [-44198] -> 192.168.21.252 -> 2 [+28322] +${TEST_DATE_STAMP} 1 [-43947] -> 192.168.20.252 -> 0 [+45915] +${TEST_DATE_STAMP} 1 [-43947] -> 192.168.20.252 -> 2 [+31501] +${TEST_DATE_STAMP} 1 [-43947] -> 192.168.20.249 -> 0 [+45662] +${TEST_DATE_STAMP} 1 [-43947] -> 192.168.20.249 -> 2 [+31501] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}1 [-44198] -> 192.168.21.254 -> 2 [+28322] +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [43947] +${TEST_DATE_STAMP} 1 [43947] +${TEST_DATE_STAMP} 2 [43947] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 0 [43947] +${TEST_DATE_STAMP} 0 [-28322] -> 192.168.21.253 -> 0 [+28322] +${TEST_DATE_STAMP} 0 [-28322] -> 192.168.21.253 -> 2 [+44198] +${TEST_DATE_STAMP} 0 [-29786] -> 192.168.20.253 -> 0 [+29786] +${TEST_DATE_STAMP} 0 [-29786] -> 192.168.20.253 -> 2 [+45662] +${TEST_DATE_STAMP} 0 [-29786] -> 192.168.20.250 -> 0 [+29786] +${TEST_DATE_STAMP} 0 [-29786] -> 192.168.20.250 -> 2 [+45915] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 1 [43947] +${TEST_DATE_STAMP} 1 [-28322] -> 192.168.21.252 -> 0 [+44451] +${TEST_DATE_STAMP} 1 [-28322] -> 192.168.21.252 -> 2 [+44198] +${TEST_DATE_STAMP} 1 [-29786] -> 192.168.20.252 -> 0 [+45915] +${TEST_DATE_STAMP} 1 [-29786] -> 192.168.20.252 -> 2 [+45662] +${TEST_DATE_STAMP} 1 [-29786] -> 192.168.20.249 -> 0 [+45662] +${TEST_DATE_STAMP} 1 [-29786] -> 192.168.20.249 -> 2 [+45662] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 2 [43947] +${TEST_DATE_STAMP} 2 [-28322] -> 192.168.21.254 -> 0 [+44198] +${TEST_DATE_STAMP} 2 [-28322] -> 192.168.21.254 -> 2 [+28322] +${TEST_DATE_STAMP} 2 [-29786] -> 192.168.20.254 -> 0 [+45662] +${TEST_DATE_STAMP} 2 [-29786] -> 192.168.20.254 -> 2 [+29786] +${TEST_DATE_STAMP} 2 [-29786] -> 192.168.20.251 -> 0 [+45915] +${TEST_DATE_STAMP} 2 [-29786] -> 192.168.20.251 -> 2 [+29786] +${TEST_DATE_STAMP} ---------------------------------------- 192.168.21.254 2 192.168.21.253 0 192.168.21.252 1 diff --git a/ctdb/tests/takeover/lcp2.023.sh b/ctdb/tests/takeover/lcp2.023.sh index 0f35b3e..c29546e 100755 --- a/ctdb/tests/takeover/lcp2.023.sh +++ b/ctdb/tests/takeover/lcp2.023.sh @@ -7,72 +7,72 @@ define_test "3 nodes, all IPs assigned, 1->3 unhealthy" export CTDB_TEST_LOGLEVEL=4 required_result < 192.168.21.254 -> 1 [+0] -DATE TIME [PID]: 2 [-58359] -> 192.168.21.252 -> 1 [+0] -DATE TIME [PID]: 2 [-59572] -> 192.168.20.253 -> 1 [+0] -DATE TIME [PID]: 2 [-59823] -> 192.168.20.251 -> 1 [+0] -DATE TIME [PID]: 2 [-59823] -> 192.168.20.249 -> 1 [+0] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: 2 [-59823] -> 192.168.20.251 -> 1 [+0] -DATE TIME [PID]: +++++++++++++++++++++++++++++++++++++++++ -DATE TIME [PID]: Selecting most imbalanced node from: -DATE TIME [PID]: 0 [89609] -DATE TIME [PID]: 1 [0] -DATE TIME [PID]: 2 [88145] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 0 [89609] -DATE TIME [PID]: 0 [-42483] -> 192.168.21.253 -> 1 [+14161] -DATE TIME [PID]: 0 [-45662] -> 192.168.20.254 -> 1 [+15625] -DATE TIME [PID]: 0 [-45662] -> 192.168.20.252 -> 1 [+15625] -DATE TIME [PID]: 0 [-45411] -> 192.168.20.250 -> 1 [+16129] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: 0 [-45662] -> 192.168.20.254 -> 1 [+15625] -DATE TIME [PID]: +++++++++++++++++++++++++++++++++++++++++ -DATE TIME [PID]: Selecting most imbalanced node from: -DATE TIME [PID]: 0 [43947] -DATE TIME [PID]: 1 [15625] -DATE TIME [PID]: 2 [88145] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 2 [88145] -DATE TIME [PID]: 2 [-44198] -> 192.168.21.254 -> 1 [+28322] -DATE TIME [PID]: 2 [-44198] -> 192.168.21.252 -> 1 [+28322] -DATE TIME [PID]: 2 [-43947] -> 192.168.20.253 -> 1 [+31501] -DATE TIME [PID]: 2 [-43947] -> 192.168.20.249 -> 1 [+31501] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: 2 [-44198] -> 192.168.21.254 -> 1 [+28322] -DATE TIME [PID]: +++++++++++++++++++++++++++++++++++++++++ -DATE TIME [PID]: Selecting most imbalanced node from: -DATE TIME [PID]: 0 [43947] -DATE TIME [PID]: 1 [43947] -DATE TIME [PID]: 2 [43947] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 0 [43947] -DATE TIME [PID]: 0 [-28322] -> 192.168.21.253 -> 1 [+44198] -DATE TIME [PID]: 0 [-29786] -> 192.168.20.252 -> 1 [+45662] -DATE TIME [PID]: 0 [-29786] -> 192.168.20.250 -> 1 [+45915] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 1 [43947] -DATE TIME [PID]: 1 [-28322] -> 192.168.21.254 -> 1 [+28322] -DATE TIME [PID]: 1 [-29786] -> 192.168.20.254 -> 1 [+29786] -DATE TIME [PID]: 1 [-29786] -> 192.168.20.251 -> 1 [+29786] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 2 [43947] -DATE TIME [PID]: 2 [-28322] -> 192.168.21.252 -> 1 [+44198] -DATE TIME [PID]: 2 [-29786] -> 192.168.20.253 -> 1 [+45662] -DATE TIME [PID]: 2 [-29786] -> 192.168.20.249 -> 1 [+45662] -DATE TIME [PID]: ---------------------------------------- +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES (UNASSIGNED) +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [89609] +${TEST_DATE_STAMP} 1 [0] +${TEST_DATE_STAMP} 2 [147968] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 2 [147968] +${TEST_DATE_STAMP} 2 [-58359] -> 192.168.21.254 -> 1 [+0] +${TEST_DATE_STAMP} 2 [-58359] -> 192.168.21.252 -> 1 [+0] +${TEST_DATE_STAMP} 2 [-59572] -> 192.168.20.253 -> 1 [+0] +${TEST_DATE_STAMP} 2 [-59823] -> 192.168.20.251 -> 1 [+0] +${TEST_DATE_STAMP} 2 [-59823] -> 192.168.20.249 -> 1 [+0] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}2 [-59823] -> 192.168.20.251 -> 1 [+0] +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [89609] +${TEST_DATE_STAMP} 1 [0] +${TEST_DATE_STAMP} 2 [88145] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 0 [89609] +${TEST_DATE_STAMP} 0 [-42483] -> 192.168.21.253 -> 1 [+14161] +${TEST_DATE_STAMP} 0 [-45662] -> 192.168.20.254 -> 1 [+15625] +${TEST_DATE_STAMP} 0 [-45662] -> 192.168.20.252 -> 1 [+15625] +${TEST_DATE_STAMP} 0 [-45411] -> 192.168.20.250 -> 1 [+16129] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}0 [-45662] -> 192.168.20.254 -> 1 [+15625] +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [43947] +${TEST_DATE_STAMP} 1 [15625] +${TEST_DATE_STAMP} 2 [88145] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 2 [88145] +${TEST_DATE_STAMP} 2 [-44198] -> 192.168.21.254 -> 1 [+28322] +${TEST_DATE_STAMP} 2 [-44198] -> 192.168.21.252 -> 1 [+28322] +${TEST_DATE_STAMP} 2 [-43947] -> 192.168.20.253 -> 1 [+31501] +${TEST_DATE_STAMP} 2 [-43947] -> 192.168.20.249 -> 1 [+31501] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}2 [-44198] -> 192.168.21.254 -> 1 [+28322] +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [43947] +${TEST_DATE_STAMP} 1 [43947] +${TEST_DATE_STAMP} 2 [43947] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 0 [43947] +${TEST_DATE_STAMP} 0 [-28322] -> 192.168.21.253 -> 1 [+44198] +${TEST_DATE_STAMP} 0 [-29786] -> 192.168.20.252 -> 1 [+45662] +${TEST_DATE_STAMP} 0 [-29786] -> 192.168.20.250 -> 1 [+45915] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 1 [43947] +${TEST_DATE_STAMP} 1 [-28322] -> 192.168.21.254 -> 1 [+28322] +${TEST_DATE_STAMP} 1 [-29786] -> 192.168.20.254 -> 1 [+29786] +${TEST_DATE_STAMP} 1 [-29786] -> 192.168.20.251 -> 1 [+29786] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 2 [43947] +${TEST_DATE_STAMP} 2 [-28322] -> 192.168.21.252 -> 1 [+44198] +${TEST_DATE_STAMP} 2 [-29786] -> 192.168.20.253 -> 1 [+45662] +${TEST_DATE_STAMP} 2 [-29786] -> 192.168.20.249 -> 1 [+45662] +${TEST_DATE_STAMP} ---------------------------------------- 192.168.21.254 1 192.168.21.253 0 192.168.21.252 2 diff --git a/ctdb/tests/takeover/lcp2.024.sh b/ctdb/tests/takeover/lcp2.024.sh index 0509552..f76bc83 100755 --- a/ctdb/tests/takeover/lcp2.024.sh +++ b/ctdb/tests/takeover/lcp2.024.sh @@ -7,15 +7,15 @@ define_test "3 nodes, no IPs assigned, all healthy, all in STARTUP runstate" export CTDB_TEST_LOGLEVEL=2 required_result < 2 [+9216] -DATE TIME [PID]: 130.216.30.173 -> 2 [+24345] -DATE TIME [PID]: 130.216.30.171 -> 2 [+39970] +${TEST_DATE_STAMP} 10.19.99.251 -> 2 [+9216] +${TEST_DATE_STAMP} 130.216.30.173 -> 2 [+24345] +${TEST_DATE_STAMP} 130.216.30.171 -> 2 [+39970] 130.216.30.181 0 130.216.30.180 1 130.216.30.179 2 diff --git a/ctdb/tests/takeover/lcp2.031.sh b/ctdb/tests/takeover/lcp2.031.sh index 6c5acf9..be10866 100755 --- a/ctdb/tests/takeover/lcp2.031.sh +++ b/ctdb/tests/takeover/lcp2.031.sh @@ -7,104 +7,104 @@ define_test "12+4 IPs, 4 nodes, 3 -> 4 healthy" export CTDB_TEST_LOGLEVEL=4 required_result < 130.216.30.178 -> 0 [+0] -DATE TIME [PID]: 1 [-64566] -> 130.216.30.176 -> 0 [+0] -DATE TIME [PID]: 1 [-64315] -> 130.216.30.175 -> 0 [+0] -DATE TIME [PID]: 1 [-64315] -> 130.216.30.171 -> 0 [+0] -DATE TIME [PID]: 1 [-52489] -> 10.19.99.253 -> 0 [+0] -DATE TIME [PID]: 1 [-52489] -> 10.19.99.250 -> 0 [+0] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: 1 [-64566] -> 130.216.30.178 -> 0 [+0] -DATE TIME [PID]: +++++++++++++++++++++++++++++++++++++++++ -DATE TIME [PID]: Selecting most imbalanced node from: -DATE TIME [PID]: 0 [0] -DATE TIME [PID]: 1 [116804] -DATE TIME [PID]: 2 [128630] -DATE TIME [PID]: 3 [128881] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 3 [128881] -DATE TIME [PID]: 3 [-55099] -> 130.216.30.180 -> 0 [+15625] -DATE TIME [PID]: 3 [-55099] -> 130.216.30.177 -> 0 [+15876] -DATE TIME [PID]: 3 [-55350] -> 130.216.30.174 -> 0 [+15129] -DATE TIME [PID]: 3 [-55350] -> 130.216.30.173 -> 0 [+15129] -DATE TIME [PID]: 3 [-36864] -> 10.19.99.252 -> 0 [+9216] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: 3 [-55350] -> 130.216.30.174 -> 0 [+15129] -DATE TIME [PID]: +++++++++++++++++++++++++++++++++++++++++ -DATE TIME [PID]: Selecting most imbalanced node from: -DATE TIME [PID]: 0 [15129] -DATE TIME [PID]: 1 [116804] -DATE TIME [PID]: 2 [128630] -DATE TIME [PID]: 3 [73531] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 2 [128630] -DATE TIME [PID]: 2 [-55099] -> 130.216.30.181 -> 0 [+30754] -DATE TIME [PID]: 2 [-55099] -> 130.216.30.179 -> 0 [+31258] -DATE TIME [PID]: 2 [-55099] -> 130.216.30.172 -> 0 [+31005] -DATE TIME [PID]: 2 [-55099] -> 130.216.30.170 -> 0 [+30754] -DATE TIME [PID]: 2 [-36864] -> 10.19.99.251 -> 0 [+18432] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: 2 [-55099] -> 130.216.30.181 -> 0 [+30754] -DATE TIME [PID]: +++++++++++++++++++++++++++++++++++++++++ -DATE TIME [PID]: Selecting most imbalanced node from: -DATE TIME [PID]: 0 [45883] -DATE TIME [PID]: 1 [116804] -DATE TIME [PID]: 2 [73531] -DATE TIME [PID]: 3 [73531] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 1 [116804] -DATE TIME [PID]: 1 [-48690] -> 130.216.30.176 -> 0 [+46630] -DATE TIME [PID]: 1 [-49186] -> 130.216.30.175 -> 0 [+46387] -DATE TIME [PID]: 1 [-49186] -> 130.216.30.171 -> 0 [+45883] -DATE TIME [PID]: 1 [-43273] -> 10.19.99.253 -> 0 [+27648] -DATE TIME [PID]: 1 [-43273] -> 10.19.99.250 -> 0 [+27648] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: 1 [-43273] -> 10.19.99.253 -> 0 [+27648] -DATE TIME [PID]: +++++++++++++++++++++++++++++++++++++++++ -DATE TIME [PID]: Selecting most imbalanced node from: -DATE TIME [PID]: 0 [73531] -DATE TIME [PID]: 1 [73531] -DATE TIME [PID]: 2 [73531] -DATE TIME [PID]: 3 [73531] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 0 [73531] -DATE TIME [PID]: 0 [-39970] -> 130.216.30.181 -> 0 [+39970] -DATE TIME [PID]: 0 [-39970] -> 130.216.30.178 -> 0 [+39970] -DATE TIME [PID]: 0 [-39474] -> 130.216.30.174 -> 0 [+39474] -DATE TIME [PID]: 0 [-27648] -> 10.19.99.253 -> 0 [+27648] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 1 [73531] -DATE TIME [PID]: 1 [-39474] -> 130.216.30.176 -> 0 [+55846] -DATE TIME [PID]: 1 [-39970] -> 130.216.30.175 -> 0 [+55603] -DATE TIME [PID]: 1 [-39970] -> 130.216.30.171 -> 0 [+55099] -DATE TIME [PID]: 1 [-27648] -> 10.19.99.250 -> 0 [+43273] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 2 [73531] -DATE TIME [PID]: 2 [-39474] -> 130.216.30.179 -> 0 [+56099] -DATE TIME [PID]: 2 [-39970] -> 130.216.30.172 -> 0 [+55350] -DATE TIME [PID]: 2 [-39970] -> 130.216.30.170 -> 0 [+55099] -DATE TIME [PID]: 2 [-27648] -> 10.19.99.251 -> 0 [+43273] -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: ---------------------------------------- -DATE TIME [PID]: CONSIDERING MOVES FROM 3 [73531] -DATE TIME [PID]: 3 [-39970] -> 130.216.30.180 -> 0 [+56099] -DATE TIME [PID]: 3 [-39970] -> 130.216.30.177 -> 0 [+55846] -DATE TIME [PID]: 3 [-39474] -> 130.216.30.173 -> 0 [+55350] -DATE TIME [PID]: 3 [-27648] -> 10.19.99.252 -> 0 [+43777] -DATE TIME [PID]: ---------------------------------------- +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES (UNASSIGNED) +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [0] +${TEST_DATE_STAMP} 1 [181370] +${TEST_DATE_STAMP} 2 [128630] +${TEST_DATE_STAMP} 3 [128881] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 1 [181370] +${TEST_DATE_STAMP} 1 [-64566] -> 130.216.30.178 -> 0 [+0] +${TEST_DATE_STAMP} 1 [-64566] -> 130.216.30.176 -> 0 [+0] +${TEST_DATE_STAMP} 1 [-64315] -> 130.216.30.175 -> 0 [+0] +${TEST_DATE_STAMP} 1 [-64315] -> 130.216.30.171 -> 0 [+0] +${TEST_DATE_STAMP} 1 [-52489] -> 10.19.99.253 -> 0 [+0] +${TEST_DATE_STAMP} 1 [-52489] -> 10.19.99.250 -> 0 [+0] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}1 [-64566] -> 130.216.30.178 -> 0 [+0] +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [0] +${TEST_DATE_STAMP} 1 [116804] +${TEST_DATE_STAMP} 2 [128630] +${TEST_DATE_STAMP} 3 [128881] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 3 [128881] +${TEST_DATE_STAMP} 3 [-55099] -> 130.216.30.180 -> 0 [+15625] +${TEST_DATE_STAMP} 3 [-55099] -> 130.216.30.177 -> 0 [+15876] +${TEST_DATE_STAMP} 3 [-55350] -> 130.216.30.174 -> 0 [+15129] +${TEST_DATE_STAMP} 3 [-55350] -> 130.216.30.173 -> 0 [+15129] +${TEST_DATE_STAMP} 3 [-36864] -> 10.19.99.252 -> 0 [+9216] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}3 [-55350] -> 130.216.30.174 -> 0 [+15129] +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [15129] +${TEST_DATE_STAMP} 1 [116804] +${TEST_DATE_STAMP} 2 [128630] +${TEST_DATE_STAMP} 3 [73531] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 2 [128630] +${TEST_DATE_STAMP} 2 [-55099] -> 130.216.30.181 -> 0 [+30754] +${TEST_DATE_STAMP} 2 [-55099] -> 130.216.30.179 -> 0 [+31258] +${TEST_DATE_STAMP} 2 [-55099] -> 130.216.30.172 -> 0 [+31005] +${TEST_DATE_STAMP} 2 [-55099] -> 130.216.30.170 -> 0 [+30754] +${TEST_DATE_STAMP} 2 [-36864] -> 10.19.99.251 -> 0 [+18432] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}2 [-55099] -> 130.216.30.181 -> 0 [+30754] +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [45883] +${TEST_DATE_STAMP} 1 [116804] +${TEST_DATE_STAMP} 2 [73531] +${TEST_DATE_STAMP} 3 [73531] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 1 [116804] +${TEST_DATE_STAMP} 1 [-48690] -> 130.216.30.176 -> 0 [+46630] +${TEST_DATE_STAMP} 1 [-49186] -> 130.216.30.175 -> 0 [+46387] +${TEST_DATE_STAMP} 1 [-49186] -> 130.216.30.171 -> 0 [+45883] +${TEST_DATE_STAMP} 1 [-43273] -> 10.19.99.253 -> 0 [+27648] +${TEST_DATE_STAMP} 1 [-43273] -> 10.19.99.250 -> 0 [+27648] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP}1 [-43273] -> 10.19.99.253 -> 0 [+27648] +${TEST_DATE_STAMP}+++++++++++++++++++++++++++++++++++++++++ +${TEST_DATE_STAMP}Selecting most imbalanced node from: +${TEST_DATE_STAMP} 0 [73531] +${TEST_DATE_STAMP} 1 [73531] +${TEST_DATE_STAMP} 2 [73531] +${TEST_DATE_STAMP} 3 [73531] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 0 [73531] +${TEST_DATE_STAMP} 0 [-39970] -> 130.216.30.181 -> 0 [+39970] +${TEST_DATE_STAMP} 0 [-39970] -> 130.216.30.178 -> 0 [+39970] +${TEST_DATE_STAMP} 0 [-39474] -> 130.216.30.174 -> 0 [+39474] +${TEST_DATE_STAMP} 0 [-27648] -> 10.19.99.253 -> 0 [+27648] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 1 [73531] +${TEST_DATE_STAMP} 1 [-39474] -> 130.216.30.176 -> 0 [+55846] +${TEST_DATE_STAMP} 1 [-39970] -> 130.216.30.175 -> 0 [+55603] +${TEST_DATE_STAMP} 1 [-39970] -> 130.216.30.171 -> 0 [+55099] +${TEST_DATE_STAMP} 1 [-27648] -> 10.19.99.250 -> 0 [+43273] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 2 [73531] +${TEST_DATE_STAMP} 2 [-39474] -> 130.216.30.179 -> 0 [+56099] +${TEST_DATE_STAMP} 2 [-39970] -> 130.216.30.172 -> 0 [+55350] +${TEST_DATE_STAMP} 2 [-39970] -> 130.216.30.170 -> 0 [+55099] +${TEST_DATE_STAMP} 2 [-27648] -> 10.19.99.251 -> 0 [+43273] +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} ---------------------------------------- +${TEST_DATE_STAMP} CONSIDERING MOVES FROM 3 [73531] +${TEST_DATE_STAMP} 3 [-39970] -> 130.216.30.180 -> 0 [+56099] +${TEST_DATE_STAMP} 3 [-39970] -> 130.216.30.177 -> 0 [+55846] +${TEST_DATE_STAMP} 3 [-39474] -> 130.216.30.173 -> 0 [+55350] +${TEST_DATE_STAMP} 3 [-27648] -> 10.19.99.252 -> 0 [+43777] +${TEST_DATE_STAMP} ---------------------------------------- 130.216.30.181 0 130.216.30.180 3 130.216.30.179 2 diff --git a/ctdb/tests/takeover/nondet.001.sh b/ctdb/tests/takeover/nondet.001.sh index 6f79c34..5f838ee 100755 --- a/ctdb/tests/takeover/nondet.001.sh +++ b/ctdb/tests/takeover/nondet.001.sh @@ -5,12 +5,12 @@ define_test "3 nodes, 1 healthy" required_result < Date: Wed, 24 Sep 2014 17:12:56 +1000 Subject: [PATCH 14/34] ctdb-logging: Change LogLevel to DEBUGLEVEL For compatibility with current Samba debug.[ch]. Signed-off-by: Martin Schwenke Reviewed-by: Volker Lendecke (cherry picked from commit 3105737c4b38b3cb4f9408cfc82cf8b49bc3fb2e) --- ctdb/common/cmdline.c | 8 ++++---- ctdb/common/ctdb_logging.c | 2 +- ctdb/ib/ibwrapper_test.c | 6 +++--- ctdb/include/ctdb_logging.h | 8 ++++---- ctdb/server/ctdb_control.c | 6 +++--- ctdb/server/ctdb_logging.c | 4 ++-- ctdb/server/ctdb_recoverd.c | 2 +- ctdb/tests/scripts/unit.sh | 2 +- ctdb/tests/src/ctdb_functest.c | 4 ++-- ctdb/tests/src/ctdb_porting_tests.c | 2 +- ctdb/tests/src/ctdb_takeover_tests.c | 4 ++-- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/ctdb/common/cmdline.c b/ctdb/common/cmdline.c index ebe68e4..ab2b45e 100644 --- a/ctdb/common/cmdline.c +++ b/ctdb/common/cmdline.c @@ -97,9 +97,9 @@ struct ctdb_context *ctdb_cmdline_init(struct event_context *ev) /* Set the debug level */ if (isalpha(ctdb_cmdline.debuglevel[0]) || ctdb_cmdline.debuglevel[0] == '-') { - LogLevel = get_debug_by_desc(ctdb_cmdline.debuglevel); + DEBUGLEVEL = get_debug_by_desc(ctdb_cmdline.debuglevel); } else { - LogLevel = strtol(ctdb_cmdline.debuglevel, NULL, 0); + DEBUGLEVEL = strtol(ctdb_cmdline.debuglevel, NULL, 0); } /* set up the tree to store server ids */ @@ -148,9 +148,9 @@ struct ctdb_context *ctdb_cmdline_client(struct tevent_context *ev, /* Set the debug level */ if (isalpha(ctdb_cmdline.debuglevel[0]) || ctdb_cmdline.debuglevel[0] == '-') { - LogLevel = get_debug_by_desc(ctdb_cmdline.debuglevel); + DEBUGLEVEL = get_debug_by_desc(ctdb_cmdline.debuglevel); } else { - LogLevel = strtol(ctdb_cmdline.debuglevel, NULL, 0); + DEBUGLEVEL = strtol(ctdb_cmdline.debuglevel, NULL, 0); } ret = ctdb_socket_connect(ctdb); diff --git a/ctdb/common/ctdb_logging.c b/ctdb/common/ctdb_logging.c index 1490eef..bf67f09 100644 --- a/ctdb/common/ctdb_logging.c +++ b/ctdb/common/ctdb_logging.c @@ -23,7 +23,7 @@ #include "../include/ctdb_private.h" #include "../include/ctdb_client.h" -int LogLevel = DEBUG_NOTICE; +int DEBUGLEVEL = DEBUG_NOTICE; int this_log_level = 0; const char *debug_extra = ""; diff --git a/ctdb/ib/ibwrapper_test.c b/ctdb/ib/ibwrapper_test.c index 48162c3..397fdf1 100644 --- a/ctdb/ib/ibwrapper_test.c +++ b/ctdb/ib/ibwrapper_test.c @@ -537,7 +537,7 @@ void ibwtest_usage(struct ibwtest_ctx *tcx, char *name) printf("\t-n number of messages to send [default %d]\n", tcx->nmsg); printf("\t-l usec time to sleep in the main loop [default %d]\n", tcx->sleep_usec); printf("\t-v max variable msg size in bytes [default %d], 0=don't send var. size\n", tcx->maxsize); - printf("\t-d LogLevel [default %d]\n", LogLevel); + printf("\t-d LogLevel [default %d]\n", DEBUGLEVEL); printf("Press ctrl+C to stop the program.\n"); } @@ -553,7 +553,7 @@ int main(int argc, char *argv[]) memset(tcx, 0, sizeof(struct ibwtest_ctx)); tcx->nsec = 0; tcx->nmsg = 1000; - LogLevel = 0; + DEBUGLEVEL = 0; /* here is the only case we can't avoid using global... */ testctx = tcx; @@ -592,7 +592,7 @@ int main(int argc, char *argv[]) tcx->maxsize = (unsigned int)atoi(optarg); break; case 'd': - LogLevel = atoi(optarg); + DEBUGLEVEL = atoi(optarg); break; default: fprintf(stderr, "ERROR: unknown option -%c\n", (char)op); diff --git a/ctdb/include/ctdb_logging.h b/ctdb/include/ctdb_logging.h index 41bbed5..f6f904a 100644 --- a/ctdb/include/ctdb_logging.h +++ b/ctdb/include/ctdb_logging.h @@ -20,7 +20,7 @@ #ifndef _CTDB_LOGGING_H_ #define _CTDB_LOGGING_H_ -extern int LogLevel; +extern int DEBUGLEVEL; extern int this_log_level; extern const char *debug_extra; @@ -35,8 +35,8 @@ enum debug_level { DEBUG_DEBUG = 4, }; -#define DEBUGLVL(lvl) ((lvl) <= LogLevel) -#define DEBUG(lvl, x) do { this_log_level = (lvl); if ((lvl) <= LogLevel) { do_debug x; }} while (0) -#define DEBUGADD(lvl, x) do { if ((lvl) <= LogLevel) { this_log_level = (lvl); do_debug_add x; }} while (0) +#define DEBUGLVL(lvl) ((lvl) <= DEBUGLEVEL) +#define DEBUG(lvl, x) do { this_log_level = (lvl); if ((lvl) <= DEBUGLEVEL) { do_debug x; }} while (0) +#define DEBUGADD(lvl, x) do { if ((lvl) <= DEBUGLEVEL) { this_log_level = (lvl); do_debug_add x; }} while (0) #endif /* _CTDB_LOGGING_H_ */ diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c index 98972ca..49bc986 100644 --- a/ctdb/server/ctdb_control.c +++ b/ctdb/server/ctdb_control.c @@ -108,14 +108,14 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, case CTDB_CONTROL_SET_DEBUG: { CHECK_CONTROL_DATA_SIZE(sizeof(int32_t)); - LogLevel = *(int32_t *)indata.dptr; + DEBUGLEVEL = *(int32_t *)indata.dptr; return 0; } case CTDB_CONTROL_GET_DEBUG: { CHECK_CONTROL_DATA_SIZE(0); - outdata->dptr = (uint8_t *)&LogLevel; - outdata->dsize = sizeof(LogLevel); + outdata->dptr = (uint8_t *)&(DEBUGLEVEL); + outdata->dsize = sizeof(DEBUGLEVEL); return 0; } diff --git a/ctdb/server/ctdb_logging.c b/ctdb/server/ctdb_logging.c index f46b3bb..97cc3be 100644 --- a/ctdb/server/ctdb_logging.c +++ b/ctdb/server/ctdb_logging.c @@ -397,7 +397,7 @@ int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile, bool use_sy static void write_to_log(struct ctdb_log_state *log, const char *buf, unsigned int len) { - if (script_log_level <= LogLevel) { + if (script_log_level <= DEBUGLEVEL) { if (log != NULL && log->prefix != NULL) { do_debug("%s: %*.*s\n", log->prefix, len, len, buf); } else { @@ -628,7 +628,7 @@ static void ctdb_tevent_logging(void *private_data, break; } - if (lvl <= LogLevel) { + if (lvl <= DEBUGLEVEL) { this_log_level = lvl; do_debug_v(fmt, ap); } diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index b817668..fd07e64 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -3553,7 +3553,7 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec, DEBUG(DEBUG_ERR, (__location__ " Failed to read debuglevel from parent\n")); return; } - LogLevel = debug_level; + DEBUGLEVEL = debug_level; /* get relevant tunables */ ret = ctdb_ctrl_get_all_tunables(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, &ctdb->tunable); diff --git a/ctdb/tests/scripts/unit.sh b/ctdb/tests/scripts/unit.sh index 4eccada..38b7e21 100644 --- a/ctdb/tests/scripts/unit.sh +++ b/ctdb/tests/scripts/unit.sh @@ -124,7 +124,7 @@ result_filter_default () _date_time_pid='[0-9/][0-9/]*\ [0-9:\.][0-9:\.]*\ \[[\ 0-9][\ 0-9]*\]' sed -e "s@^${_date_time_pid}:@DATE\ TIME\ \[PID\]:@" } -TEST_DATE_STAMP="DATE TIME [PID]: " +TEST_DATE_STAMP="" # Override this function to customise output filtering. result_filter () diff --git a/ctdb/tests/src/ctdb_functest.c b/ctdb/tests/src/ctdb_functest.c index 16ca4fd..9eaae55 100644 --- a/ctdb/tests/src/ctdb_functest.c +++ b/ctdb/tests/src/ctdb_functest.c @@ -162,9 +162,9 @@ static void usage(void) int main(int argc, const char *argv[]) { - LogLevel = DEBUG_DEBUG; + DEBUGLEVEL = DEBUG_DEBUG; if (getenv("CTDB_TEST_LOGLEVEL")) { - LogLevel = atoi(getenv("CTDB_TEST_LOGLEVEL")); + DEBUGLEVEL = atoi(getenv("CTDB_TEST_LOGLEVEL")); } if (argc < 2) { diff --git a/ctdb/tests/src/ctdb_porting_tests.c b/ctdb/tests/src/ctdb_porting_tests.c index bd78361..e95c25d 100644 --- a/ctdb/tests/src/ctdb_porting_tests.c +++ b/ctdb/tests/src/ctdb_porting_tests.c @@ -264,7 +264,7 @@ int main(int argc, const char *argv[]) int extra_argc = 0; poptContext pc; - LogLevel = DEBUG_INFO; + DEBUGLEVEL = DEBUG_INFO; pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST); diff --git a/ctdb/tests/src/ctdb_takeover_tests.c b/ctdb/tests/src/ctdb_takeover_tests.c index 04b49e8..8b07325 100644 --- a/ctdb/tests/src/ctdb_takeover_tests.c +++ b/ctdb/tests/src/ctdb_takeover_tests.c @@ -598,9 +598,9 @@ static void usage(void) int main(int argc, const char *argv[]) { - LogLevel = DEBUG_DEBUG; + DEBUGLEVEL = DEBUG_DEBUG; if (getenv("CTDB_TEST_LOGLEVEL")) { - LogLevel = atoi(getenv("CTDB_TEST_LOGLEVEL")); + DEBUGLEVEL = atoi(getenv("CTDB_TEST_LOGLEVEL")); } if (argc < 2) { -- 2.1.1 From e2c1b72f7ecc3fc10cdc2ac30d9afa5b52dedea9 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Tue, 19 Aug 2014 12:15:31 +1000 Subject: [PATCH 15/34] ctdb-logging: Update to use Samba style debug.h/debug.c Samba's debug subsystem has changed a lot, so CTDB's logging needs to be rewritten to be compatible. The new debug.h/debug.c can't just be pulled in because it has some extra dependencies into Samba's lib/util. For now, to support the smallest possible patch, implement a minimal subset of Samba's debug.[ch] that just supports the DEBUG_CALLBACK logtype. Define a callback for each logging method. Check later to see if debug_extra (or similar) can somehow be implemented using debug classes. The timestamp on CTDB CLI tool and test program DEBUG() output goes away, so update the unit test code to cope. Signed-off-by: Martin Schwenke Reviewed-by: Volker Lendecke (cherry picked from commit b4589b954e1090a934fafd3f8e3c2cf1ed785c61) --- ctdb/common/ctdb_logging.c | 2 - ctdb/include/ctdb_logging.h | 6 --- ctdb/lib/tdb_wrap/tdb_wrap.c | 15 ++++-- ctdb/lib/util/debug.c | 120 ++++++++++++++++++------------------------- ctdb/lib/util/debug.h | 18 +++++-- ctdb/server/ctdb_logging.c | 77 ++++++--------------------- 6 files changed, 92 insertions(+), 146 deletions(-) diff --git a/ctdb/common/ctdb_logging.c b/ctdb/common/ctdb_logging.c index bf67f09..9b5103a 100644 --- a/ctdb/common/ctdb_logging.c +++ b/ctdb/common/ctdb_logging.c @@ -23,8 +23,6 @@ #include "../include/ctdb_private.h" #include "../include/ctdb_client.h" -int DEBUGLEVEL = DEBUG_NOTICE; -int this_log_level = 0; const char *debug_extra = ""; struct debug_levels debug_levels[] = { diff --git a/ctdb/include/ctdb_logging.h b/ctdb/include/ctdb_logging.h index f6f904a..c0c0266 100644 --- a/ctdb/include/ctdb_logging.h +++ b/ctdb/include/ctdb_logging.h @@ -20,8 +20,6 @@ #ifndef _CTDB_LOGGING_H_ #define _CTDB_LOGGING_H_ -extern int DEBUGLEVEL; -extern int this_log_level; extern const char *debug_extra; enum debug_level { @@ -35,8 +33,4 @@ enum debug_level { DEBUG_DEBUG = 4, }; -#define DEBUGLVL(lvl) ((lvl) <= DEBUGLEVEL) -#define DEBUG(lvl, x) do { this_log_level = (lvl); if ((lvl) <= DEBUGLEVEL) { do_debug x; }} while (0) -#define DEBUGADD(lvl, x) do { if ((lvl) <= DEBUGLEVEL) { this_log_level = (lvl); do_debug_add x; }} while (0) - #endif /* _CTDB_LOGGING_H_ */ diff --git a/ctdb/lib/tdb_wrap/tdb_wrap.c b/ctdb/lib/tdb_wrap/tdb_wrap.c index f39ac7a..57f8efc 100644 --- a/ctdb/lib/tdb_wrap/tdb_wrap.c +++ b/ctdb/lib/tdb_wrap/tdb_wrap.c @@ -50,12 +50,19 @@ static void log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const ch { if (level <= TDB_DEBUG_ERROR) { va_list ap; - char newfmt[strlen(tdb_name(tdb)) + 1 + strlen(fmt) + 1]; - this_log_level = level; - sprintf(newfmt, "%s:%s", tdb_name(tdb), fmt); + char *ptr = NULL; + int ret; + va_start(ap, fmt); - do_debug_v(newfmt, ap); + ret = vasprintf(&ptr, fmt, ap); va_end(ap); + + if (ret != -1) { + const char *name = tdb_name(tdb); + DEBUG(level, + ("%s:%s", name ? name : "unnamed tdb", ptr)); + free(ptr); + } } } diff --git a/ctdb/lib/util/debug.c b/ctdb/lib/util/debug.c index 40dda1a..e159444 100644 --- a/ctdb/lib/util/debug.c +++ b/ctdb/lib/util/debug.c @@ -17,78 +17,13 @@ along with this program; if not, see . */ -#include "includes.h" -#include "system/time.h" -#include +#include "replace.h" +#include "system/filesys.h" #include +#include +#include "debug.h" -static void _do_debug_v(const char *format, va_list ap) -{ - struct timeval t; - char *s = NULL; - struct tm *tm; - char tbuf[100]; - int ret; - - ret = vasprintf(&s, format, ap); - if (ret == -1) { - fprintf(stderr, "vasprintf failed in _do_debug_v, cannot print debug message.\n"); - fflush(stderr); - return; - } - - t = timeval_current(); - tm = localtime(&t.tv_sec); - - strftime(tbuf,sizeof(tbuf)-1,"%Y/%m/%d %H:%M:%S", tm); - - fprintf(stderr, "%s.%06u [%s%5u]: %s", tbuf, (unsigned)t.tv_usec, - debug_extra, (unsigned)getpid(), s); - fflush(stderr); - free(s); -} - -/* default logging function */ -void (*do_debug_v)(const char *, va_list ap) = _do_debug_v; - -void do_debug(const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - do_debug_v(format, ap); - va_end(ap); -} - - -static void _do_debug_add_v(const char *format, va_list ap) -{ - char *s = NULL; - int ret; - - ret = vasprintf(&s, format, ap); - if (ret == -1) { - fprintf(stderr, "vasprintf failed in _do_debug_add_v, cannot print debug message.\n"); - fflush(stderr); - return; - } - - fprintf(stderr, "%s", s); - fflush(stderr); - free(s); -} - -/* default logging function */ -void (*do_debug_add_v)(const char *, va_list ap) = _do_debug_add_v; - -void do_debug_add(const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - do_debug_add_v(format, ap); - va_end(ap); -} +int DEBUGLEVEL; static void print_asc(int level, const uint8_t *buf, size_t len) { @@ -133,3 +68,48 @@ void dump_data(int level, const uint8_t *buf, size_t len) DEBUG(level, (__location__ " dump data of size %i finished\n", (int)len)); } +/* state variables for the debug system */ +static struct { + debug_callback_fn callback; + void *callback_private; +} state; + +static int current_msg_level = 0; + +void debug_set_callback(void *private_ptr, debug_callback_fn fn) +{ + assert(fn != NULL); + + state.callback_private = private_ptr; + state.callback = fn; +} + +bool dbghdr(int level, const char *location, const char *func) +{ + current_msg_level = level; + return true; +} + +bool dbgtext( const char *format_str, ... ) +{ + va_list ap; + char *msgbuf = NULL; + int res; + + va_start(ap, format_str); + res = vasprintf(&msgbuf, format_str, ap); + va_end(ap); + if (res == -1) { + return false; + } + + if (state.callback != NULL) { + state.callback(state.callback_private, + current_msg_level, msgbuf); + } else { + write(2, msgbuf, strlen(msgbuf)); + } + + free(msgbuf); + return true; +} diff --git a/ctdb/lib/util/debug.h b/ctdb/lib/util/debug.h index a590bc0..ac5e2c7 100644 --- a/ctdb/lib/util/debug.h +++ b/ctdb/lib/util/debug.h @@ -20,10 +20,20 @@ #ifndef UTIL_DEBUG_H #define UTIL_DEBUG_H -extern void (*do_debug_v)(const char *, va_list ap); -extern void (*do_debug_add_v)(const char *, va_list ap); -void do_debug(const char *format, ...) PRINTF_ATTRIBUTE(1, 2); -void do_debug_add(const char *format, ...) PRINTF_ATTRIBUTE(1, 2); +bool dbgtext( const char *, ... ) PRINTF_ATTRIBUTE(1,2); +bool dbghdr( int level, const char *location, const char *func); void dump_data(int level, const uint8_t *buf1, size_t len); +extern int DEBUGLEVEL; + +#define DEBUGLVL(lvl) ((lvl) <= DEBUGLEVEL) +#define DEBUG( lvl, body ) \ + (void)( ((lvl) <= DEBUGLEVEL) \ + && (dbghdr( lvl, __location__, __FUNCTION__ )) \ + && (dbgtext body) ) +#define DEBUGADD(lvl, body) DEBUG(lvl, body) + +typedef void (*debug_callback_fn)(void *private_ptr, int level, const char *msg); +void debug_set_callback(void *private_ptr, debug_callback_fn fn); + #endif /* UTIL_DEBUG_H */ diff --git a/ctdb/server/ctdb_logging.c b/ctdb/server/ctdb_logging.c index 97cc3be..3aba37b 100644 --- a/ctdb/server/ctdb_logging.c +++ b/ctdb/server/ctdb_logging.c @@ -23,6 +23,7 @@ #include "system/syslog.h" #include "system/time.h" #include "system/filesys.h" +#include "lib/util/debug.h" struct syslog_message { uint32_t level; @@ -208,21 +209,15 @@ static struct ctdb_log_state *log_state; /* syslog logging function */ -static void ctdb_syslog_log(const char *format, va_list ap) +static void ctdb_syslog_log(void *private_ptr, int dbglevel, const char *s) { struct syslog_message *msg; int level = LOG_DEBUG; - char *s = NULL; - int len, ret; + int len; int syslog_fd; struct sockaddr_in syslog_sin; - ret = vasprintf(&s, format, ap); - if (ret == -1) { - return; - } - - switch (this_log_level) { + switch (dbglevel) { case DEBUG_EMERG: level = LOG_EMERG; break; @@ -252,7 +247,6 @@ static void ctdb_syslog_log(const char *format, va_list ap) len = offsetof(struct syslog_message, message) + strlen(debug_extra) + strlen(s) + 1; msg = malloc(len); if (msg == NULL) { - free(s); return; } msg->level = level; @@ -266,7 +260,6 @@ static void ctdb_syslog_log(const char *format, va_list ap) syslog_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (syslog_fd == -1) { printf("Failed to create syslog socket\n"); - free(s); free(msg); return; } @@ -275,15 +268,14 @@ static void ctdb_syslog_log(const char *format, va_list ap) syslog_sin.sin_port = htons(CTDB_PORT); syslog_sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - ret = sendto(syslog_fd, msg, len, 0, - (struct sockaddr *)&syslog_sin, - sizeof(syslog_sin)); + (void) sendto(syslog_fd, msg, len, 0, + (struct sockaddr *)&syslog_sin, + sizeof(syslog_sin)); /* no point in checking here since we cant log an error */ close(syslog_fd); } - free(s); free(msg); } @@ -291,23 +283,14 @@ static void ctdb_syslog_log(const char *format, va_list ap) /* log file logging function */ -static void ctdb_logfile_log(const char *format, va_list ap) +static void ctdb_logfile_log(void *private_ptr, int dbglevel, const char *s) { struct timeval t; - char *s = NULL; struct tm *tm; char tbuf[100]; char *s2 = NULL; int ret; - ret = vasprintf(&s, format, ap); - if (ret == -1) { - const char *errstr = "vasprintf failed\n"; - - sys_write(log_state->fd, errstr, strlen(errstr)); - return; - } - t = timeval_current(); tm = localtime(&t.tv_sec); @@ -316,7 +299,6 @@ static void ctdb_logfile_log(const char *format, va_list ap) ret = asprintf(&s2, "%s.%06u [%s%5u]: %s", tbuf, (unsigned)t.tv_usec, debug_extra, (unsigned)getpid(), s); - free(s); if (ret == -1) { const char *errstr = "asprintf failed\n"; sys_write(log_state->fd, errstr, strlen(errstr)); @@ -328,32 +310,12 @@ static void ctdb_logfile_log(const char *format, va_list ap) } } -static void ctdb_logfile_log_add(const char *format, va_list ap) -{ - char *s = NULL; - int ret; - - ret = vasprintf(&s, format, ap); - if (ret == -1) { - const char *errstr = "vasprintf failed\n"; - - sys_write(log_state->fd, errstr, strlen(errstr)); - return; - } - - if (s) { - sys_write(log_state->fd, s, strlen(s)); - free(s); - } -} - - - /* choose the logfile location */ int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile, bool use_syslog) { + debug_callback_fn callback; int ret; ctdb->log = talloc_zero(ctdb, struct ctdb_log_state); @@ -366,12 +328,10 @@ int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile, bool use_sy log_state = ctdb->log; if (use_syslog) { - do_debug_v = ctdb_syslog_log; - do_debug_add_v = ctdb_syslog_log; + callback = ctdb_syslog_log; ctdb->log->use_syslog = true; } else if (logfile == NULL || strcmp(logfile, "-") == 0) { - do_debug_v = ctdb_logfile_log; - do_debug_add_v = ctdb_logfile_log_add; + callback = ctdb_logfile_log; ctdb->log->fd = 1; /* also catch stderr of subcommands to stdout */ ret = dup2(1, 2); @@ -380,8 +340,7 @@ int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile, bool use_sy abort(); } } else { - do_debug_v = ctdb_logfile_log; - do_debug_add_v = ctdb_logfile_log_add; + callback = ctdb_logfile_log; ctdb->log->fd = open(logfile, O_WRONLY|O_APPEND|O_CREAT, 0666); if (ctdb->log->fd == -1) { @@ -390,6 +349,8 @@ int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile, bool use_sy } } + debug_set_callback(NULL, callback); + return 0; } @@ -399,9 +360,9 @@ static void write_to_log(struct ctdb_log_state *log, { if (script_log_level <= DEBUGLEVEL) { if (log != NULL && log->prefix != NULL) { - do_debug("%s: %*.*s\n", log->prefix, len, len, buf); + dbgtext("%s: %*.*s\n", log->prefix, len, len, buf); } else { - do_debug("%*.*s\n", len, len, buf); + dbgtext("%*.*s\n", len, len, buf); } /* log it in the eventsystem as well */ if (log && log->logfn) { @@ -435,8 +396,6 @@ static void ctdb_log_handler(struct event_context *ev, struct fd_event *fde, return; } - this_log_level = script_log_level; - while (log->buf_used > 0 && (p = memchr(log->buf, '\n', log->buf_used)) != NULL) { int n1 = (p - log->buf)+1; @@ -462,7 +421,6 @@ static int log_context_destructor(struct ctdb_log_state *log) { /* Flush buffer in case it wasn't \n-terminated. */ if (log->buf_used > 0) { - this_log_level = script_log_level; write_to_log(log, log->buf, log->buf_used); } return 0; @@ -629,8 +587,7 @@ static void ctdb_tevent_logging(void *private_data, } if (lvl <= DEBUGLEVEL) { - this_log_level = lvl; - do_debug_v(fmt, ap); + dbgtext(fmt, ap); } } -- 2.1.1 From 3f7ed0d5107c845005d06f1ee57b7c370a36244a Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 25 Aug 2014 13:21:12 +1000 Subject: [PATCH 16/34] ctdb-build: Move generation of ctdb_version.h earlier Signed-off-by: Martin Schwenke Reviewed-by: Volker Lendecke (cherry picked from commit ba3e2ecf6728ecb83afbaccaed35d19e4e562806) --- ctdb/wscript | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ctdb/wscript b/ctdb/wscript index 895fcc6..97cd84c 100755 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -196,6 +196,12 @@ def configure(conf): def build(bld): + t = bld.SAMBA_GENERATOR('ctdb-version-header', + target='include/ctdb_version.h', + rule='../packaging/mkversion.sh ${TGT} %s' % (VERSION), + dep_vars=['VERSION']) + t.env.VERSION = VERSION + bld.RECURSE('lib/replace') if bld.CHECK_FOR_THIRD_PARTY(): bld.RECURSE('third_party/popt') @@ -208,12 +214,6 @@ def build(bld): bld.RECURSE('lib/tdb') bld.RECURSE('lib/socket_wrapper') - t = bld.SAMBA_GENERATOR('ctdb-version-header', - target='include/ctdb_version.h', - rule='../packaging/mkversion.sh ${TGT} %s' % (VERSION), - dep_vars=['VERSION']) - t.env.VERSION = VERSION - bld.SAMBA_SUBSYSTEM('ctdb-tcp', source=bld.SUBDIR('tcp', 'tcp_connect.c tcp_init.c tcp_io.c'), -- 2.1.1 From c91c55458e3e74acdceede0d68d7b47320e1a974 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 25 Aug 2014 13:28:30 +1000 Subject: [PATCH 17/34] ctdb-build: Add generation of Samba-style version.h This is needed by fault.c. Signed-off-by: Martin Schwenke Reviewed-by: Volker Lendecke (cherry picked from commit 43266be94552fe0c364e12d3c44fb54e453c123a) --- ctdb/wscript | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ctdb/wscript b/ctdb/wscript index 97cd84c..969c034 100755 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -202,6 +202,15 @@ def build(bld): dep_vars=['VERSION']) t.env.VERSION = VERSION + version_h = samba_utils.os_path_relpath(os.path.join(Options.launch_dir, + "version.h"), + bld.curdir) + t.bld.SAMBA_GENERATOR('ctdb-samba-version-header', + target=version_h, + rule='printf "#include \\"ctdb_version.h\\" \\n#define SAMBA_VERSION_STRING CTDB_VERSION_STRING\\n" > ${TGT}', + dep_vars=['VERSION']) + t.env.VERSION = VERSION + bld.RECURSE('lib/replace') if bld.CHECK_FOR_THIRD_PARTY(): bld.RECURSE('third_party/popt') -- 2.1.1 From 2d075aded43835752b393dce9dcd2704a7e0a670 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 15 Aug 2014 16:41:57 +1000 Subject: [PATCH 18/34] ctdb-build: Change from ctdb-util to samba-util Remove local lib/util and lib/tdb-wrap. Update wscript, packaging and includes.h. The only potentially surprising thing here is a fake samba-util subsystem that just depends on samba-util-core. As explained in a comment: When a combined build is implemented, CTDB will wanted to build against samba-util rather than samba-util-core. Similarly, other Samba subsystems expect samba-util. So, for a standalone build, just define a fake samba-util subsystem that pulls in samba-util-core. Signed-off-by: Martin Schwenke Reviewed-by: Volker Lendecke (cherry picked from commit 59c30257064518aae117784f02ba73bc3221bec6) --- ctdb/configure.rpm | 2 +- ctdb/include/internal/includes.h | 12 +- ctdb/lib/tdb_wrap/tdb_wrap.c | 113 -------- ctdb/lib/tdb_wrap/tdb_wrap.h | 39 --- ctdb/lib/tdb_wrap/wscript_build | 7 - ctdb/lib/util/debug.c | 115 -------- ctdb/lib/util/debug.h | 39 --- ctdb/lib/util/dlinklist.h | 181 ------------- ctdb/lib/util/fault.c | 235 ---------------- ctdb/lib/util/idtree.c | 387 --------------------------- ctdb/lib/util/signal.c | 144 ---------- ctdb/lib/util/substitute.c | 167 ------------ ctdb/lib/util/util.c | 52 ---- ctdb/lib/util/util.h | 565 --------------------------------------- ctdb/lib/util/util_file.c | 120 --------- ctdb/lib/util/util_time.c | 102 ------- ctdb/lib/util/wscript_build | 9 - ctdb/packaging/RPM/ctdb.spec.in | 2 +- ctdb/wscript | 45 +++- 19 files changed, 41 insertions(+), 2295 deletions(-) delete mode 100644 ctdb/lib/tdb_wrap/tdb_wrap.c delete mode 100644 ctdb/lib/tdb_wrap/tdb_wrap.h delete mode 100755 ctdb/lib/tdb_wrap/wscript_build delete mode 100644 ctdb/lib/util/debug.c delete mode 100644 ctdb/lib/util/debug.h delete mode 100644 ctdb/lib/util/dlinklist.h delete mode 100644 ctdb/lib/util/fault.c delete mode 100644 ctdb/lib/util/idtree.c delete mode 100644 ctdb/lib/util/signal.c delete mode 100644 ctdb/lib/util/substitute.c delete mode 100644 ctdb/lib/util/util.c delete mode 100644 ctdb/lib/util/util.h delete mode 100644 ctdb/lib/util/util_file.c delete mode 100644 ctdb/lib/util/util_time.c delete mode 100755 ctdb/lib/util/wscript_build diff --git a/ctdb/configure.rpm b/ctdb/configure.rpm index 32e6673..ff7eace 100755 --- a/ctdb/configure.rpm +++ b/ctdb/configure.rpm @@ -7,7 +7,7 @@ else fi CFLAGS="-Wall -g -D_GNU_SOURCE" ./configure \ - --builtin-libraries=replace,popt \ + --builtin-libraries=replace,popt,samba-debug,socket-blocking,tdb-wrap \ --bundled-libraries=!talloc,!tevent,!tdb \ --minimum-library-version=talloc:2.0.8,tdb:1.2.11,tevent:0.9.16 \ --prefix=/usr \ diff --git a/ctdb/include/internal/includes.h b/ctdb/include/internal/includes.h index 78eba55..d167ec7 100644 --- a/ctdb/include/internal/includes.h +++ b/ctdb/include/internal/includes.h @@ -38,17 +38,7 @@ #define discard_const(ptr) ((void *)((intptr_t)(ptr))) #endif -struct timeval timeval_zero(void); -bool timeval_is_zero(const struct timeval *tv); -struct timeval timeval_current(void); -struct timeval timeval_set(uint32_t secs, uint32_t usecs); -int timeval_compare(const struct timeval *tv1, const struct timeval *tv2); -struct timeval timeval_until(const struct timeval *tv1, - const struct timeval *tv2); -_PUBLIC_ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs); -double timeval_elapsed(struct timeval *tv); - #include "lib/util/debug.h" -#include "lib/util/util.h" +#include "lib/util/samba_util.h" #endif /* _CTDB_INCLUDES_H */ diff --git a/ctdb/lib/tdb_wrap/tdb_wrap.c b/ctdb/lib/tdb_wrap/tdb_wrap.c deleted file mode 100644 index 57f8efc..0000000 --- a/ctdb/lib/tdb_wrap/tdb_wrap.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - database wrap functions - - Copyright (C) Andrew Tridgell 2004 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -/* - the stupidity of the unix fcntl locking design forces us to never - allow a database file to be opened twice in the same process. These - wrappers provide convenient access to a tdb or ldb, taking advantage - of talloc destructors to ensure that only a single open is done -*/ - -#include "replace.h" -#include "lib/util/dlinklist.h" -#include "lib/util/debug.h" - -#include "ctdb_logging.h" - -#include "tdb_wrap.h" - -static struct tdb_wrap *tdb_list; - - - -/* destroy the last connection to a tdb */ -static int tdb_wrap_destructor(struct tdb_wrap *w) -{ - tdb_close(w->tdb); - DLIST_REMOVE(tdb_list, w); - return 0; -} - -static void log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...) -{ - if (level <= TDB_DEBUG_ERROR) { - va_list ap; - char *ptr = NULL; - int ret; - - va_start(ap, fmt); - ret = vasprintf(&ptr, fmt, ap); - va_end(ap); - - if (ret != -1) { - const char *name = tdb_name(tdb); - DEBUG(level, - ("%s:%s", name ? name : "unnamed tdb", ptr)); - free(ptr); - } - } -} - - -/* - wrapped connection to a tdb database - to close just talloc_free() the tdb_wrap pointer - */ -struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx, - const char *name, int hash_size, int tdb_flags, - int open_flags, mode_t mode) -{ - struct tdb_wrap *w; - struct tdb_logging_context log_ctx; - - log_ctx.log_fn = log_fn; - log_ctx.log_private = NULL; - - for (w=tdb_list;w;w=w->next) { - if (strcmp(name, w->name) == 0) { - return talloc_reference(mem_ctx, w); - } - } - - w = talloc(mem_ctx, struct tdb_wrap); - if (w == NULL) { - return NULL; - } - - w->name = talloc_strdup(w, name); - if (w->name == NULL) { - talloc_free(w); - return NULL; - } - - w->tdb = tdb_open_ex(name, hash_size, tdb_flags, - open_flags, mode, &log_ctx, NULL); - if (w->tdb == NULL) { - talloc_free(w); - return NULL; - } - - talloc_set_destructor(w, tdb_wrap_destructor); - - DLIST_ADD(tdb_list, w); - - return w; -} diff --git a/ctdb/lib/tdb_wrap/tdb_wrap.h b/ctdb/lib/tdb_wrap/tdb_wrap.h deleted file mode 100644 index 026e6ba..0000000 --- a/ctdb/lib/tdb_wrap/tdb_wrap.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - database wrap headers - - Copyright (C) Andrew Tridgell 2004 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#ifndef _DB_WRAP_H -#define _DB_WRAP_H - -#include -#include - -struct tdb_wrap { - struct tdb_context *tdb; - - const char *name; - struct tdb_wrap *next, *prev; -}; - -struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx, - const char *name, int hash_size, int tdb_flags, - int open_flags, mode_t mode); - -#endif /* _DB_WRAP_H */ diff --git a/ctdb/lib/tdb_wrap/wscript_build b/ctdb/lib/tdb_wrap/wscript_build deleted file mode 100755 index 39a128a..0000000 --- a/ctdb/lib/tdb_wrap/wscript_build +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/python - -bld.SAMBA_SUBSYSTEM('tdb-wrap', - source='tdb_wrap.c', - deps='tdb talloc', - local_include=False - ) diff --git a/ctdb/lib/util/debug.c b/ctdb/lib/util/debug.c deleted file mode 100644 index e159444..0000000 --- a/ctdb/lib/util/debug.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - Unix SMB/CIFS implementation. - ctdb debug functions - Copyright (C) Volker Lendecke 2007 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include "replace.h" -#include "system/filesys.h" -#include -#include -#include "debug.h" - -int DEBUGLEVEL; - -static void print_asc(int level, const uint8_t *buf, size_t len) -{ - int i; - for (i=0;i8) DEBUGADD(level,(" ")); - while (n--) DEBUGADD(level,(" ")); - n = MIN(8,i%16); - print_asc(level,&buf[i-(i%16)],n); DEBUGADD(level,( " " )); - n = (i%16) - n; - if (n>0) print_asc(level,&buf[i-n],n); - DEBUGADD(level,("\n")); - } - DEBUG(level, (__location__ " dump data of size %i finished\n", (int)len)); -} - -/* state variables for the debug system */ -static struct { - debug_callback_fn callback; - void *callback_private; -} state; - -static int current_msg_level = 0; - -void debug_set_callback(void *private_ptr, debug_callback_fn fn) -{ - assert(fn != NULL); - - state.callback_private = private_ptr; - state.callback = fn; -} - -bool dbghdr(int level, const char *location, const char *func) -{ - current_msg_level = level; - return true; -} - -bool dbgtext( const char *format_str, ... ) -{ - va_list ap; - char *msgbuf = NULL; - int res; - - va_start(ap, format_str); - res = vasprintf(&msgbuf, format_str, ap); - va_end(ap); - if (res == -1) { - return false; - } - - if (state.callback != NULL) { - state.callback(state.callback_private, - current_msg_level, msgbuf); - } else { - write(2, msgbuf, strlen(msgbuf)); - } - - free(msgbuf); - return true; -} diff --git a/ctdb/lib/util/debug.h b/ctdb/lib/util/debug.h deleted file mode 100644 index ac5e2c7..0000000 --- a/ctdb/lib/util/debug.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - Unix SMB/CIFS implementation. - ctdb debug functions - Copyright (C) Volker Lendecke 2007 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#ifndef UTIL_DEBUG_H -#define UTIL_DEBUG_H - -bool dbgtext( const char *, ... ) PRINTF_ATTRIBUTE(1,2); -bool dbghdr( int level, const char *location, const char *func); -void dump_data(int level, const uint8_t *buf1, size_t len); - -extern int DEBUGLEVEL; - -#define DEBUGLVL(lvl) ((lvl) <= DEBUGLEVEL) -#define DEBUG( lvl, body ) \ - (void)( ((lvl) <= DEBUGLEVEL) \ - && (dbghdr( lvl, __location__, __FUNCTION__ )) \ - && (dbgtext body) ) -#define DEBUGADD(lvl, body) DEBUG(lvl, body) - -typedef void (*debug_callback_fn)(void *private_ptr, int level, const char *msg); -void debug_set_callback(void *private_ptr, debug_callback_fn fn); - -#endif /* UTIL_DEBUG_H */ diff --git a/ctdb/lib/util/dlinklist.h b/ctdb/lib/util/dlinklist.h deleted file mode 100644 index 5520901..0000000 --- a/ctdb/lib/util/dlinklist.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - Unix SMB/CIFS implementation. - some simple double linked list macros - - Copyright (C) Andrew Tridgell 1998-2010 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/* To use these macros you must have a structure containing a next and - prev pointer */ - -#ifndef _DLINKLIST_H -#define _DLINKLIST_H - -/* - February 2010 - changed list format to have a prev pointer from the - list head. This makes DLIST_ADD_END() O(1) even though we only have - one list pointer. - - The scheme is as follows: - - 1) with no entries in the list: - list_head == NULL - - 2) with 1 entry in the list: - list_head->next == NULL - list_head->prev == list_head - - 3) with 2 entries in the list: - list_head->next == element2 - list_head->prev == element2 - element2->prev == list_head - element2->next == NULL - - 4) with N entries in the list: - list_head->next == element2 - list_head->prev == elementN - elementN->prev == element{N-1} - elementN->next == NULL - - This allows us to find the tail of the list by using - list_head->prev, which means we can add to the end of the list in - O(1) time - - - Note that the 'type' arguments below are no longer needed, but - are kept for now to prevent an incompatible argument change - */ - - -/* - add an element at the front of a list -*/ -#define DLIST_ADD(list, p) \ -do { \ - if (!(list)) { \ - (p)->prev = (list) = (p); \ - (p)->next = NULL; \ - } else { \ - (p)->prev = (list)->prev; \ - (list)->prev = (p); \ - (p)->next = (list); \ - (list) = (p); \ - } \ -} while (0) - -/* - remove an element from a list - Note that the element doesn't have to be in the list. If it - isn't then this is a no-op -*/ -#define DLIST_REMOVE(list, p) \ -do { \ - if ((p) == (list)) { \ - if ((p)->next) (p)->next->prev = (p)->prev; \ - (list) = (p)->next; \ - } else if ((list) && (p) == (list)->prev) { \ - (p)->prev->next = NULL; \ - (list)->prev = (p)->prev; \ - } else { \ - if ((p)->prev) (p)->prev->next = (p)->next; \ - if ((p)->next) (p)->next->prev = (p)->prev; \ - } \ - if ((p) != (list)) (p)->next = (p)->prev = NULL; \ -} while (0) - -/* - find the head of the list given any element in it. - Note that this costs O(N), so you should avoid this macro - if at all possible! -*/ -#define DLIST_HEAD(p, result_head) \ -do { \ - (result_head) = (p); \ - while (DLIST_PREV(result_head)) (result_head) = (result_head)->prev; \ -} while(0) - -/* return the last element in the list */ -#define DLIST_TAIL(list) ((list)?(list)->prev:NULL) - -/* return the previous element in the list. */ -#define DLIST_PREV(p) (((p)->prev && (p)->prev->next != NULL)?(p)->prev:NULL) - -/* insert 'p' after the given element 'el' in a list. If el is NULL then - this is the same as a DLIST_ADD() */ -#define DLIST_ADD_AFTER(list, p, el) \ -do { \ - if (!(list) || !(el)) { \ - DLIST_ADD(list, p); \ - } else { \ - (p)->prev = (el); \ - (p)->next = (el)->next; \ - (el)->next = (p); \ - if ((p)->next) (p)->next->prev = (p); \ - if ((list)->prev == (el)) (list)->prev = (p); \ - }\ -} while (0) - - -/* - add to the end of a list. - Note that 'type' is ignored -*/ -#define DLIST_ADD_END(list, p, type) \ -do { \ - if (!(list)) { \ - DLIST_ADD(list, p); \ - } else { \ - DLIST_ADD_AFTER(list, p, (list)->prev); \ - } \ -} while (0) - -/* promote an element to the front of a list */ -#define DLIST_PROMOTE(list, p) \ -do { \ - DLIST_REMOVE(list, p); \ - DLIST_ADD(list, p); \ -} while (0) - -/* - demote an element to the end of a list. - Note that 'type' is ignored -*/ -#define DLIST_DEMOTE(list, p, type) \ -do { \ - DLIST_REMOVE(list, p); \ - DLIST_ADD_END(list, p, NULL); \ -} while (0) - -/* - concatenate two lists - putting all elements of the 2nd list at the - end of the first list. - Note that 'type' is ignored -*/ -#define DLIST_CONCATENATE(list1, list2, type) \ -do { \ - if (!(list1)) { \ - (list1) = (list2); \ - } else { \ - (list1)->prev->next = (list2); \ - if (list2) { \ - void *_tmplist = (void *)(list1)->prev; \ - (list1)->prev = (list2)->prev; \ - (list2)->prev = _tmplist; \ - } \ - } \ -} while (0) - -#endif /* _DLINKLIST_H */ diff --git a/ctdb/lib/util/fault.c b/ctdb/lib/util/fault.c deleted file mode 100644 index d53eecd..0000000 --- a/ctdb/lib/util/fault.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Critical Fault handling - Copyright (C) Andrew Tridgell 1992-1998 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "includes.h" -#include "system/wait.h" -#include "system/filesys.h" - -/** - * @file - * @brief Fault handling - */ - -/* the registered fault handler */ -static struct { - const char *name; - void (*fault_handler)(int sig); -} fault_handlers; - -static const char *progname; - -#ifdef HAVE_BACKTRACE -#include -#elif HAVE_LIBEXC_H -#include -#endif - -/** - * Write backtrace to debug log - */ -_PUBLIC_ void call_backtrace(void) -{ -#ifdef HAVE_BACKTRACE -#ifndef BACKTRACE_STACK_SIZE -#define BACKTRACE_STACK_SIZE 64 -#endif - void *backtrace_stack[BACKTRACE_STACK_SIZE]; - size_t backtrace_size; - char **backtrace_strings; - - /* get the backtrace (stack frames) */ - backtrace_size = backtrace(backtrace_stack,BACKTRACE_STACK_SIZE); - backtrace_strings = backtrace_symbols(backtrace_stack, backtrace_size); - - DEBUG(0, ("BACKTRACE: %lu stack frames:\n", - (unsigned long)backtrace_size)); - - if (backtrace_strings) { - int i; - - for (i = 0; i < backtrace_size; i++) - DEBUGADD(0, (" #%u %s\n", i, backtrace_strings[i])); - - /* Leak the backtrace_strings, rather than risk what free() might do */ - } - -#elif HAVE_LIBEXC - -#define NAMESIZE 32 /* Arbitrary */ -#ifndef BACKTRACE_STACK_SIZE -#define BACKTRACE_STACK_SIZE 64 -#endif - - /* The IRIX libexc library provides an API for unwinding the stack. See - * libexc(3) for details. Apparantly trace_back_stack leaks memory, but - * since we are about to abort anyway, it hardly matters. - * - * Note that if we paniced due to a SIGSEGV or SIGBUS (or similar) this - * will fail with a nasty message upon failing to open the /proc entry. - */ - { - uint64_t addrs[BACKTRACE_STACK_SIZE]; - char * names[BACKTRACE_STACK_SIZE]; - char namebuf[BACKTRACE_STACK_SIZE * NAMESIZE]; - - int i; - int levels; - - ZERO_ARRAY(addrs); - ZERO_ARRAY(names); - ZERO_ARRAY(namebuf); - - for (i = 0; i < BACKTRACE_STACK_SIZE; i++) { - names[i] = namebuf + (i * NAMESIZE); - } - - levels = trace_back_stack(0, addrs, names, - BACKTRACE_STACK_SIZE, NAMESIZE); - - DEBUG(0, ("BACKTRACE: %d stack frames:\n", levels)); - for (i = 0; i < levels; i++) { - DEBUGADD(0, (" #%d 0x%llx %s\n", i, addrs[i], names[i])); - } - } -#undef NAMESIZE -#else - DEBUG(0, ("call_backtrace: not implemented\n")); -#endif -} - -_PUBLIC_ const char *panic_action = NULL; -_PUBLIC_ void (*pre_panic_action_hook)(void) = NULL; -_PUBLIC_ void (*post_panic_action_hook)(void) = NULL; - -/** - Something really nasty happened - panic ! -**/ -_PUBLIC_ void smb_panic(const char *why) -{ - int result; - - if (panic_action && *panic_action) { - char pidstr[20]; - char cmdstring[200]; - strlcpy(cmdstring, panic_action, sizeof(cmdstring)); - snprintf(pidstr, sizeof(pidstr), "%u", getpid()); - all_string_sub(cmdstring, "%PID%", pidstr, sizeof(cmdstring)); - if (progname) { - all_string_sub(cmdstring, "%PROG%", progname, sizeof(cmdstring)); - } - DEBUG(0, ("smb_panic(): calling panic action [%s]\n", cmdstring)); - - if (pre_panic_action_hook) { - pre_panic_action_hook(); - } - - result = system(cmdstring); - - if (post_panic_action_hook) { - post_panic_action_hook(); - } - - if (result == -1) - DEBUG(0, ("smb_panic(): fork failed in panic action: %s\n", - strerror(errno))); - else - DEBUG(0, ("smb_panic(): action returned status %d\n", - WEXITSTATUS(result))); - } - DEBUG(0,("PANIC: %s\n", why)); - - call_backtrace(); - -#ifdef SIGABRT - CatchSignal(SIGABRT, SIG_DFL); -#endif - abort(); -} - -/** -report a fault -**/ -_NORETURN_ static void fault_report(int sig) -{ - static int counter; - - if (counter) _exit(1); - - DEBUG(0,("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n")); - DEBUG(0,("INTERNAL ERROR: Signal %d in %s pid %d",sig, progname, (int)getpid())); - DEBUG(0,("\nPlease read the file BUGS.txt in the distribution\n")); - DEBUG(0,("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n")); - - smb_panic("internal error"); - - exit(1); -} - -/** -catch serious errors -**/ -_NORETURN_ static void sig_fault(int sig) -{ - if (fault_handlers.fault_handler) { - /* we have a fault handler, call it. It may not return. */ - fault_handlers.fault_handler(sig); - } - /* If it returns or doesn't exist, use regular reporter */ - fault_report(sig); -} - -/** -setup our fault handlers -**/ -_PUBLIC_ void fault_setup(void) -{ -#ifdef SIGSEGV - CatchSignal(SIGSEGV, sig_fault); -#endif -#ifdef SIGBUS - CatchSignal(SIGBUS, sig_fault); -#endif -#ifdef SIGABRT - CatchSignal(SIGABRT, sig_fault); -#endif -#ifdef SIGFPE - CatchSignal(SIGFPE, sig_fault); -#endif -} - -/** - register a fault handler. - Should only be called once in the execution of smbd. -*/ -_PUBLIC_ bool register_fault_handler(const char *name, - void (*fault_handler)(int sig)) -{ - if (fault_handlers.name != NULL) { - /* it's already registered! */ - DEBUG(2,("fault handler '%s' already registered - failed '%s'\n", - fault_handlers.name, name)); - return false; - } - - fault_handlers.name = name; - fault_handlers.fault_handler = fault_handler; - - DEBUG(2,("fault handler '%s' registered\n", name)); - return true; -} diff --git a/ctdb/lib/util/idtree.c b/ctdb/lib/util/idtree.c deleted file mode 100644 index 09dc237..0000000 --- a/ctdb/lib/util/idtree.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - very efficient functions to manage mapping a id (such as a fnum) to - a pointer. This is used for fnum and search id allocation. - - Copyright (C) Andrew Tridgell 2004 - - This code is derived from lib/idr.c in the 2.6 Linux kernel, which was - written by Jim Houston jim.houston@ccur.com, and is - Copyright (C) 2002 by Concurrent Computer Corporation - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -/* - see the section marked "public interface" below for documentation -*/ - -/** - * @file - */ - -#include "includes.h" - -#define IDR_BITS 5 -#define IDR_FULL 0xfffffffful -#if 0 /* unused */ -#define TOP_LEVEL_FULL (IDR_FULL >> 30) -#endif -#define IDR_SIZE (1 << IDR_BITS) -#define IDR_MASK ((1 << IDR_BITS)-1) -#define MAX_ID_SHIFT (sizeof(int)*8 - 1) -#define MAX_ID_BIT (1U << MAX_ID_SHIFT) -#define MAX_ID_MASK (MAX_ID_BIT - 1) -#define MAX_LEVEL (MAX_ID_SHIFT + IDR_BITS - 1) / IDR_BITS -#define IDR_FREE_MAX MAX_LEVEL + MAX_LEVEL - -#define set_bit(bit, v) (v) |= (1<<(bit)) -#define clear_bit(bit, v) (v) &= ~(1<<(bit)) -#define test_bit(bit, v) ((v) & (1<<(bit))) - -struct idr_layer { - uint32_t bitmap; - struct idr_layer *ary[IDR_SIZE]; - int count; -}; - -struct idr_context { - struct idr_layer *top; - struct idr_layer *id_free; - int layers; - int id_free_cnt; -}; - -static struct idr_layer *alloc_layer(struct idr_context *idp) -{ - struct idr_layer *p; - - if (!(p = idp->id_free)) - return NULL; - idp->id_free = p->ary[0]; - idp->id_free_cnt--; - p->ary[0] = NULL; - return p; -} - -static int find_next_bit(uint32_t bm, int maxid, int n) -{ - while (nary[0] = idp->id_free; - idp->id_free = p; - idp->id_free_cnt++; -} - -static int idr_pre_get(struct idr_context *idp) -{ - while (idp->id_free_cnt < IDR_FREE_MAX) { - struct idr_layer *new = talloc_zero(idp, struct idr_layer); - if(new == NULL) - return (0); - free_layer(idp, new); - } - return 1; -} - -static int sub_alloc(struct idr_context *idp, void *ptr, int *starting_id) -{ - int n, m, sh; - struct idr_layer *p, *new; - struct idr_layer *pa[MAX_LEVEL+1]; - unsigned int l, id, oid; - uint32_t bm; - - memset(pa, 0, sizeof(pa)); - - id = *starting_id; -restart: - p = idp->top; - l = idp->layers; - pa[l--] = NULL; - while (1) { - /* - * We run around this while until we reach the leaf node... - */ - n = (id >> (IDR_BITS*l)) & IDR_MASK; - bm = ~p->bitmap; - m = find_next_bit(bm, IDR_SIZE, n); - if (m == IDR_SIZE) { - /* no space available go back to previous layer. */ - l++; - oid = id; - id = (id | ((1 << (IDR_BITS*l))-1)) + 1; - - /* if already at the top layer, we need to grow */ - if (!(p = pa[l])) { - *starting_id = id; - return -2; - } - - /* If we need to go up one layer, continue the - * loop; otherwise, restart from the top. - */ - sh = IDR_BITS * (l + 1); - if (oid >> sh == id >> sh) - continue; - else - goto restart; - } - if (m != n) { - sh = IDR_BITS*l; - id = ((id >> sh) ^ n ^ m) << sh; - } - if ((id >= MAX_ID_BIT) || (id < 0)) - return -1; - if (l == 0) - break; - /* - * Create the layer below if it is missing. - */ - if (!p->ary[m]) { - if (!(new = alloc_layer(idp))) - return -1; - p->ary[m] = new; - p->count++; - } - pa[l--] = p; - p = p->ary[m]; - } - /* - * We have reached the leaf node, plant the - * users pointer and return the raw id. - */ - p->ary[m] = (struct idr_layer *)ptr; - set_bit(m, p->bitmap); - p->count++; - /* - * If this layer is full mark the bit in the layer above - * to show that this part of the radix tree is full. - * This may complete the layer above and require walking - * up the radix tree. - */ - n = id; - while (p->bitmap == IDR_FULL) { - if (!(p = pa[++l])) - break; - n = n >> IDR_BITS; - set_bit((n & IDR_MASK), p->bitmap); - } - return(id); -} - -static int idr_get_new_above_int(struct idr_context *idp, void *ptr, int starting_id) -{ - struct idr_layer *p, *new; - int layers, v, id; - - idr_pre_get(idp); - - id = starting_id; -build_up: - p = idp->top; - layers = idp->layers; - if (!p) { - if (!(p = alloc_layer(idp))) - return -1; - layers = 1; - } - /* - * Add a new layer to the top of the tree if the requested - * id is larger than the currently allocated space. - */ - while ((layers < MAX_LEVEL) && (id >= (1 << (layers*IDR_BITS)))) { - layers++; - if (!p->count) - continue; - if (!(new = alloc_layer(idp))) { - /* - * The allocation failed. If we built part of - * the structure tear it down. - */ - for (new = p; p && p != idp->top; new = p) { - p = p->ary[0]; - new->ary[0] = NULL; - new->bitmap = new->count = 0; - free_layer(idp, new); - } - return -1; - } - new->ary[0] = p; - new->count = 1; - if (p->bitmap == IDR_FULL) - set_bit(0, new->bitmap); - p = new; - } - idp->top = p; - idp->layers = layers; - v = sub_alloc(idp, ptr, &id); - if (v == -2) - goto build_up; - return(v); -} - -static int sub_remove(struct idr_context *idp, int shift, int id) -{ - struct idr_layer *p = idp->top; - struct idr_layer **pa[1+MAX_LEVEL]; - struct idr_layer ***paa = &pa[0]; - int n; - - *paa = NULL; - *++paa = &idp->top; - - while ((shift > 0) && p) { - n = (id >> shift) & IDR_MASK; - clear_bit(n, p->bitmap); - *++paa = &p->ary[n]; - p = p->ary[n]; - shift -= IDR_BITS; - } - n = id & IDR_MASK; - if (p != NULL && test_bit(n, p->bitmap)) { - clear_bit(n, p->bitmap); - p->ary[n] = NULL; - while(*paa && ! --((**paa)->count)){ - free_layer(idp, **paa); - **paa-- = NULL; - } - if ( ! *paa ) - idp->layers = 0; - return 0; - } - return -1; -} - -static void *_idr_find(struct idr_context *idp, int id) -{ - int n; - struct idr_layer *p; - - n = idp->layers * IDR_BITS; - p = idp->top; - /* - * This tests to see if bits outside the current tree are - * present. If so, tain't one of ours! - */ - if (n + IDR_BITS < 31 && - ((id & ~(~0 << MAX_ID_SHIFT)) >> (n + IDR_BITS))) { - return NULL; - } - - /* Mask off upper bits we don't use for the search. */ - id &= MAX_ID_MASK; - - while (n >= IDR_BITS && p) { - n -= IDR_BITS; - p = p->ary[(id >> n) & IDR_MASK]; - } - return((void *)p); -} - -static int _idr_remove(struct idr_context *idp, int id) -{ - struct idr_layer *p; - - /* Mask off upper bits we don't use for the search. */ - id &= MAX_ID_MASK; - - if (sub_remove(idp, (idp->layers - 1) * IDR_BITS, id) == -1) { - return -1; - } - - if ( idp->top && idp->top->count == 1 && - (idp->layers > 1) && - idp->top->ary[0]) { - /* We can drop a layer */ - p = idp->top->ary[0]; - idp->top->bitmap = idp->top->count = 0; - free_layer(idp, idp->top); - idp->top = p; - --idp->layers; - } - while (idp->id_free_cnt >= IDR_FREE_MAX) { - p = alloc_layer(idp); - talloc_free(p); - } - return 0; -} - -/************************************************************************ - this is the public interface -**************************************************************************/ - -/** - initialise a idr tree. The context return value must be passed to - all subsequent idr calls. To destroy the idr tree use talloc_free() - on this context - */ -_PUBLIC_ struct idr_context *idr_init(TALLOC_CTX *mem_ctx) -{ - return talloc_zero(mem_ctx, struct idr_context); -} - -/** - allocate the next available id, and assign 'ptr' into its slot. - you can retrieve later this pointer using idr_find() -*/ -_PUBLIC_ int idr_get_new(struct idr_context *idp, void *ptr, int limit) -{ - int ret = idr_get_new_above_int(idp, ptr, 0); - if (ret > limit) { - idr_remove(idp, ret); - return -1; - } - return ret; -} - -/** - allocate a new id, giving the first available value greater than or - equal to the given starting id -*/ -_PUBLIC_ int idr_get_new_above(struct idr_context *idp, void *ptr, int starting_id, int limit) -{ - int ret = idr_get_new_above_int(idp, ptr, starting_id); - if (ret > limit) { - idr_remove(idp, ret); - return -1; - } - return ret; -} - -/** - find a pointer value previously set with idr_get_new given an id -*/ -_PUBLIC_ void *idr_find(struct idr_context *idp, int id) -{ - return _idr_find(idp, id); -} - -/** - remove an id from the idr tree -*/ -_PUBLIC_ int idr_remove(struct idr_context *idp, int id) -{ - int ret; - ret = _idr_remove((struct idr_context *)idp, id); - if (ret != 0) { - DEBUG(0,("WARNING: attempt to remove unset id %d in idtree\n", id)); - } - return ret; -} diff --git a/ctdb/lib/util/signal.c b/ctdb/lib/util/signal.c deleted file mode 100644 index 33a9900..0000000 --- a/ctdb/lib/util/signal.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - Unix SMB/CIFS implementation. - signal handling functions - - Copyright (C) Andrew Tridgell 1998 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "includes.h" -#include "system/wait.h" - -/** - * @file - * @brief Signal handling - */ - -/**************************************************************************** - Catch child exits and reap the child zombie status. -****************************************************************************/ - -static void sig_cld(int signum) -{ - while (waitpid((pid_t)-1,(int *)NULL, WNOHANG) > 0) - ; - - /* - * Turns out it's *really* important not to - * restore the signal handler here if we have real POSIX - * signal handling. If we do, then we get the signal re-delivered - * immediately - hey presto - instant loop ! JRA. - */ - -#if !defined(HAVE_SIGACTION) - CatchSignal(SIGCLD, sig_cld); -#endif -} - -/**************************************************************************** -catch child exits - leave status; -****************************************************************************/ - -static void sig_cld_leave_status(int signum) -{ - /* - * Turns out it's *really* important not to - * restore the signal handler here if we have real POSIX - * signal handling. If we do, then we get the signal re-delivered - * immediately - hey presto - instant loop ! JRA. - */ - -#if !defined(HAVE_SIGACTION) - CatchSignal(SIGCLD, sig_cld_leave_status); -#endif -} - -/** - Block sigs. -**/ - -void BlockSignals(bool block, int signum) -{ -#ifdef HAVE_SIGPROCMASK - sigset_t set; - sigemptyset(&set); - sigaddset(&set,signum); - sigprocmask(block?SIG_BLOCK:SIG_UNBLOCK,&set,NULL); -#elif defined(HAVE_SIGBLOCK) - if (block) { - sigblock(sigmask(signum)); - } else { - sigsetmask(siggetmask() & ~sigmask(signum)); - } -#else - /* yikes! This platform can't block signals? */ - static int done; - if (!done) { - DEBUG(0,("WARNING: No signal blocking available\n")); - done=1; - } -#endif -} - -/** - Catch a signal. This should implement the following semantics: - - 1) The handler remains installed after being called. - 2) The signal should be blocked during handler execution. -**/ - -void (*CatchSignal(int signum,void (*handler)(int )))(int) -{ -#ifdef HAVE_SIGACTION - struct sigaction act; - struct sigaction oldact; - - ZERO_STRUCT(act); - - act.sa_handler = handler; -#ifdef SA_RESTART - /* - * We *want* SIGALRM to interrupt a system call. - */ - if(signum != SIGALRM) - act.sa_flags = SA_RESTART; -#endif - sigemptyset(&act.sa_mask); - sigaddset(&act.sa_mask,signum); - sigaction(signum,&act,&oldact); - return oldact.sa_handler; -#else /* !HAVE_SIGACTION */ - /* FIXME: need to handle sigvec and systems with broken signal() */ - return signal(signum, handler); -#endif -} - -/** - Ignore SIGCLD via whatever means is necessary for this OS. -**/ - -void (*CatchChild(void))(int) -{ - return CatchSignal(SIGCLD, sig_cld); -} - -/** - Catch SIGCLD but leave the child around so it's status can be reaped. -**/ - -void (*CatchChildLeaveStatus(void))(int) -{ - return CatchSignal(SIGCLD, sig_cld_leave_status); -} diff --git a/ctdb/lib/util/substitute.c b/ctdb/lib/util/substitute.c deleted file mode 100644 index 32945a7..0000000 --- a/ctdb/lib/util/substitute.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Samba utility functions - - Copyright (C) Andrew Tridgell 1992-2001 - Copyright (C) Simo Sorce 2001-2002 - Copyright (C) Martin Pool 2003 - Copyright (C) James Peach 2005 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "includes.h" - -/** - * @file - * @brief Substitute utilities. - **/ - -/** - Substitute a string for a pattern in another string. Make sure there is - enough room! - - This routine looks for pattern in s and replaces it with - insert. It may do multiple replacements. - - Any of " ; ' $ or ` in the insert string are replaced with _ - if len==0 then the string cannot be extended. This is different from the old - use of len==0 which was for no length checks to be done. -**/ - -_PUBLIC_ void string_sub(char *s, const char *pattern, const char *insert, size_t len) -{ - char *p; - ssize_t ls, lp, li, i; - - if (!insert || !pattern || !*pattern || !s) - return; - - ls = (ssize_t)strlen(s); - lp = (ssize_t)strlen(pattern); - li = (ssize_t)strlen(insert); - - if (len == 0) - len = ls + 1; /* len is number of *bytes* */ - - while (lp <= ls && (p = strstr(s, pattern))) { - if (ls + (li-lp) >= len) { - DEBUG(0,("ERROR: string overflow by %d in string_sub(%.50s, %d)\n", - (int)(ls + (li-lp) - len), - pattern, (int)len)); - break; - } - if (li != lp) { - memmove(p+li,p+lp,strlen(p+lp)+1); - } - for (i=0;i= len) { - DEBUG(0,("ERROR: string overflow by %d in all_string_sub(%.50s, %d)\n", - (int)(ls + (li-lp) - len), - pattern, (int)len)); - break; - } - if (li != lp) { - memmove(p+li,p+lp,strlen(p+lp)+1); - } - memcpy(p, insert, li); - s = p + li; - ls += (li-lp); - } -} diff --git a/ctdb/lib/util/util.c b/ctdb/lib/util/util.c deleted file mode 100644 index af52805..0000000 --- a/ctdb/lib/util/util.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Copyright (C) Andrew Tridgell 2005 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ - -#include "includes.h" -#include "system/filesys.h" - - -/** - Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available, - else - if SYSV use O_NDELAY - if BSD use FNDELAY -**/ - -_PUBLIC_ int set_blocking(int fd, bool set) -{ - int val; -#ifdef O_NONBLOCK -#define FLAG_TO_SET O_NONBLOCK -#else -#ifdef SYSV -#define FLAG_TO_SET O_NDELAY -#else /* BSD */ -#define FLAG_TO_SET FNDELAY -#endif -#endif - - if((val = fcntl(fd, F_GETFL, 0)) == -1) - return -1; - if(set) /* Turn blocking on - ie. clear nonblock flag */ - val &= ~FLAG_TO_SET; - else - val |= FLAG_TO_SET; - return fcntl( fd, F_SETFL, val); -#undef FLAG_TO_SET -} diff --git a/ctdb/lib/util/util.h b/ctdb/lib/util/util.h deleted file mode 100644 index 87aaa45..0000000 --- a/ctdb/lib/util/util.h +++ /dev/null @@ -1,565 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Utility functions for Samba - Copyright (C) Andrew Tridgell 1992-1999 - Copyright (C) Jelmer Vernooij 2005 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef _SAMBA_UTIL_H_ -#define _SAMBA_UTIL_H_ - -/** - * @file - * @brief Helpful macros - */ - -struct smbsrv_tcon; - -#ifdef _SAMBA_BUILD_ -extern const char *logfile; -#endif -extern const char *panic_action; -extern void (*pre_panic_action_hook)(void); -extern void (*post_panic_action_hook)(void); - -/** - * assert macros - */ -#ifdef DEVELOPER -#define SMB_ASSERT(b) do { if (!(b)) { \ - DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \ - __FILE__, __LINE__, #b)); smb_panic("assert failed: " #b); }} while(0) -#else -/* redefine the assert macro for non-developer builds */ -#define SMB_ASSERT(b) do { if (!(b)) { \ - DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \ - __FILE__, __LINE__, #b)); }} while (0) -#endif - -#if _SAMBA_BUILD_ == 4 -#ifdef VALGRIND -#define strlen(x) valgrind_strlen(x) -size_t valgrind_strlen(const char *s); -#endif -#endif - -#ifndef ABS -#define ABS(a) ((a)>0?(a):(-(a))) -#endif - -/** - * Write backtrace to debug log - */ -_PUBLIC_ void call_backtrace(void); - -/** - Something really nasty happened - panic ! -**/ -_PUBLIC_ _NORETURN_ void smb_panic(const char *why); - -/** -setup our fault handlers -**/ -_PUBLIC_ void fault_setup(void); - -/** - register a fault handler. - Should only be called once in the execution of smbd. -*/ -_PUBLIC_ bool register_fault_handler(const char *name, void (*fault_handler)(int sig)); - -/* The following definitions come from lib/util/signal.c */ - - -/** - Block sigs. -**/ -void BlockSignals(bool block, int signum); - -/** - Catch a signal. This should implement the following semantics: - - 1) The handler remains installed after being called. - 2) The signal should be blocked during handler execution. -**/ -void (*CatchSignal(int signum,void (*handler)(int )))(int); - -/** - Ignore SIGCLD via whatever means is necessary for this OS. -**/ -void (*CatchChild(void))(int); - -/** - Catch SIGCLD but leave the child around so it's status can be reaped. -**/ -void (*CatchChildLeaveStatus(void))(int); - - -/* The following definitions come from lib/util/util_str.c */ - - -/** - Trim the specified elements off the front and back of a string. -**/ -_PUBLIC_ bool trim_string(char *s, const char *front, const char *back); - -/** - Find the number of 'c' chars in a string -**/ -_PUBLIC_ _PURE_ size_t count_chars(const char *s, char c); - -/** - Safe string copy into a known length string. maxlength does not - include the terminating zero. -**/ -_PUBLIC_ char *safe_strcpy(char *dest,const char *src, size_t maxlength); - -/** - Safe string cat into a string. maxlength does not - include the terminating zero. -**/ -_PUBLIC_ char *safe_strcat(char *dest, const char *src, size_t maxlength); - -/** - Routine to get hex characters and turn them into a 16 byte array. - the array can be variable length, and any non-hex-numeric - characters are skipped. "0xnn" or "0Xnn" is specially catered - for. - - valid examples: "0A5D15"; "0x15, 0x49, 0xa2"; "59\ta9\te3\n" - - -**/ -_PUBLIC_ size_t strhex_to_str(char *p, size_t p_len, const char *strhex, size_t strhex_len); - -#ifdef _SAMBA_BUILD_ -/** - * Parse a hex string and return a data blob. - */ -_PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(TALLOC_CTX *mem_ctx, const char *strhex) ; -#endif - -/** - * Routine to print a buffer as HEX digits, into an allocated string. - */ -_PUBLIC_ void hex_encode(const unsigned char *buff_in, size_t len, char **out_hex_buffer); - -/** - * talloc version of hex_encode() - */ -_PUBLIC_ char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len); - -/** - Substitute a string for a pattern in another string. Make sure there is - enough room! - - This routine looks for pattern in s and replaces it with - insert. It may do multiple replacements. - - Any of " ; ' $ or ` in the insert string are replaced with _ - if len==0 then the string cannot be extended. This is different from the old - use of len==0 which was for no length checks to be done. -**/ -_PUBLIC_ void string_sub(char *s,const char *pattern, const char *insert, size_t len); - - -_PUBLIC_ char *string_sub_talloc(TALLOC_CTX *mem_ctx, const char *s, - const char *pattern, const char *insert); - -/** - Similar to string_sub() but allows for any character to be substituted. - Use with caution! - if len==0 then the string cannot be extended. This is different from the old - use of len==0 which was for no length checks to be done. -**/ -_PUBLIC_ void all_string_sub(char *s,const char *pattern,const char *insert, size_t len); - -/** - Unescape a URL encoded string, in place. -**/ -_PUBLIC_ void rfc1738_unescape(char *buf); - -/** - format a string into length-prefixed dotted domain format, as used in NBT - and in some ADS structures -**/ -_PUBLIC_ const char *str_format_nbt_domain(TALLOC_CTX *mem_ctx, const char *s); - -/** - * Add a string to an array of strings. - * - * num should be a pointer to an integer that holds the current - * number of elements in strings. It will be updated by this function. - */ -_PUBLIC_ bool add_string_to_array(TALLOC_CTX *mem_ctx, - const char *str, const char ***strings, int *num); - -/** - varient of strcmp() that handles NULL ptrs -**/ -_PUBLIC_ int strcmp_safe(const char *s1, const char *s2); - -/** -return the number of bytes occupied by a buffer in ASCII format -the result includes the null termination -limited by 'n' bytes -**/ -_PUBLIC_ size_t ascii_len_n(const char *src, size_t n); - -/** - Set a boolean variable from the text value stored in the passed string. - Returns true in success, false if the passed string does not correctly - represent a boolean. -**/ -_PUBLIC_ bool set_boolean(const char *boolean_string, bool *boolean); - -/** - * Parse a string containing a boolean value. - * - * val will be set to the read value. - * - * @retval true if a boolean value was parsed, false otherwise. - */ -_PUBLIC_ bool conv_str_bool(const char * str, bool * val); - -#if _SAMBA_BUILD_ == 4 -/** - * Convert a size specification like 16K into an integral number of bytes. - **/ -_PUBLIC_ bool conv_str_size(const char * str, uint64_t * val); -#endif - -/** - * Parse a uint64_t value from a string - * - * val will be set to the value read. - * - * @retval true if parsing was successful, false otherwise - */ -_PUBLIC_ bool conv_str_u64(const char * str, uint64_t * val); - -/** -return the number of bytes occupied by a buffer in CH_UTF16 format -the result includes the null termination -**/ -_PUBLIC_ size_t utf16_len(const void *buf); - -/** -return the number of bytes occupied by a buffer in CH_UTF16 format -the result includes the null termination -limited by 'n' bytes -**/ -_PUBLIC_ size_t utf16_len_n(const void *src, size_t n); -_PUBLIC_ size_t ucs2_align(const void *base_ptr, const void *p, int flags); - -/** -Do a case-insensitive, whitespace-ignoring string compare. -**/ -_PUBLIC_ int strwicmp(const char *psz1, const char *psz2); - -/** - String replace. -**/ -_PUBLIC_ void string_replace(char *s, char oldc, char newc); - -/** - * Compare 2 strings. - * - * @note The comparison is case-insensitive. - **/ -_PUBLIC_ bool strequal(const char *s1, const char *s2); - -/* The following definitions come from lib/util/util_file.c */ - - -#ifdef _SAMBA_BUILD_ -/** -read a line from a file with possible \ continuation chars. -Blanks at the start or end of a line are stripped. -The string will be allocated if s2 is NULL -**/ -_PUBLIC_ char *fgets_slash(char *s2,int maxlen,XFILE *f); -#endif - -/** - * Read one line (data until next newline or eof) and allocate it - */ -_PUBLIC_ char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint); - -#ifdef _SAMBA_BUILD_ -/** -load a file into memory from a fd. -**/ -_PUBLIC_ char *fd_load(int fd, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx); - - -char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx); - -/** -load a file into memory -**/ -_PUBLIC_ char *file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx); -#endif - -/** -mmap (if possible) or read a file -**/ -_PUBLIC_ void *map_file(const char *fname, size_t size); - -/** -load a file into memory and return an array of pointers to lines in the file -must be freed with talloc_free(). -**/ -_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx); - -/** -load a fd into memory and return an array of pointers to lines in the file -must be freed with talloc_free(). If convert is true calls unix_to_dos on -the list. -**/ -_PUBLIC_ char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx); - -/** - save a lump of data into a file. Mostly used for debugging -*/ -_PUBLIC_ bool file_save(const char *fname, const void *packet, size_t length); -_PUBLIC_ int vfdprintf(int fd, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0); -_PUBLIC_ int fdprintf(int fd, const char *format, ...) PRINTF_ATTRIBUTE(2,3); - -/* The following definitions come from lib/util/util.c */ - - -/** - Find a suitable temporary directory. The result should be copied immediately - as it may be overwritten by a subsequent call. -**/ -_PUBLIC_ const char *tmpdir(void); - -/** - Check if a file exists - call vfs_file_exist for samba files. -**/ -_PUBLIC_ bool file_exist(const char *fname); - -/** - Check a files mod time. -**/ -_PUBLIC_ time_t file_modtime(const char *fname); - -/** - Check if a directory exists. -**/ -_PUBLIC_ bool directory_exist(const char *dname); - -/** - * Try to create the specified directory if it didn't exist. - * - * @retval true if the directory already existed and has the right permissions - * or was successfully created. - */ -_PUBLIC_ bool directory_create_or_exist(const char *dname, uid_t uid, - mode_t dir_perms); - -/** - Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available, - else - if SYSV use O_NDELAY - if BSD use FNDELAY -**/ -_PUBLIC_ int set_blocking(int fd, bool set); - -/** - Sleep for a specified number of milliseconds. -**/ -_PUBLIC_ void msleep(unsigned int t); - -/** - Get my own name, return in malloc'ed storage. -**/ -_PUBLIC_ char* get_myname(void); - -/** - Return true if a string could be a pure IP address. -**/ -_PUBLIC_ bool is_ipaddress(const char *str); - -/** - Interpret an internet address or name into an IP address in 4 byte form. -**/ -_PUBLIC_ uint32_t interpret_addr(const char *str); - -/** - A convenient addition to interpret_addr(). -**/ -_PUBLIC_ struct in_addr interpret_addr2(const char *str); - -/** - Check if an IP is the 0.0.0.0. -**/ -_PUBLIC_ bool is_zero_ip_v4(struct in_addr ip); - -/** - Are two IPs on the same subnet? -**/ -_PUBLIC_ bool same_net_v4(struct in_addr ip1,struct in_addr ip2,struct in_addr mask); - -_PUBLIC_ bool is_ipaddress_v4(const char *str); - -/** - Check if a process exists. Does this work on all unixes? -**/ -_PUBLIC_ bool process_exists_by_pid(pid_t pid); - -/** - Simple routine to do POSIX file locking. Cruft in NFS and 64->32 bit mapping - is dealt with in posix.c -**/ -_PUBLIC_ bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type); - -/** - malloc that aborts with smb_panic on fail or zero size. -**/ -_PUBLIC_ void *smb_xmalloc(size_t size); - -/** - Memdup with smb_panic on fail. -**/ -_PUBLIC_ void *smb_xmemdup(const void *p, size_t size); - -/** - strdup that aborts on malloc fail. -**/ -_PUBLIC_ char *smb_xstrdup(const char *s); - -char *smb_xstrndup(const char *s, size_t n); - -/** - Like strdup but for memory. -**/ -_PUBLIC_ void *smb_memdup(const void *p, size_t size); - -/** - * see if a range of memory is all zero. A NULL pointer is considered - * to be all zero - */ -_PUBLIC_ bool all_zero(const uint8_t *ptr, size_t size); - -/** - realloc an array, checking for integer overflow in the array size -*/ -_PUBLIC_ void *realloc_array(void *ptr, size_t el_size, unsigned count, bool free_on_fail); - -void *malloc_array(size_t el_size, unsigned int count); - -/* The following definitions come from lib/util/fsusage.c */ - - -/** - * Retrieve amount of free disk space. - * this does all of the system specific guff to get the free disk space. - * It is derived from code in the GNU fileutils package, but has been - * considerably mangled for use here - * - * results are returned in *dfree and *dsize, in 512 byte units -*/ -_PUBLIC_ int sys_fsusage(const char *path, uint64_t *dfree, uint64_t *dsize); - -/* The following definitions come from lib/util/ms_fnmatch.c */ - - -/** - * @file - * @brief MS-style Filename matching - */ - -#if _SAMBA_BUILD_ == 4 -#include "libcli/smb/smb_constants.h" - -int ms_fnmatch(const char *pattern, const char *string, enum protocol_types protocol); - -/** a generic fnmatch function - uses for non-CIFS pattern matching */ -int gen_fnmatch(const char *pattern, const char *string); -#endif - -/* The following definitions come from lib/util/mutex.c */ - - -#ifdef _SAMBA_BUILD_ -/** - register a set of mutex/rwlock handlers. - Should only be called once in the execution of smbd. -*/ -_PUBLIC_ bool register_mutex_handlers(const char *name, struct mutex_ops *ops); -#endif - -/* The following definitions come from lib/util/idtree.c */ - - -/** - initialise a idr tree. The context return value must be passed to - all subsequent idr calls. To destroy the idr tree use talloc_free() - on this context - */ -_PUBLIC_ struct idr_context *idr_init(TALLOC_CTX *mem_ctx); - -/** - allocate the next available id, and assign 'ptr' into its slot. - you can retrieve later this pointer using idr_find() -*/ -_PUBLIC_ int idr_get_new(struct idr_context *idp, void *ptr, int limit); - -/** - allocate a new id, giving the first available value greater than or - equal to the given starting id -*/ -_PUBLIC_ int idr_get_new_above(struct idr_context *idp, void *ptr, int starting_id, int limit); - -/** - allocate a new id randomly in the given range -*/ -_PUBLIC_ int idr_get_new_random(struct idr_context *idp, void *ptr, int limit); - -/** - find a pointer value previously set with idr_get_new given an id -*/ -_PUBLIC_ void *idr_find(struct idr_context *idp, int id); - -/** - remove an id from the idr tree -*/ -_PUBLIC_ int idr_remove(struct idr_context *idp, int id); - -/* The following definitions come from lib/util/become_daemon.c */ - -#if _SAMBA_BUILD_ == 4 -/** - Become a daemon, discarding the controlling terminal. -**/ -_PUBLIC_ void become_daemon(bool fork); -#endif - -/** - * Load a ini-style file. - */ -bool pm_process( const char *fileName, - bool (*sfunc)(const char *, void *), - bool (*pfunc)(const char *, const char *, void *), - void *userdata); - -bool unmap_file(void *start, size_t size); - -#define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr))) - -#endif /* _SAMBA_UTIL_H_ */ diff --git a/ctdb/lib/util/util_file.c b/ctdb/lib/util/util_file.c deleted file mode 100644 index 5db0072..0000000 --- a/ctdb/lib/util/util_file.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - functions taken from samba4 for quick prototyping of ctdb. These are - not intended to remain part of ctdb -*/ - -#include - -#include "includes.h" -#include "system/filesys.h" - - -static char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx) -{ - struct stat sbuf; - char *p; - - if (fstat(fd, &sbuf) != 0) return NULL; - - p = (char *)talloc_size(mem_ctx, sbuf.st_size+1); - if (!p) return NULL; - - if (read(fd, p, sbuf.st_size) != sbuf.st_size) { - talloc_free(p); - return NULL; - } - p[sbuf.st_size] = 0; - - if (size) *size = sbuf.st_size; - - return p; -} - - -static char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx) -{ - int fd; - char *p; - - if (!fname || !*fname) return NULL; - - fd = open(fname,O_RDONLY); - if (fd == -1) return NULL; - - p = fd_load(fd, size, mem_ctx); - - close(fd); - - return p; -} - - -/** -parse a buffer into lines -'p' will be freed on error, and otherwise will be made a child of the returned array -**/ -static char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx) -{ - int i; - char *s, **ret; - - if (!p) return NULL; - - for (s = p, i=0; s < p+size; s++) { - if (s[0] == '\n') i++; - } - - ret = talloc_array(mem_ctx, char *, i+2); - if (!ret) { - talloc_free(p); - return NULL; - } - - talloc_steal(ret, p); - - memset(ret, 0, sizeof(ret[0])*(i+2)); - if (numlines) *numlines = i; - - ret[0] = p; - for (s = p, i=0; s < p+size; s++) { - if (s[0] == '\n') { - s[0] = 0; - i++; - ret[i] = s+1; - } - if (s[0] == '\r') s[0] = 0; - } - - return ret; -} - - -/** -load a file into memory and return an array of pointers to lines in the file -must be freed with talloc_free(). -**/ -_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx) -{ - char *p; - size_t size; - - assert(maxsize == 0); - - p = file_load(fname, &size, mem_ctx); - if (!p) return NULL; - - return file_lines_parse(p, size, numlines, mem_ctx); -} - -char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len) -{ - int i; - char *hex_buffer; - - hex_buffer = talloc_array(mem_ctx, char, (len*2)+1); - - for (i = 0; i < len; i++) - slprintf(&hex_buffer[i*2], 3, "%02X", buff_in[i]); - - return hex_buffer; -} diff --git a/ctdb/lib/util/util_time.c b/ctdb/lib/util/util_time.c deleted file mode 100644 index 13ddfdb..0000000 --- a/ctdb/lib/util/util_time.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - functions taken from samba4 for quick prototyping of ctdb. These are - not intended to remain part of ctdb -*/ - -#include "includes.h" -#include "system/time.h" -#include "system/filesys.h" - - -/** - return a zero timeval -*/ -struct timeval timeval_zero(void) -{ - struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = 0; - return tv; -} - -/** - return True if a timeval is zero -*/ -bool timeval_is_zero(const struct timeval *tv) -{ - return tv->tv_sec == 0 && tv->tv_usec == 0; -} - -/** - return a timeval for the current time -*/ -struct timeval timeval_current(void) -{ - struct timeval tv; - gettimeofday(&tv, NULL); - return tv; -} - -double timeval_elapsed(struct timeval *tv) -{ - struct timeval tv2 = timeval_current(); - return (tv2.tv_sec - tv->tv_sec) + - (tv2.tv_usec - tv->tv_usec)*1.0e-6; -} - -/** - return a timeval struct with the given elements -*/ -_PUBLIC_ struct timeval timeval_set(uint32_t secs, uint32_t usecs) -{ - struct timeval tv; - tv.tv_sec = secs; - tv.tv_usec = usecs; - return tv; -} - -_PUBLIC_ int timeval_compare(const struct timeval *tv1, const struct timeval *tv2) -{ - if (tv1->tv_sec > tv2->tv_sec) return 1; - if (tv1->tv_sec < tv2->tv_sec) return -1; - if (tv1->tv_usec > tv2->tv_usec) return 1; - if (tv1->tv_usec < tv2->tv_usec) return -1; - return 0; -} - -_PUBLIC_ struct timeval timeval_until(const struct timeval *tv1, - const struct timeval *tv2) -{ - struct timeval t; - if (timeval_compare(tv1, tv2) >= 0) { - return timeval_zero(); - } - t.tv_sec = tv2->tv_sec - tv1->tv_sec; - if (tv1->tv_usec > tv2->tv_usec) { - t.tv_sec--; - t.tv_usec = 1000000 - (tv1->tv_usec - tv2->tv_usec); - } else { - t.tv_usec = tv2->tv_usec - tv1->tv_usec; - } - return t; -} - -static struct timeval timeval_add(const struct timeval *tv, - uint32_t secs, uint32_t usecs) -{ - struct timeval tv2 = *tv; - const unsigned int million = 1000000; - tv2.tv_sec += secs; - tv2.tv_usec += usecs; - tv2.tv_sec += tv2.tv_usec / million; - tv2.tv_usec = tv2.tv_usec % million; - return tv2; -} - - -_PUBLIC_ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs) -{ - struct timeval tv = timeval_current(); - return timeval_add(&tv, secs, usecs); -} - diff --git a/ctdb/lib/util/wscript_build b/ctdb/lib/util/wscript_build deleted file mode 100755 index fb88814..0000000 --- a/ctdb/lib/util/wscript_build +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python - -bld.SAMBA_SUBSYSTEM('ctdb-util', - source='''util.c util_file.c util_time.c - debug.c fault.c idtree.c signal.c - substitute.c''', - deps='tdb talloc tevent execinfo', - local_include=False, - ) diff --git a/ctdb/packaging/RPM/ctdb.spec.in b/ctdb/packaging/RPM/ctdb.spec.in index 816520a..42d70de 100644 --- a/ctdb/packaging/RPM/ctdb.spec.in +++ b/ctdb/packaging/RPM/ctdb.spec.in @@ -88,7 +88,7 @@ fi export CC CFLAGS="$RPM_OPT_FLAGS $EXTRA -D_GNU_SOURCE" ./buildtools/bin/waf configure \ - --builtin-libraries=replace,popt \ + --builtin-libraries=replace,popt,samba-debug,socket-blocking,tdb-wrap \ --bundled-libraries=!talloc,!tevent,!tdb \ --minimum-library-version=talloc:%libtalloc_version,tdb:%libtdb_version,tevent:%libtevent_version \ %if %with_pcp_pmda diff --git a/ctdb/wscript b/ctdb/wscript index 969c034..3858ac7 100755 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -32,12 +32,18 @@ samba_dist.DIST_DIRS('''ctdb:. lib/replace:lib/replace lib/talloc:lib/talloc lib/tevent:lib/tevent lib/tdb:lib/tdb lib/socket_wrapper:lib/socket_wrapper third_party/popt:third_party/popt + lib/util:lib/util lib/tdb_wrap:lib/tdb_wrap + lib/ccan:lib/ccan libcli/util:libcli/util buildtools:buildtools''') def set_options(opt): opt.PRIVATE_EXTENSION_DEFAULT('ctdb') + opt.RECURSE('lib/replace') + + opt.RECURSE('lib/util') + opt.RECURSE('lib/talloc') opt.RECURSE('lib/tevent') opt.RECURSE('lib/tdb') @@ -67,6 +73,12 @@ def configure(conf): Options.options.disable_python = True conf.RECURSE('lib/replace') + + conf.SAMBA_CHECK_PERL(mandatory=True) + + conf.SAMBA_CHECK_PYTHON(mandatory=True, version=(2,5,0)) + conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True) + if conf.CHECK_FOR_THIRD_PARTY(): conf.RECURSE('third_party/popt') else: @@ -75,6 +87,8 @@ def configure(conf): else: conf.define('USING_SYSTEM_POPT', 1) + conf.RECURSE('lib/util') + conf.RECURSE('lib/talloc') conf.RECURSE('lib/tevent') conf.RECURSE('lib/tdb') @@ -180,7 +194,8 @@ def configure(conf): 'share/ctdb-tests') conf.env.CTDB_TEST_LIBDIR = os.path.join(conf.env.LIBDIR, 'ctdb-tests') - # Allow separate compilation of utilities to find includes + # Allow unified compilation and separate compilation of utilities + # to find includes if srcdir == '.': # Building from tarball conf.ADD_EXTRA_INCLUDES('#include') @@ -190,8 +205,15 @@ def configure(conf): conf.ADD_EXTRA_INCLUDES('#ctdb/include') conf.ADD_EXTRA_INCLUDES('#ctdb/include/internal') conf.ADD_EXTRA_INCLUDES('#ctdb') + conf.ADD_EXTRA_INCLUDES('#lib #lib/replace') + + conf.SET_TARGET_TYPE('systemd-daemon', 'EMPTY') + + del(conf.env.defines['PYTHONDIR']) + del(conf.env.defines['PYTHONARCHDIR']) conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True) + conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True) conf.SAMBA_CONFIG_H() @@ -223,6 +245,15 @@ def build(bld): bld.RECURSE('lib/tdb') bld.RECURSE('lib/socket_wrapper') + # When a combined build is implemented, CTDB will wanted to build + # against samba-util rather than samba-util-core. Similarly, + # other Samba subsystems expect samba-util. So, for a standalone + # build, just define a fake samba-util subsystem that pulls in + # samba-util-core. + bld.SAMBA_SUBSYSTEM('samba-util', + source='', + deps='samba-util-core') + bld.SAMBA_SUBSYSTEM('ctdb-tcp', source=bld.SUBDIR('tcp', 'tcp_connect.c tcp_init.c tcp_io.c'), @@ -276,7 +307,7 @@ def build(bld): includes='include include/internal', public_headers='include/ctdb_client.h', deps='''replace popt talloc tevent tdb - ctdb-util tdb-wrap''') + samba-util tdb-wrap''') bld.SAMBA_SUBSYSTEM('ctdb-server', source='server/ctdbd.c ' + @@ -326,14 +357,14 @@ def build(bld): bld.SAMBA_BINARY('ctdb_lock_helper', source='server/ctdb_lock_helper.c', - deps='ctdb-util ctdb-common-util talloc tdb', + deps='samba-util ctdb-common-util talloc tdb', includes='include include/internal', install_path='${BINDIR}') bld.SAMBA_BINARY('ctdb_event_helper', source='server/ctdb_event_helper.c', includes='include include/internal', - deps='ctdb-util ctdb-common-util replace tdb', + deps='samba-util ctdb-common-util replace tdb', install_path='${BINDIR}') bld.SAMBA_GENERATOR('ctdb-smnotify-h', @@ -491,7 +522,7 @@ def build(bld): bld.SAMBA_BINARY('ctdb_takeover_tests', source='tests/src/ctdb_takeover_tests.c', deps='''replace popt tdb tevent talloc ctdb-system - ctdb-util tdb-wrap''' + + samba-util tdb-wrap''' + ib_deps, includes='include include/internal', install_path='${CTDB_TEST_LIBDIR}') @@ -499,14 +530,14 @@ def build(bld): bld.SAMBA_BINARY('ctdb_functest', source='tests/src/ctdb_functest.c', deps='''replace tdb tevent talloc popt ctdb-system - ctdb-util tdb-wrap''', + samba-util tdb-wrap''', includes='include include/internal', install_path='${CTDB_TEST_LIBDIR}') bld.SAMBA_BINARY('ctdb_stubtest', source='tests/src/ctdb_test.c', deps='''replace tdb tevent talloc popt ctdb-system - ctdb-util tdb-wrap''', + samba-util tdb-wrap''', includes='include include/internal', install_path='${CTDB_TEST_LIBDIR}') -- 2.1.1 From e277c7594da0ca895ab5edc3547f6a4494663b26 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 29 Aug 2014 21:17:30 +1000 Subject: [PATCH 19/34] ctdb-build: Fix handling of public headers Add the header munging, add/package ctdb_version.h, create directory include/public. Signed-off-by: Martin Schwenke Reviewed-by: Volker Lendecke Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Mon Oct 6 14:56:07 CEST 2014 on sn-devel-104 (cherry picked from commit 88b24858d887278f4787081dacff2409259fcf42) --- ctdb/include/public/README.txt | 6 ++++++ ctdb/packaging/RPM/ctdb.spec.in | 1 + ctdb/wscript | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 ctdb/include/public/README.txt diff --git a/ctdb/include/public/README.txt b/ctdb/include/public/README.txt new file mode 100644 index 0000000..534e9b7 --- /dev/null +++ b/ctdb/include/public/README.txt @@ -0,0 +1,6 @@ +DO NOT REMOVE + +This is a placeholder to allow for build rules putting public headers +in this directory. Using this directory allows us to ensure that our +public headers will work with external applications that make use of +Samba libraries diff --git a/ctdb/packaging/RPM/ctdb.spec.in b/ctdb/packaging/RPM/ctdb.spec.in index 42d70de..f6f5d89 100644 --- a/ctdb/packaging/RPM/ctdb.spec.in +++ b/ctdb/packaging/RPM/ctdb.spec.in @@ -225,6 +225,7 @@ development libraries for ctdb %{_includedir}/ctdb_protocol.h %{_includedir}/ctdb_private.h %{_includedir}/ctdb_typesafe_cb.h +%{_includedir}/ctdb_version.h %package tests Summary: CTDB test suite diff --git a/ctdb/wscript b/ctdb/wscript index 3858ac7..2802b78 100755 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -218,6 +218,9 @@ def configure(conf): def build(bld): + # enable building of public headers in the build tree + bld.env.build_public_headers = 'include/public' + t = bld.SAMBA_GENERATOR('ctdb-version-header', target='include/ctdb_version.h', rule='../packaging/mkversion.sh ${TGT} %s' % (VERSION), @@ -326,7 +329,8 @@ def build(bld): ctdb_update_record.c ctdb_lock.c'''), includes='include include/internal', - public_headers='''include/ctdb.h + public_headers='''include/ctdb_version.h + include/ctdb.h include/ctdb_private.h include/ctdb_protocol.h include/ctdb_typesafe_cb.h''', -- 2.1.1 From 6bb93d629ba3ffe46d14406acbe1e3c6d17bf502 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 26 Sep 2014 15:42:34 +1000 Subject: [PATCH 20/34] ctdb-build: Rename define BINDIR to CTDB_HELPER_BINDIR This avoids a clash with Samba's BINDIR and also makes it easier to move the helpers to somewhere else (e.g. libexec) in the future. Signed-off-by: Martin Schwenke Reviewed-by: Andrew Bartlett (cherry picked from commit 6b98ddc54fe20367a60601c4b430c73408e7e1c5) --- ctdb/server/ctdb_lock.c | 2 +- ctdb/server/eventscript.c | 2 +- ctdb/wscript | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c index 3a9b327..22a88b3 100644 --- a/ctdb/server/ctdb_lock.c +++ b/ctdb/server/ctdb_lock.c @@ -724,7 +724,7 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb) struct lock_context *lock_ctx; int ret, argc; TALLOC_CTX *tmp_ctx; - const char *helper = BINDIR "/ctdb_lock_helper"; + const char *helper = CTDB_HELPER_BINDIR "/ctdb_lock_helper"; static const char *prog = NULL; const char **args; diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c index 447a83c..28bbb54 100644 --- a/ctdb/server/eventscript.c +++ b/ctdb/server/eventscript.c @@ -271,7 +271,7 @@ static int fork_child_for_script(struct ctdb_context *ctdb, struct ctdb_script_wire *current = get_current_script(state); int argc; const char **argv; - static const char *helper = BINDIR "/ctdb_event_helper"; + static const char *helper = CTDB_HELPER_BINDIR "/ctdb_event_helper"; if (helper_prog == NULL) { const char *t = getenv("CTDB_EVENT_HELPER"); diff --git a/ctdb/wscript b/ctdb/wscript index 2802b78..9f4a7a9 100755 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -177,7 +177,7 @@ def configure(conf): conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR, 'ctdbd.socket') - conf.ADD_CFLAGS('''-DBINDIR=\"%s\" + conf.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\" -DLOGDIR=\"%s\" -DSOCKPATH=\"%s\" -DCTDB_ETCDIR=\"%s\" -- 2.1.1 From 820b9637e8c4bb58b27693b735b260a059f2c42c Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 25 Aug 2014 13:46:00 +1000 Subject: [PATCH 21/34] ctdb-build: Make some steps conditional on standalone build CTDB's current wscript assumes that it is only used as part of a standalone build. However, it will soon be part of a unified build so make some steps conditional. Signed-off-by: Martin Schwenke Reviewed-by: Andrew Bartlett (cherry picked from commit d568be69891da3944df2de8629e7e64bc480ad86) --- ctdb/wscript | 86 ++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/ctdb/wscript b/ctdb/wscript index 9f4a7a9..788aa5e 100755 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -70,14 +70,16 @@ def configure(conf): # No need to build python bindings for talloc/tevent/tdb if conf.IN_LAUNCH_DIR(): + conf.env.standalone_ctdb = True Options.options.disable_python = True conf.RECURSE('lib/replace') - conf.SAMBA_CHECK_PERL(mandatory=True) + if conf.env.standalone_ctdb: + conf.SAMBA_CHECK_PERL(mandatory=True) - conf.SAMBA_CHECK_PYTHON(mandatory=True, version=(2,5,0)) - conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True) + conf.SAMBA_CHECK_PYTHON(mandatory=True, version=(2,5,0)) + conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True) if conf.CHECK_FOR_THIRD_PARTY(): conf.RECURSE('third_party/popt') @@ -196,45 +198,54 @@ def configure(conf): # Allow unified compilation and separate compilation of utilities # to find includes - if srcdir == '.': - # Building from tarball - conf.ADD_EXTRA_INCLUDES('#include') - conf.ADD_EXTRA_INCLUDES('#include/internal') - else: - # Building standalone CTDB from within Samba tree + if not conf.env.standalone_ctdb: conf.ADD_EXTRA_INCLUDES('#ctdb/include') - conf.ADD_EXTRA_INCLUDES('#ctdb/include/internal') - conf.ADD_EXTRA_INCLUDES('#ctdb') - conf.ADD_EXTRA_INCLUDES('#lib #lib/replace') + else: + if srcdir == '.': + # Building from tarball + conf.ADD_EXTRA_INCLUDES('#include') + conf.ADD_EXTRA_INCLUDES('#include/internal') + else: + # Building standalone CTDB from within Samba tree + conf.ADD_EXTRA_INCLUDES('#ctdb/include') + conf.ADD_EXTRA_INCLUDES('#ctdb/include/internal') + conf.ADD_EXTRA_INCLUDES('#ctdb') + conf.ADD_EXTRA_INCLUDES('#lib #lib/replace') - conf.SET_TARGET_TYPE('systemd-daemon', 'EMPTY') + conf.SET_TARGET_TYPE('systemd-daemon', 'EMPTY') - del(conf.env.defines['PYTHONDIR']) - del(conf.env.defines['PYTHONARCHDIR']) + del(conf.env.defines['PYTHONDIR']) + del(conf.env.defines['PYTHONARCHDIR']) - conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True) - conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True) - conf.SAMBA_CONFIG_H() + conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True) + conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True) + conf.SAMBA_CONFIG_H() def build(bld): - # enable building of public headers in the build tree - bld.env.build_public_headers = 'include/public' + if bld.env.standalone_ctdb: + # enable building of public headers in the build tree + bld.env.build_public_headers = 'include/public' + if bld.env.standalone_ctdb: + ctdb_mkversion = '../packaging/mkversion.sh' + else: + ctdb_mkversion = '../ctdb/packaging/mkversion.sh' t = bld.SAMBA_GENERATOR('ctdb-version-header', target='include/ctdb_version.h', - rule='../packaging/mkversion.sh ${TGT} %s' % (VERSION), + rule='%s ${TGT} %s' % (ctdb_mkversion, VERSION), dep_vars=['VERSION']) t.env.VERSION = VERSION - version_h = samba_utils.os_path_relpath(os.path.join(Options.launch_dir, - "version.h"), - bld.curdir) - t.bld.SAMBA_GENERATOR('ctdb-samba-version-header', - target=version_h, - rule='printf "#include \\"ctdb_version.h\\" \\n#define SAMBA_VERSION_STRING CTDB_VERSION_STRING\\n" > ${TGT}', - dep_vars=['VERSION']) - t.env.VERSION = VERSION + if bld.env.standalone_ctdb: + version_h = samba_utils.os_path_relpath(os.path.join(Options.launch_dir, + "version.h"), + bld.curdir) + t.bld.SAMBA_GENERATOR('ctdb-samba-version-header', + target=version_h, + rule='printf "#include \\"ctdb_version.h\\" \\n#define SAMBA_VERSION_STRING CTDB_VERSION_STRING\\n" > ${TGT}', + dep_vars=['VERSION']) + t.env.VERSION = VERSION bld.RECURSE('lib/replace') if bld.CHECK_FOR_THIRD_PARTY(): @@ -248,14 +259,15 @@ def build(bld): bld.RECURSE('lib/tdb') bld.RECURSE('lib/socket_wrapper') - # When a combined build is implemented, CTDB will wanted to build - # against samba-util rather than samba-util-core. Similarly, - # other Samba subsystems expect samba-util. So, for a standalone - # build, just define a fake samba-util subsystem that pulls in - # samba-util-core. - bld.SAMBA_SUBSYSTEM('samba-util', - source='', - deps='samba-util-core') + if bld.env.standalone_ctdb: + # In a combined build is implemented, CTDB will wanted to + # build against samba-util rather than samba-util-core. + # Similarly, other Samba subsystems expect samba-util. So, + # for a standalone build, just define a fake samba-util + # subsystem that pulls in samba-util-core. + bld.SAMBA_SUBSYSTEM('samba-util', + source='', + deps='samba-util-core') bld.SAMBA_SUBSYSTEM('ctdb-tcp', source=bld.SUBDIR('tcp', -- 2.1.1 From 544644ff01465ac3a10d9d4f56714bd213c55de3 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 25 Aug 2014 14:05:48 +1000 Subject: [PATCH 22/34] build: Hook CTDB into top level build using --with-cluster-support Signed-off-by: Martin Schwenke Reviewed-by: Andrew Bartlett Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Wed Oct 8 09:42:08 CEST 2014 on sn-devel-104 (cherry picked from commit e94422a8acf4a812ed19ddd63b42789df49a3f00) --- wscript | 4 ++++ wscript_build | 2 ++ 2 files changed, 6 insertions(+) diff --git a/wscript b/wscript index 73c113c..7124e57 100644 --- a/wscript +++ b/wscript @@ -43,6 +43,7 @@ def set_options(opt): opt.RECURSE('pidl') opt.RECURSE('source3') opt.RECURSE('lib/util') + opt.RECURSE('ctdb') opt.add_option('--with-system-mitkrb5', help='enable system MIT krb5 build (includes Samba 4 client and Samba 3 code base).'+ @@ -166,6 +167,9 @@ def configure(conf): conf.RECURSE('selftest') conf.RECURSE('source3') conf.RECURSE('lib/texpect') + if Options.options.with_cluster_support: + conf.env.with_ctdb = True + conf.RECURSE('ctdb') conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS() diff --git a/wscript_build b/wscript_build index 48cb71d..d7dea54 100644 --- a/wscript_build +++ b/wscript_build @@ -139,6 +139,8 @@ bld.RECURSE('libcli/smbreadline') bld.RECURSE('codepages') if bld.AD_DC_BUILD_IS_ENABLED(): bld.RECURSE('source4/setup') +if bld.env.with_ctdb: + bld.RECURSE('ctdb') bld.RECURSE('source4/scripting') bld.RECURSE('pidl') bld.RECURSE('lib') -- 2.1.1 From 78be14cc21045ce016a225417071274a474ae5e0 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 15 Oct 2014 20:04:45 +1100 Subject: [PATCH 23/34] ctdb-logging: Add missing newline when logging to file This got lost with the transition to the new Samba debug code. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit 96106e085a3a8bab51c8b14e85ba1a817d5fa55b) --- ctdb/server/ctdb_logging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ctdb/server/ctdb_logging.c b/ctdb/server/ctdb_logging.c index 3aba37b..e09aa94 100644 --- a/ctdb/server/ctdb_logging.c +++ b/ctdb/server/ctdb_logging.c @@ -296,7 +296,7 @@ static void ctdb_logfile_log(void *private_ptr, int dbglevel, const char *s) strftime(tbuf,sizeof(tbuf)-1,"%Y/%m/%d %H:%M:%S", tm); - ret = asprintf(&s2, "%s.%06u [%s%5u]: %s", + ret = asprintf(&s2, "%s.%06u [%s%5u]: %s\n", tbuf, (unsigned)t.tv_usec, debug_extra, (unsigned)getpid(), s); if (ret == -1) { -- 2.1.1 From f20c9f65f8a8d8706b51224aab1d9187eb15e8f3 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Fri, 10 Oct 2014 10:59:06 +1100 Subject: [PATCH 24/34] build: Remove configure option --enable-old-ctdb CTDB source is now part of Samba tree and to enable clustering smbd should be built against included CTDB. Signed-off-by: Amitay Isaacs Reviewed-by: Michael Adam (cherry picked from commit 5e7ab5ce38689a2dd1e921abf58af346b730a843) --- source3/wscript | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/source3/wscript b/source3/wscript index b285c5f..36d54b2 100644 --- a/source3/wscript +++ b/source3/wscript @@ -55,9 +55,6 @@ def set_options(opt): opt.add_option('--with-ctdb-dir', help=("Directory under which ctdb is installed"), action="store", dest='ctdb_dir', default=None) - opt.add_option('--enable-old-ctdb', - help=("enable building against (too) old version of ctdb (default=false)"), - action="store_true", dest='enable_old_ctdb', default=False) opt.add_option('--with-libcephfs', help=("Directory under which libcephfs is installed"), @@ -1612,11 +1609,8 @@ main() { if ok: CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL=1' else: - if not Options.options.enable_old_ctdb: - have_cluster_support = False - ctdb_broken = "SCHEDULE_FOR_DELETION control missing" - else: - Logs.warn("ignoring missing SCHEDULE_FOR_DELETION control (--enable-old-ctdb)") + have_cluster_support = False + ctdb_broken = "SCHEDULE_FOR_DELETION control missing" conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') if have_cluster_support: @@ -1642,11 +1636,8 @@ main() { if ok: CTDB_CFLAGS += ' -DHAVE_CTDB_WANT_READONLY_DECL=1' else: - if not Options.options.enable_old_ctdb: - have_cluster_support = False - ctdb_broken = "support for CTDB readonly records missing" - else: - Logs.warn("ignoring missing READONLY support (--enable-old-ctdb)") + have_cluster_support = False + ctdb_broken = "support for CTDB readonly records missing" conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') if have_cluster_support: @@ -1726,11 +1717,8 @@ main() { if ok: CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL=1' else: - if not Options.options.enable_old_ctdb: - have_cluster_support = False - ctdb_broken = "CHECK_SRVIDS control missing" - else: - Logs.warn("ignoring missing CHECK_SRVIDS control (--enable-old-ctdb)") + have_cluster_support = False + ctdb_broken = "CHECK_SRVIDS control missing" conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') conf.undefine('HAVE_CTDB_CHECK_CODE') -- 2.1.1 From 5d99604495a61476f666b84349b7a5bc32b3dffc Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Fri, 10 Oct 2014 10:54:15 +1100 Subject: [PATCH 25/34] build: Remove checks for ctdb features Since we are always building with integrated CTDB, there is no need for these checks. Signed-off-by: Amitay Isaacs Reviewed-by: Michael Adam (cherry picked from commit 18100b80b9c62833df22638828336294c9740ae0) --- source3/lib/cluster_support.c | 18 ----- source3/lib/ctdbd_conn.c | 16 ---- source3/lib/dbwrap/dbwrap_ctdb.c | 11 --- source3/wscript | 164 --------------------------------------- 4 files changed, 209 deletions(-) diff --git a/source3/lib/cluster_support.c b/source3/lib/cluster_support.c index d6605fd..e2aef7b 100644 --- a/source3/lib/cluster_support.c +++ b/source3/lib/cluster_support.c @@ -62,24 +62,6 @@ const char *cluster_support_features(void) #ifdef HAVE_CTDB_PROTOCOL_H _LINE_DEF(HAVE_CTDB_PROTOCOL_H) #endif -#ifdef HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL - _LINE_DEF(HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL) -#endif -#ifdef HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL - _LINE_DEF(HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL) -#endif -#ifdef HAVE_CTDB_WANT_READONLY_DECL - _LINE_DEF(HAVE_CTDB_WANT_READONLY_DECL) -#endif -#ifdef HAVE_STRUCT_CTDB_CONTROL_TCP - _LINE_DEF(HAVE_STRUCT_CTDB_CONTROL_TCP) -#endif -#ifdef HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR - _LINE_DEF(HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR) -#endif -#ifdef HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL - _LINE_DEF(HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL) -#endif #ifdef CTDB_PATH _LINE_STR(CTDB_PATH) #endif diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index a667482..fe3e25a 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -1110,20 +1110,13 @@ fail: bool ctdb_serverids_exist_supported(struct ctdbd_connection *conn) { -#ifndef HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL - return false; -#else /* HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL */ return true; -#endif /* HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL */ } bool ctdb_serverids_exist(struct ctdbd_connection *conn, const struct server_id *pids, unsigned num_pids, bool *results) { -#ifndef HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL - return false; -#else /* HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL */ unsigned i, num_received; NTSTATUS status; struct ctdb_vnn_list *vnns = NULL; @@ -1267,7 +1260,6 @@ bool ctdb_serverids_exist(struct ctdbd_connection *conn, fail: cluster_fatal("serverids_exist failed"); return false; -#endif /* HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL */ } /* @@ -1421,11 +1413,7 @@ NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id, NTSTATUS status; uint32_t flags; -#ifdef HAVE_CTDB_WANT_READONLY_DECL flags = local_copy ? CTDB_WANT_READONLY : 0; -#else - flags = 0; -#endif ZERO_STRUCT(req); @@ -1633,9 +1621,7 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn, * versions at runtime */ struct ctdb_control_tcp p4; -#ifdef HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR struct ctdb_control_tcp_addr p; -#endif TDB_DATA data; NTSTATUS status; struct sockaddr_storage client; @@ -1656,14 +1642,12 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn, data.dptr = (uint8_t *)&p4; data.dsize = sizeof(p4); break; -#ifdef HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR case AF_INET6: memcpy(&p.dest.ip6, &server, sizeof(p.dest.ip6)); memcpy(&p.src.ip6, &client, sizeof(p.src.ip6)); data.dptr = (uint8_t *)&p; data.dsize = sizeof(p); break; -#endif default: return NT_STATUS_INTERNAL_ERROR; } diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c index 0b30d9f..2aee435 100644 --- a/source3/lib/dbwrap/dbwrap_ctdb.c +++ b/source3/lib/dbwrap/dbwrap_ctdb.c @@ -867,7 +867,6 @@ static NTSTATUS db_ctdb_store(struct db_record *rec, TDB_DATA data, int flag) -#ifdef HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL static NTSTATUS db_ctdb_send_schedule_for_deletion(struct db_record *rec) { NTSTATUS status; @@ -911,7 +910,6 @@ static NTSTATUS db_ctdb_send_schedule_for_deletion(struct db_record *rec) return status; } -#endif static NTSTATUS db_ctdb_delete(struct db_record *rec) { @@ -927,10 +925,7 @@ static NTSTATUS db_ctdb_delete(struct db_record *rec) return status; } -#ifdef HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL status = db_ctdb_send_schedule_for_deletion(rec); -#endif - return status; } @@ -999,7 +994,6 @@ static int db_ctdb_record_destr(struct db_record* data) static bool db_ctdb_can_use_local_hdr(const struct ctdb_ltdb_header *hdr, bool read_only) { -#ifdef HAVE_CTDB_WANT_READONLY_DECL if (hdr->dmaster != get_my_vnn()) { /* If we're not dmaster, it must be r/o copy. */ return read_only && (hdr->flags & CTDB_REC_RO_HAVE_READONLY); @@ -1009,9 +1003,6 @@ static bool db_ctdb_can_use_local_hdr(const struct ctdb_ltdb_header *hdr, * If we want write access, no one may have r/o copies. */ return read_only || !(hdr->flags & CTDB_REC_RO_HAVE_DELEGATIONS); -#else - return (hdr->dmaster == get_my_vnn()); -#endif } static bool db_ctdb_can_use_local_copy(TDB_DATA ctdb_data, bool read_only) @@ -1638,7 +1629,6 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx, return NULL; } -#ifdef HAVE_CTDB_WANT_READONLY_DECL if (!result->persistent && (dbwrap_flags & DBWRAP_FLAG_OPTIMIZE_READONLY_ACCESS)) { @@ -1657,7 +1647,6 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx, return NULL; } } -#endif lp_ctx = loadparm_init_s3(db_path, loadparm_s3_helpers()); diff --git a/source3/wscript b/source3/wscript index 36d54b2..4db9dc2 100644 --- a/source3/wscript +++ b/source3/wscript @@ -1556,170 +1556,6 @@ main() { if ok: CTDB_CFLAGS += ' -DHAVE_CTDB_PROTOCOL_H=1' - conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') - if have_cluster_support: - ok = conf.CHECK_CODE(''' - #define NO_CONFIG_H - #include "replace.h" - #include "system/wait.h" - #include "system/network.h" - #include - #include - #include - #include - - int main(void) - { - int i = (int)CTDB_CONTROL_TRANS3_COMMIT; - return 0; - } - ''', - 'HAVE_CTDB_CHECK_CODE', - addmain=False, - includes=includes, - msg='Checking for transaction support (TRANS3_COMMIT control)') - if ok: - CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL=1' - else: - have_cluster_support = False - ctdb_broken = "ctdb transaction support missing or too old" - - conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') - if have_cluster_support: - ok = conf.CHECK_CODE(''' - #define NO_CONFIG_H - #include "replace.h" - #include "system/wait.h" - #include "system/network.h" - #include - #include - #include - #include - - int main(void) - { - int i = (int)CTDB_CONTROL_SCHEDULE_FOR_DELETION; - return 0; - } - ''', - 'HAVE_CTDB_CHECK_CODE', - addmain=False, - includes=includes, - msg='Checking for SCHEDULE_FOR_DELETION control') - if ok: - CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL=1' - else: - have_cluster_support = False - ctdb_broken = "SCHEDULE_FOR_DELETION control missing" - - conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') - if have_cluster_support: - ok = conf.CHECK_CODE(''' - #define NO_CONFIG_H - #include "replace.h" - #include "system/wait.h" - #include "system/network.h" - #include - #include - #include - - int main(void) - { - int i = (int)CTDB_WANT_READONLY; - return 0; - } - ''', - 'HAVE_CTDB_CHECK_CODE', - addmain=False, - includes=includes, - msg='Checking for CTDB readonly records support') - if ok: - CTDB_CFLAGS += ' -DHAVE_CTDB_WANT_READONLY_DECL=1' - else: - have_cluster_support = False - ctdb_broken = "support for CTDB readonly records missing" - - conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') - if have_cluster_support: - ok = conf.CHECK_CODE(''' - #define NO_CONFIG_H - #include "replace.h" - #include "system/wait.h" - #include "system/network.h" - #include - #include - #include - #include - - int main(void) - { - struct ctdb_control_tcp _x; - return 0; - } - ''', - 'HAVE_CTDB_CHECK_CODE', - addmain=False, - includes=includes, - msg='Checking for ctdb ipv4 support') - if ok: - CTDB_CFLAGS += ' -DHAVE_STRUCT_CTDB_CONTROL_TCP=1' - else: - have_cluster_support = False - ctdb_broken = "missing struct ctdb_control_tcp" - - conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') - if have_cluster_support: - ok = conf.CHECK_CODE(''' - #define NO_CONFIG_H - #include "replace.h" - #include "system/wait.h" - #include "system/network.h" - #include - #include - #include - #include - - int main(void) - { - struct ctdb_control_tcp_addr _x; - return 0; - } - ''', - 'HAVE_CTDB_CHECK_CODE', - addmain=False, - includes=includes, - msg='Checking for ctdb ipv6 support') - if ok: - CTDB_CFLAGS += ' -DHAVE_STRUCT_CTDB_CONTROL_TCP_ADDR=1' - - conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') - if have_cluster_support: - ok = conf.CHECK_CODE(''' - #define NO_CONFIG_H - #include "replace.h" - #include "system/wait.h" - #include "system/network.h" - #include - #include - #include - #include - - int main(void) - { - int i = (int)CTDB_CONTROL_CHECK_SRVIDS; - return 0; - } - ''', - 'HAVE_CTDB_CHECK_CODE', - addmain=False, - includes=includes, - msg='Checking for CHECK_SRVIDS control') - if ok: - CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL=1' - else: - have_cluster_support = False - ctdb_broken = "CHECK_SRVIDS control missing" - conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') conf.undefine('HAVE_CTDB_CHECK_CODE') if have_cluster_support: -- 2.1.1 From 30bd5fe17de507d9c0c6e815d4667bfddd387e7f Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Fri, 10 Oct 2014 11:42:05 +1100 Subject: [PATCH 26/34] build: Remove configure option --with-ctdb-dir Signed-off-by: Amitay Isaacs Reviewed-by: Michael Adam (cherry picked from commit 9933028a657f01d7ff9db5fca19887f5e0523299) --- source3/wscript | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/source3/wscript b/source3/wscript index 4db9dc2..241f0fd 100644 --- a/source3/wscript +++ b/source3/wscript @@ -52,10 +52,6 @@ def set_options(opt): opt.SAMBA3_ADD_OPTION('fake-kaserver', help=("Include AFS fake-kaserver support"), default=False) - opt.add_option('--with-ctdb-dir', - help=("Directory under which ctdb is installed"), - action="store", dest='ctdb_dir', default=None) - opt.add_option('--with-libcephfs', help=("Directory under which libcephfs is installed"), action="store", dest='libcephfs_dir', default=None) @@ -1466,10 +1462,7 @@ main() { else: includes = '' - if Options.options.ctdb_dir: - CTDB_INCLUDE = Options.options.ctdb_dir + '/include' - else: - CTDB_INCLUDE = conf.srcdir + '/ctdb/include' + CTDB_INCLUDE = conf.srcdir + '/ctdb/include' includes = includes + ' ' + CTDB_INCLUDE if not conf.env.USING_SYSTEM_TDB: -- 2.1.1 From ad0fef18c4a16dde060d87a577cea7f447d60326 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Fri, 10 Oct 2014 12:02:26 +1100 Subject: [PATCH 27/34] ctdb: Rename ctdb socket variable from CTDB_PATH to CTDB_SOCKET Signed-off-by: Amitay Isaacs Reviewed-by: Michael Adam (cherry picked from commit 0d5ecaa2e38b55e981cb2770a945d14ab1d98589) --- ctdb/client/ctdb_client.c | 2 +- ctdb/include/ctdb_protocol.h | 4 ++-- ctdb/utils/pmda/pmda_ctdb.c | 2 +- source3/lib/cluster_support.c | 4 ++-- source3/lib/ctdbd_conn.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c index 7d629db..424937a 100644 --- a/ctdb/client/ctdb_client.c +++ b/ctdb/client/ctdb_client.c @@ -3375,7 +3375,7 @@ struct ctdb_context *ctdb_init(struct event_context *ev) ctdb->lastid = INT_MAX-200; CTDB_NO_MEMORY_NULL(ctdb, ctdb->idr); - ret = ctdb_set_socketname(ctdb, CTDB_PATH); + ret = ctdb_set_socketname(ctdb, CTDB_SOCKET); if (ret != 0) { DEBUG(DEBUG_ERR,(__location__ " ctdb_set_socketname failed.\n")); talloc_free(ctdb); diff --git a/ctdb/include/ctdb_protocol.h b/ctdb/include/ctdb_protocol.h index 61d5735..72161af 100644 --- a/ctdb/include/ctdb_protocol.h +++ b/ctdb/include/ctdb_protocol.h @@ -22,9 +22,9 @@ /* location of daemon socket, set at configure time */ #ifdef SOCKPATH -#define CTDB_PATH SOCKPATH +#define CTDB_SOCKET SOCKPATH #else -#define CTDB_PATH "/var/run/ctdb/ctdbd.socket" +#define CTDB_SOCKET "/var/run/ctdb/ctdbd.socket" #endif /* default ctdb port number */ diff --git a/ctdb/utils/pmda/pmda_ctdb.c b/ctdb/utils/pmda/pmda_ctdb.c index a686389..2beac8f 100644 --- a/ctdb/utils/pmda/pmda_ctdb.c +++ b/ctdb/utils/pmda/pmda_ctdb.c @@ -197,7 +197,7 @@ pmda_ctdb_daemon_connect(void) socket_name = getenv("CTDB_SOCKET"); if (socket_name == NULL) { - socket_name = CTDB_PATH; + socket_name = CTDB_SOCKET; } ret = ctdb_set_socketname(ctdb, socket_name); diff --git a/source3/lib/cluster_support.c b/source3/lib/cluster_support.c index e2aef7b..afe2260 100644 --- a/source3/lib/cluster_support.c +++ b/source3/lib/cluster_support.c @@ -62,8 +62,8 @@ const char *cluster_support_features(void) #ifdef HAVE_CTDB_PROTOCOL_H _LINE_DEF(HAVE_CTDB_PROTOCOL_H) #endif -#ifdef CTDB_PATH - _LINE_STR(CTDB_PATH) +#ifdef CTDB_SOCKET + _LINE_STR(CTDB_SOCKET) #endif #ifdef CTDB_VERSION _LINE_INT(CTDB_VERSION) diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index fe3e25a..5044ddf 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -201,7 +201,7 @@ const char *lp_ctdbd_socket(void) return ret; } - return CTDB_PATH; + return CTDB_SOCKET; } /* -- 2.1.1 From 3998adcd6a025c6ef35ac0fc06bb541ca694b15d Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Fri, 10 Oct 2014 14:25:34 +1100 Subject: [PATCH 28/34] build: Remove configure checks for ctdb headers Signed-off-by: Amitay Isaacs Reviewed-by: Michael Adam (cherry picked from commit e67c4b977a52d1744f4da8296bbcd7c213cbe92a) --- source3/lib/cluster_support.c | 18 +-------- source3/lib/ctdb_conn.c | 4 -- source3/torture/test_ctdbconn.c | 4 -- source3/wscript | 82 +---------------------------------------- 4 files changed, 2 insertions(+), 106 deletions(-) diff --git a/source3/lib/cluster_support.c b/source3/lib/cluster_support.c index afe2260..6a5f91d 100644 --- a/source3/lib/cluster_support.c +++ b/source3/lib/cluster_support.c @@ -20,18 +20,11 @@ #include #include "cluster_support.h" -#ifdef HAVE_CTDB_H +#ifdef CLUSTER_SUPPORT #include -#define CLUSTER_SUPPORT 1 -#endif - -#ifdef HAVE_CTDB_PROTOCOL_H #include -#else -#ifdef HAVE_CTDB_PRIVATE_H #include #endif -#endif bool cluster_support_available(void) { @@ -53,15 +46,6 @@ const char *cluster_support_features(void) #else " NONE\n" #endif -#ifdef HAVE_CTDB_H - _LINE_DEF(HAVE_CTDB_H) -#endif -#ifdef HAVE_CTDB_PRIVATE_H - _LINE_DEF(HAVE_CTDB_PRIVATE_H) -#endif -#ifdef HAVE_CTDB_PROTOCOL_H - _LINE_DEF(HAVE_CTDB_PROTOCOL_H) -#endif #ifdef CTDB_SOCKET _LINE_STR(CTDB_SOCKET) #endif diff --git a/source3/lib/ctdb_conn.c b/source3/lib/ctdb_conn.c index 0996511..1bba8e7 100644 --- a/source3/lib/ctdb_conn.c +++ b/source3/lib/ctdb_conn.c @@ -23,11 +23,7 @@ #include -#ifdef HAVE_CTDB_PROTOCOL_H #include -#else -#include -#endif #include "lib/async_req/async_sock.h" diff --git a/source3/torture/test_ctdbconn.c b/source3/torture/test_ctdbconn.c index ff45a02..1f80cff 100644 --- a/source3/torture/test_ctdbconn.c +++ b/source3/torture/test_ctdbconn.c @@ -25,11 +25,7 @@ #include "lib/util/tevent_unix.h" #include "tdb.h" -#ifdef HAVE_CTDB_PROTOCOL_H #include "ctdb_protocol.h" -#else -#include "ctdb_private.h" -#endif #include "messages.h" diff --git a/source3/wscript b/source3/wscript index 241f0fd..880ef23 100644 --- a/source3/wscript +++ b/source3/wscript @@ -1471,89 +1471,9 @@ main() { if not conf.env.USING_SYSTEM_TALLOC: includes = includes + ' ' + srcdir + '/lib/talloc' - ok = conf.CHECK_CODE(''' - #define NO_CONFIG_H - #include "replace.h" - #include "system/wait.h" - #include "system/network.h" - #define private #error __USED_RESERVED_WORD_private__ - #include - #include - #include - - int main(void) - { - return 0; - } - ''', - 'HAVE_CTDB_CHECK_CODE', - addmain=False, - includes=includes, - msg='Checking for header ctdb.h') - if ok: - CTDB_CFLAGS += ' -DHAVE_CTDB_H=1' - else: - have_cluster_support = False - ctdb_broken = "ctdb.h is required for cluster support" - - conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') - if have_cluster_support: - ok = conf.CHECK_CODE(''' - #define NO_CONFIG_H - #include "replace.h" - #include "system/wait.h" - #include "system/network.h" - #define private #error __USED_RESERVED_WORD_private__ - #include - #include - #include - #include - - int main(void) - { - return 0; - } - ''', - 'HAVE_CTDB_CHECK_CODE', - addmain=False, - includes=includes, - msg='Checking for header ctdb_private.h') - if ok: - CTDB_CFLAGS += ' -DHAVE_CTDB_PRIVATE_H=1' - else: - have_cluster_support = False - ctdb_broken = "ctdb_private.h is required for cluster support" - - conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') - if have_cluster_support: - ok = conf.CHECK_CODE(''' - #define NO_CONFIG_H - #include "replace.h" - #include "system/wait.h" - #include "system/network.h" - #define private #error __USED_RESERVED_WORD_private__ - #include - #include - #include - #include - - int main(void) - { - return 0; - } - ''', - 'HAVE_CTDB_CHECK_CODE', - addmain=False, - includes=includes, - msg='Checking for header ctdb_protocol.h') - if ok: - CTDB_CFLAGS += ' -DHAVE_CTDB_PROTOCOL_H=1' - - conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE') - conf.undefine('HAVE_CTDB_CHECK_CODE') if have_cluster_support: Logs.info("building with cluster support") - conf.env['CTDB_CFLAGS'] = CTDB_CFLAGS + conf.env['CTDB_CFLAGS'] = '-DCLUSTER_SUPPORT=1' conf.env['CTDB_INCLUDE'] = CTDB_INCLUDE else: if Options.options.with_cluster_support == False: -- 2.1.1 From 98c9de0a1f8fcc13b5cf75e107532e25a2faec64 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Fri, 10 Oct 2014 14:29:51 +1100 Subject: [PATCH 29/34] build: Simplify check for building with ctdb Signed-off-by: Amitay Isaacs Reviewed-by: Michael Adam (cherry picked from commit 69c0c43d55c93b82b2e398d5c61009fd347170bf) --- source3/wscript | 25 +++++-------------------- wscript | 3 +-- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/source3/wscript b/source3/wscript index 880ef23..2745d5d 100644 --- a/source3/wscript +++ b/source3/wscript @@ -1443,19 +1443,14 @@ main() { conf.DEFINE('WITH_QUOTAS', '1') # - # checking for clustering extensions (CTDB) + # checking for clustering (CTDB) # - if Options.options.with_cluster_support == False: + if not Options.options.with_cluster_support: # configure is called with --without-cluster-support, # so don't check for and build w/o ctdb support. - have_cluster_support = False - + Logs.info("building without cluster support (--without-cluster-support)") + conf.env.with_ctdb = False else: - - have_cluster_support = True - ctdb_broken = "" - CTDB_CFLAGS = "" - srcdir = os.path.realpath(conf.srcdir) if 'EXTRA_INCLUDES' in conf.env: includes = ' '.join(conf.env['EXTRA_INCLUDES']).replace('#', srcdir + '/') @@ -1471,20 +1466,10 @@ main() { if not conf.env.USING_SYSTEM_TALLOC: includes = includes + ' ' + srcdir + '/lib/talloc' - if have_cluster_support: Logs.info("building with cluster support") conf.env['CTDB_CFLAGS'] = '-DCLUSTER_SUPPORT=1' conf.env['CTDB_INCLUDE'] = CTDB_INCLUDE - else: - if Options.options.with_cluster_support == False: - Logs.info("building without cluster support (--without-cluster-support)") - elif Options.options.with_cluster_support == True: - Logs.error("Cluster support not available: " + ctdb_broken) - conf.fatal("Cluster support not found, but --with-cluster-support was specified") - else: - Logs.info("building without cluster support: " + ctdb_broken) - conf.env['CTDB_CFLAGS'] = '' - + conf.env.with_ctdb = True conf.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }', 'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR', diff --git a/wscript b/wscript index 7124e57..236603e 100644 --- a/wscript +++ b/wscript @@ -167,8 +167,7 @@ def configure(conf): conf.RECURSE('selftest') conf.RECURSE('source3') conf.RECURSE('lib/texpect') - if Options.options.with_cluster_support: - conf.env.with_ctdb = True + if conf.env.with_ctdb: conf.RECURSE('ctdb') conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS() -- 2.1.1 From 5ceecdc951afc3b225bd5e62074a01c66166dda0 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Tue, 21 Oct 2014 11:53:29 +1100 Subject: [PATCH 30/34] ctdb: Rename CTDB_VERSION to CTDB_PROTOCOL CTDB_VERSION really is the ctdb protocol version. Signed-off-by: Amitay Isaacs Reviewed-by: Michael Adam (cherry picked from commit a54db687acc14351613738d93a4e99ceaa2c6759) --- ctdb/client/ctdb_client.c | 4 ++-- ctdb/include/ctdb_protocol.h | 2 +- ctdb/server/ctdb_daemon.c | 6 +++--- ctdb/tcp/tcp_io.c | 2 +- ctdb/tools/ctdb.c | 4 ++-- source3/lib/cluster_support.c | 6 ++---- source3/lib/ctdb_conn.c | 4 ++-- source3/lib/ctdbd_conn.c | 12 ++++++------ 8 files changed, 19 insertions(+), 21 deletions(-) diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c index 424937a..07b17d0 100644 --- a/ctdb/client/ctdb_client.c +++ b/ctdb/client/ctdb_client.c @@ -54,7 +54,7 @@ struct ctdb_req_header *_ctdbd_allocate_pkt(struct ctdb_context *ctdb, hdr->length = length; hdr->operation = operation; hdr->ctdb_magic = CTDB_MAGIC; - hdr->ctdb_version = CTDB_VERSION; + hdr->ctdb_version = CTDB_PROTOCOL; hdr->srcnode = ctdb->pnn; if (ctdb->vnn_map) { hdr->generation = ctdb->vnn_map->generation; @@ -216,7 +216,7 @@ void ctdb_client_read_cb(uint8_t *data, size_t cnt, void *args) goto done; } - if (hdr->ctdb_version != CTDB_VERSION) { + if (hdr->ctdb_version != CTDB_PROTOCOL) { ctdb_set_error(ctdb, "Bad CTDB version 0x%x rejected in client\n", hdr->ctdb_version); goto done; } diff --git a/ctdb/include/ctdb_protocol.h b/ctdb/include/ctdb_protocol.h index 72161af..725e426 100644 --- a/ctdb/include/ctdb_protocol.h +++ b/ctdb/include/ctdb_protocol.h @@ -272,7 +272,7 @@ enum ctdb_operation { }; #define CTDB_MAGIC 0x43544442 /* CTDB */ -#define CTDB_VERSION 1 +#define CTDB_PROTOCOL 1 enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0, CTDB_CONTROL_STATISTICS = 1, diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c index 65b7109..b21e123 100644 --- a/ctdb/server/ctdb_daemon.c +++ b/ctdb/server/ctdb_daemon.c @@ -814,7 +814,7 @@ static void daemon_incoming_packet(void *p, struct ctdb_req_header *hdr) goto done; } - if (hdr->ctdb_version != CTDB_VERSION) { + if (hdr->ctdb_version != CTDB_PROTOCOL) { ctdb_set_error(client->ctdb, "Bad CTDB version 0x%x rejected in daemon\n", hdr->ctdb_version); goto done; } @@ -876,7 +876,7 @@ static void ctdb_daemon_read_cb(uint8_t *data, size_t cnt, void *args) return; } - if (hdr->ctdb_version != CTDB_VERSION) { + if (hdr->ctdb_version != CTDB_PROTOCOL) { ctdb_set_error(client->ctdb, "Bad CTDB version 0x%x rejected in daemon\n", hdr->ctdb_version); return; } @@ -1360,7 +1360,7 @@ struct ctdb_req_header *_ctdb_transport_allocate(struct ctdb_context *ctdb, hdr->length = length; hdr->operation = operation; hdr->ctdb_magic = CTDB_MAGIC; - hdr->ctdb_version = CTDB_VERSION; + hdr->ctdb_version = CTDB_PROTOCOL; hdr->generation = ctdb->vnn_map->generation; hdr->srcnode = ctdb->pnn; diff --git a/ctdb/tcp/tcp_io.c b/ctdb/tcp/tcp_io.c index 5111195..a951320 100644 --- a/ctdb/tcp/tcp_io.c +++ b/ctdb/tcp/tcp_io.c @@ -63,7 +63,7 @@ void ctdb_tcp_read_cb(uint8_t *data, size_t cnt, void *args) goto failed; } - if (hdr->ctdb_version != CTDB_VERSION) { + if (hdr->ctdb_version != CTDB_PROTOCOL) { DEBUG(DEBUG_ALERT, (__location__ " Bad CTDB version 0x%x rejected\n", hdr->ctdb_version)); goto failed; diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index 71dfc28..1ba2be1 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -484,7 +484,7 @@ static void show_statistics(struct ctdb_statistics *s, int show_header) printf("max_childwrite_latency:"); printf("\n"); } - printf("%d:", CTDB_VERSION); + printf("%d:", CTDB_PROTOCOL); printf("%d:", (int)s->statistics_current_time.tv_sec); printf("%d:", (int)s->statistics_start_time.tv_sec); for (i=0;ichildwrite_latency.max); printf("\n"); } else { - printf("CTDB version %u\n", CTDB_VERSION); + printf("CTDB version %u\n", CTDB_PROTOCOL); printf("Current time of statistics : %s", ctime(&s->statistics_current_time.tv_sec)); printf("Statistics collected since : (%03d %02d:%02d:%02d) %s", days, hours, minutes, seconds, ctime(&s->statistics_start_time.tv_sec)); diff --git a/source3/lib/cluster_support.c b/source3/lib/cluster_support.c index 6a5f91d..b8925aa 100644 --- a/source3/lib/cluster_support.c +++ b/source3/lib/cluster_support.c @@ -21,9 +21,7 @@ #include "cluster_support.h" #ifdef CLUSTER_SUPPORT -#include #include -#include #endif bool cluster_support_available(void) @@ -49,8 +47,8 @@ const char *cluster_support_features(void) #ifdef CTDB_SOCKET _LINE_STR(CTDB_SOCKET) #endif -#ifdef CTDB_VERSION - _LINE_INT(CTDB_VERSION) +#ifdef CTDB_PROTOCOL + _LINE_INT(CTDB_PROTOCOL) #endif ""; diff --git a/source3/lib/ctdb_conn.c b/source3/lib/ctdb_conn.c index 1bba8e7..c705c21 100644 --- a/source3/lib/ctdb_conn.c +++ b/source3/lib/ctdb_conn.c @@ -179,7 +179,7 @@ struct tevent_req *ctdb_conn_control_send(TALLOC_CTX *mem_ctx, hdr = &state->req.hdr; hdr->length = offsetof(struct ctdb_req_control, data) + datalen; hdr->ctdb_magic = CTDB_MAGIC; - hdr->ctdb_version = CTDB_VERSION; + hdr->ctdb_version = CTDB_PROTOCOL; hdr->operation = CTDB_REQ_CONTROL; hdr->reqid = 1; /* FIXME */ hdr->destnode = vnn; @@ -306,7 +306,7 @@ struct tevent_req *ctdb_conn_msg_write_send(TALLOC_CTX *mem_ctx, h->length = offsetof(struct ctdb_req_message, data) + msg_len; h->ctdb_magic = CTDB_MAGIC; - h->ctdb_version = CTDB_VERSION; + h->ctdb_version = CTDB_PROTOCOL; h->generation = 1; h->operation = CTDB_REQ_MESSAGE; h->destnode = vnn; diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index 5044ddf..a26f410 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -767,7 +767,7 @@ NTSTATUS ctdbd_messaging_send_blob(struct ctdbd_connection *conn, r.hdr.length = offsetof(struct ctdb_req_message, data) + buflen; r.hdr.ctdb_magic = CTDB_MAGIC; - r.hdr.ctdb_version = CTDB_VERSION; + r.hdr.ctdb_version = CTDB_PROTOCOL; r.hdr.generation = 1; r.hdr.operation = CTDB_REQ_MESSAGE; r.hdr.destnode = dst_vnn; @@ -826,7 +826,7 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn, ZERO_STRUCT(req); req.hdr.length = offsetof(struct ctdb_req_control, data) + data.dsize; req.hdr.ctdb_magic = CTDB_MAGIC; - req.hdr.ctdb_version = CTDB_VERSION; + req.hdr.ctdb_version = CTDB_PROTOCOL; req.hdr.operation = CTDB_REQ_CONTROL; req.hdr.reqid = ctdbd_next_reqid(conn); req.hdr.destnode = vnn; @@ -947,7 +947,7 @@ bool ctdb_processes_exist(struct ctdbd_connection *conn, req.hdr.length = offsetof(struct ctdb_req_control, data); req.hdr.length += sizeof(pid); req.hdr.ctdb_magic = CTDB_MAGIC; - req.hdr.ctdb_version = CTDB_VERSION; + req.hdr.ctdb_version = CTDB_PROTOCOL; req.hdr.operation = CTDB_REQ_CONTROL; req.hdr.reqid = reqids[i]; req.hdr.destnode = pids[i].vnn; @@ -1143,7 +1143,7 @@ bool ctdb_serverids_exist(struct ctdbd_connection *conn, req.hdr.length = offsetof(struct ctdb_req_control, data); req.hdr.ctdb_magic = CTDB_MAGIC; - req.hdr.ctdb_version = CTDB_VERSION; + req.hdr.ctdb_version = CTDB_PROTOCOL; req.hdr.operation = CTDB_REQ_CONTROL; req.hdr.reqid = vnn->reqid; req.hdr.destnode = vnn->vnn; @@ -1354,7 +1354,7 @@ NTSTATUS ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id, req.hdr.length = offsetof(struct ctdb_req_call, data) + key.dsize; req.hdr.ctdb_magic = CTDB_MAGIC; - req.hdr.ctdb_version = CTDB_VERSION; + req.hdr.ctdb_version = CTDB_PROTOCOL; req.hdr.operation = CTDB_REQ_CALL; req.hdr.reqid = ctdbd_next_reqid(conn); req.flags = CTDB_IMMEDIATE_MIGRATION; @@ -1419,7 +1419,7 @@ NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id, req.hdr.length = offsetof(struct ctdb_req_call, data) + key.dsize; req.hdr.ctdb_magic = CTDB_MAGIC; - req.hdr.ctdb_version = CTDB_VERSION; + req.hdr.ctdb_version = CTDB_PROTOCOL; req.hdr.operation = CTDB_REQ_CALL; req.hdr.reqid = ctdbd_next_reqid(conn); req.flags = flags; -- 2.1.1 From 84aa2811f6cd58b5100b15bab9eb766a88376bbb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 24 Oct 2014 17:42:51 +0200 Subject: [PATCH 31/34] autobuild: adapt samba-ctdb target does not need a separate ctdb build any more Signed-off-by: Michael Adam Reviewed-by: Amitay Isaacs (cherry picked from commit eeebbe73125967943d95b6e03cbf695d3d219bc0) --- script/autobuild.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/script/autobuild.py b/script/autobuild.py index c5d3cad..d62538e 100755 --- a/script/autobuild.py +++ b/script/autobuild.py @@ -58,14 +58,9 @@ tasks = { ("tdb-make", "cd lib/tdb && make", "text/plain"), ("tdb-install", "cd lib/tdb && make install", "text/plain"), - # build and install ctdb: - ("ctdb-configure", "cd ./ctdb && PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig:${PKG_CONFIG_PATH} ./configure ${PREFIX} --bundled-libraries=!tdb", "text/plain"), - ("ctdb-make", "cd ./ctdb && make all", "text/plain"), - ("ctdb-install", "cd ./ctdb && make install", "text/plain"), - ("ctdb-header-ls", "ls ${PREFIX_DIR}/include/ctdb.h", "text/plain"), # build samba with cluster support against this ctdb: - ("samba-configure", "PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig:${PKG_CONFIG_PATH} ./configure.developer ${PREFIX} --with-selftest-prefix=./bin/ab --with-cluster-support --with-ctdb-dir=${PREFIX_DIR} --bundled-libraries=!tdb", "text/plain"), + ("samba-configure", "PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig:${PKG_CONFIG_PATH} ./configure.developer ${PREFIX} --with-selftest-prefix=./bin/ab --with-cluster-support --bundled-libraries=!tdb", "text/plain"), ("samba-make", "make", "text/plain"), ("samba-check", "./bin/smbd -b | grep CLUSTER_SUPPORT", "text/plain"), ("samba-install", "make install", "text/plain"), -- 2.1.1 From 1ab5188020193ee423b7be0473e453e0bbf0efa7 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 24 Oct 2014 17:53:08 +0200 Subject: [PATCH 32/34] build: further simplify --with-cluster-support case in configure includes were only built for the ctdb checks and they are now gone because we are building against included ctdb. Signed-off-by: Michael Adam Reviewed-by: Amitay Isaacs (cherry picked from commit bf98630f0a44597e61cdfc735ab73d862643007b) --- source3/wscript | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/source3/wscript b/source3/wscript index 2745d5d..a89957ec 100644 --- a/source3/wscript +++ b/source3/wscript @@ -1451,24 +1451,9 @@ main() { Logs.info("building without cluster support (--without-cluster-support)") conf.env.with_ctdb = False else: - srcdir = os.path.realpath(conf.srcdir) - if 'EXTRA_INCLUDES' in conf.env: - includes = ' '.join(conf.env['EXTRA_INCLUDES']).replace('#', srcdir + '/') - else: - includes = '' - - CTDB_INCLUDE = conf.srcdir + '/ctdb/include' - includes = includes + ' ' + CTDB_INCLUDE - - if not conf.env.USING_SYSTEM_TDB: - includes = includes + ' ' + srcdir + '/lib/tdb/include' - - if not conf.env.USING_SYSTEM_TALLOC: - includes = includes + ' ' + srcdir + '/lib/talloc' - Logs.info("building with cluster support") conf.env['CTDB_CFLAGS'] = '-DCLUSTER_SUPPORT=1' - conf.env['CTDB_INCLUDE'] = CTDB_INCLUDE + conf.env['CTDB_INCLUDE'] = conf.srcdir + '/ctdb/include' conf.env.with_ctdb = True conf.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }', -- 2.1.1 From 4a7033d8d30846da5f7631171ea14f5891644359 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 24 Oct 2014 17:55:17 +0200 Subject: [PATCH 33/34] build: adapt comments for the clustering choice Signed-off-by: Michael Adam Reviewed-by: Amitay Isaacs (cherry picked from commit a72ca5a200c6321f3e3a42761dc3d661dacd5021) --- source3/wscript | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source3/wscript b/source3/wscript index a89957ec..9778d4e 100644 --- a/source3/wscript +++ b/source3/wscript @@ -1443,11 +1443,9 @@ main() { conf.DEFINE('WITH_QUOTAS', '1') # - # checking for clustering (CTDB) + # cluster support (CTDB) # if not Options.options.with_cluster_support: - # configure is called with --without-cluster-support, - # so don't check for and build w/o ctdb support. Logs.info("building without cluster support (--without-cluster-support)") conf.env.with_ctdb = False else: -- 2.1.1 From 616a37905f0eb20c6b139241a7295a7424fd7914 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 25 Oct 2014 18:01:30 +0200 Subject: [PATCH 34/34] autobuild: check whether ctdbd has been installed in the samba-ctdb target An intermediate test until we have full runtime-tests. Signed-off-by: Michael Adam Reviewed-by: Amitay Isaacs Autobuild-User(master): Amitay Isaacs Autobuild-Date(master): Tue Oct 28 08:05:40 CET 2014 on sn-devel-104 (cherry picked from commit bf07a6b79e525a2aba71e07c4e13f2b2cb06b12f) --- script/autobuild.py | 1 + 1 file changed, 1 insertion(+) diff --git a/script/autobuild.py b/script/autobuild.py index d62538e..2b25a10 100755 --- a/script/autobuild.py +++ b/script/autobuild.py @@ -64,6 +64,7 @@ tasks = { ("samba-make", "make", "text/plain"), ("samba-check", "./bin/smbd -b | grep CLUSTER_SUPPORT", "text/plain"), ("samba-install", "make install", "text/plain"), + ("ctdb-check", "test -e ${PREFIX_DIR}/sbin/ctdbd", "text/plain"), # clean up: ("check-clean-tree", "script/clean-source-tree.sh", "text/plain"), -- 2.1.1