[SCM] Samba Shared Repository - branch master updated
Volker Lendecke
vlendec at samba.org
Tue Mar 10 11:06:03 MDT 2015
The branch, master has been updated
via ee087f8 torture4: Fix systems with a 32-bit "long"
via b7b508c ctdb-daemon: Use statically allocated arrays for helper paths
via 89b08c0 ctdb-common: New function ctdb_set_helper()
from c6cb2d6 Update libwbclient version to 0.12
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit ee087f8d6d98e033e5d1f86096a11cd46a5d543e
Author: Volker Lendecke <vl at samba.org>
Date: Tue Mar 10 11:52:36 2015 +0100
torture4: Fix systems with a 32-bit "long"
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan (metze) Metzmacher <metze at samba.org>
Autobuild-User(master): Volker Lendecke <vl at samba.org>
Autobuild-Date(master): Tue Mar 10 18:05:13 CET 2015 on sn-devel-104
commit b7b508c76553448dcbf33d8779f4285d8948df64
Author: Martin Schwenke <martin at meltin.net>
Date: Fri Mar 6 14:05:23 2015 +1100
ctdb-daemon: Use statically allocated arrays for helper paths
The use of talloc with a static variable is somewhat confusing.
Statically allocate an array and use ctdb_set_helper() instead.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit 89b08c0f0ba951ed385ffb6190a98465717f8b25
Author: Martin Schwenke <martin at meltin.net>
Date: Sat Mar 7 07:22:32 2015 +1100
ctdb-common: New function ctdb_set_helper()
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Volker Lendecke <vl at samba.org>
-----------------------------------------------------------------------
Summary of changes:
ctdb/common/ctdb_util.c | 60 ++++++++++++++++++++++++++++++++++++++++++++
ctdb/include/ctdb_private.h | 2 ++
ctdb/server/ctdb_lock.c | 37 ++++++++++-----------------
ctdb/server/eventscript.c | 15 +++++------
source4/torture/smb2/ioctl.c | 11 ++++----
5 files changed, 87 insertions(+), 38 deletions(-)
Changeset truncated at 500 lines:
diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c
index 137e0a8..bd68c55 100644
--- a/ctdb/common/ctdb_util.c
+++ b/ctdb/common/ctdb_util.c
@@ -64,6 +64,66 @@ void ctdb_die(struct ctdb_context *ctdb, const char *msg)
exit(1);
}
+/* Set the path of a helper program from envvar, falling back to
+ * dir/file if envvar unset. type is a string to print in log
+ * messages. helper is assumed to point to a statically allocated
+ * array of size bytes, initialised to "". If file is NULL don't fall
+ * back if envvar is unset. If dir is NULL and envvar is unset (but
+ * file is not NULL) then this is an error. Returns true if helper is
+ * set, either previously or this time. */
+bool ctdb_set_helper(const char *type, char *helper, size_t size,
+ const char *envvar,
+ const char *dir, const char *file)
+{
+ const char *t;
+ struct stat st;
+
+ if (helper[0] != '\0') {
+ /* Already set */
+ return true;
+ }
+
+ t = getenv(envvar);
+ if (t != NULL) {
+ if (strlen(t) >= size) {
+ DEBUG(DEBUG_ERR,
+ ("Unable to set %s - path too long\n", type));
+ return false;
+ }
+
+ strncpy(helper, t, size);
+ } else if (file == NULL) {
+ return false;
+ } else if (dir == NULL) {
+ DEBUG(DEBUG_ERR,
+ ("Unable to set %s - dir is NULL\n", type));
+ return false;
+ } else {
+ if (snprintf(helper, size, "%s/%s", dir, file) >= size) {
+ DEBUG(DEBUG_ERR,
+ ("Unable to set %s - path too long\n", type));
+ return false;
+ }
+ }
+
+ if (stat(helper, &st) != 0) {
+ DEBUG(DEBUG_ERR,
+ ("Unable to set %s \"%s\" - %s\n",
+ type, helper, strerror(errno)));
+ return false;
+ }
+ if (!(st.st_mode & S_IXUSR)) {
+ DEBUG(DEBUG_ERR,
+ ("Unable to set %s \"%s\" - not executable\n",
+ type, helper));
+ return false;
+ }
+
+ DEBUG(DEBUG_NOTICE,
+ ("Set %s to \"%s\"\n", type, helper));
+ return true;
+}
+
/* Invoke an external program to do some sort of tracing on the CTDB
* process. This might block for a little while. The external
* program is specified by the environment variable
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 7005fd8..ed4d612 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -722,6 +722,8 @@ struct ctdb_fetch_handle {
void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);
void ctdb_die(struct ctdb_context *ctdb, const char *msg);
+bool ctdb_set_helper(const char *type, char *helper, size_t size,
+ const char *envvar, const char *dir, const char *file);
void ctdb_external_trace(void);
bool ctdb_same_address(struct ctdb_address *a1, struct ctdb_address *a2);
int ctdb_parse_address(struct ctdb_context *ctdb,
diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c
index c5a2b98..f592834 100644
--- a/ctdb/server/ctdb_lock.c
+++ b/ctdb/server/ctdb_lock.c
@@ -482,7 +482,7 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
struct timeval current_time,
void *private_data)
{
- static const char * debug_locks = NULL;
+ static char debug_locks[PATH_MAX+1] = "";
struct lock_context *lock_ctx;
struct ctdb_context *ctdb;
pid_t pid;
@@ -510,16 +510,10 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
elapsed_time));
}
- /* Fire a child process to find the blocking process. */
- if (debug_locks == NULL) {
- debug_locks = getenv("CTDB_DEBUG_LOCKS");
- if (debug_locks == NULL) {
- debug_locks = talloc_asprintf(ctdb,
- "%s/debug_locks.sh",
- getenv("CTDB_BASE"));
- }
- }
- if (debug_locks != NULL) {
+ if (ctdb_set_helper("lock debugging helper",
+ debug_locks, sizeof(debug_locks),
+ "CTDB_DEBUG_LOCKS",
+ getenv("CTDB_BASE"), "debug_locks.sh")) {
pid = vfork();
if (pid == 0) {
execl(debug_locks, debug_locks, NULL);
@@ -529,7 +523,7 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
} else {
DEBUG(DEBUG_WARNING,
(__location__
- " Unable to setup lock debugging - no memory?\n"));
+ " Unable to setup lock debugging\n"));
}
/* Back-off logging if lock is not obtained for a long time */
@@ -754,20 +748,15 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb)
struct lock_context *lock_ctx;
int ret, argc;
TALLOC_CTX *tmp_ctx;
- const char *helper = CTDB_HELPER_BINDIR "/ctdb_lock_helper";
- static const char *prog = NULL;
+ static char prog[PATH_MAX+1] = "";
const char **args;
- if (prog == NULL) {
- const char *t;
-
- t = getenv("CTDB_LOCK_HELPER");
- if (t != NULL) {
- prog = talloc_strdup(ctdb, t);
- } else {
- prog = talloc_strdup(ctdb, helper);
- }
- CTDB_NO_MEMORY_VOID(ctdb, prog);
+ if (!ctdb_set_helper("lock helper",
+ prog, sizeof(prog),
+ "CTDB_LOCK_HELPER",
+ CTDB_HELPER_BINDIR, "ctdb_lock_helper")) {
+ ctdb_die(ctdb, __location__
+ " Unable to set lock helper\n");
}
/* Find a lock context with requests */
diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c
index eaa6a20..d776121 100644
--- a/ctdb/server/eventscript.c
+++ b/ctdb/server/eventscript.c
@@ -261,7 +261,7 @@ failed:
static void ctdb_event_script_handler(struct event_context *ev, struct fd_event *fde,
uint16_t flags, void *p);
-static const char *helper_prog = NULL;
+static char helper_prog[PATH_MAX+1] = "";
static int fork_child_for_script(struct ctdb_context *ctdb,
struct ctdb_event_script_state *state)
@@ -271,15 +271,12 @@ 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 = CTDB_HELPER_BINDIR "/ctdb_event_helper";
- if (helper_prog == NULL) {
- const char *t = getenv("CTDB_EVENT_HELPER");
- if (t != NULL) {
- helper_prog = t;
- } else {
- helper_prog = helper;
- }
+ if (!ctdb_set_helper("event helper", helper_prog, sizeof(helper_prog),
+ "CTDB_EVENT_HELPER",
+ CTDB_HELPER_BINDIR, "ctdb_event_helper")) {
+ ctdb_die(ctdb, __location__
+ " Unable to set event helper\n");
}
current->start = timeval_current();
diff --git a/source4/torture/smb2/ioctl.c b/source4/torture/smb2/ioctl.c
index 43f98be..78bbdd9 100644
--- a/source4/torture/smb2/ioctl.c
+++ b/source4/torture/smb2/ioctl.c
@@ -3435,9 +3435,10 @@ static bool test_ioctl_sparse_hole_dealloc(struct torture_context *torture,
* deallocation on this FS...
*/
dealloc_chunk_len = hlen;
- torture_comment(torture, "hole punch %lu at 0 resulted in "
- "deallocation of %lu at 0\n", hlen,
- far_rsp[0].file_off);
+ torture_comment(torture, "hole punch %ju at 0 resulted in "
+ "deallocation of %ju at 0\n",
+ (uintmax_t)hlen,
+ (uintmax_t)far_rsp[0].file_off);
torture_assert_u64_equal(torture,
file_size - far_rsp[0].len,
far_rsp[0].file_off,
@@ -3509,7 +3510,7 @@ static bool test_ioctl_sparse_hole_dealloc(struct torture_context *torture,
"unexpected response len");
if (far_rsp[0].file_off == dealloc_chunk_len) {
torture_comment(torture, "holes merged for deallocation of "
- "%lu chunk\n", dealloc_chunk_len);
+ "%ju chunk\n", (uintmax_t)dealloc_chunk_len);
torture_assert_u64_equal(torture,
file_size - far_rsp[0].len,
far_rsp[0].file_off,
@@ -4630,7 +4631,7 @@ static bool test_ioctl_sparse_qar_overflow(struct torture_context *torture,
/* off + length wraps around to 511 */
far_buf.file_off = 512;
- far_buf.len = (uint64_t)0xffffffffffffffff;
+ far_buf.len = 0xffffffffffffffffLL;
ndr_ret = ndr_push_struct_blob(&ioctl.smb2.in.out, tmp_ctx,
&far_buf,
(ndr_push_flags_fn_t)ndr_push_file_alloced_range_buf);
--
Samba Shared Repository
More information about the samba-cvs
mailing list