[SCM] Samba Shared Repository - branch v4-2-test updated
Stefan Metzmacher
metze at samba.org
Tue Aug 18 13:56:06 UTC 2015
The branch, v4-2-test has been updated
via 75e2768 ctdb-daemon: Correctly process the exit code from failed eventscripts
via bbaef4d ctdb-daemon: Improve error handling for running event scripts
via 0d36fba ctdb-tool: Correctly print timed out event scripts output
via 1f7e86d s3:lib: fix some corner cases of open_socket_out_cleanup()
via 7ad714e lib: Fix rundown of open_socket_out()
from e9d22f1 s4:torture:vfs_fruit: add a test for stream names
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-2-test
- Log -----------------------------------------------------------------
commit 75e2768a08f4d53644d1f1f6a1a348f811440358
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Jul 21 16:37:04 2015 +1000
ctdb-daemon: Correctly process the exit code from failed eventscripts
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11431
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
Autobuild-User(master): Martin Schwenke <martins at samba.org>
Autobuild-Date(master): Wed Jul 22 15:03:53 CEST 2015 on sn-devel-104
(cherry picked from commit 00ec3c477eba50206801b451ae4eb64c12aba5db)
Autobuild-User(v4-2-test): Stefan Metzmacher <metze at samba.org>
Autobuild-Date(v4-2-test): Tue Aug 18 15:55:44 CEST 2015 on sn-devel-104
commit bbaef4d48ed9f835a00cdff57b5282835af45f3d
Author: Amitay Isaacs <amitay at gmail.com>
Date: Thu Nov 13 11:02:26 2014 +1100
ctdb-daemon: Improve error handling for running event scripts
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11431
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
Autobuild-User(master): Martin Schwenke <martins at samba.org>
Autobuild-Date(master): Fri Nov 14 03:06:12 CET 2014 on sn-devel-104
(cherry picked from commit d04bfc6ec6ad7a4749ebfee2284253c4a91a81aa)
commit 0d36fbabdc2457cdea80e18ca224232317142b06
Author: Amitay Isaacs <amitay at gmail.com>
Date: Mon Jul 20 16:37:58 2015 +1000
ctdb-tool: Correctly print timed out event scripts output
The timed out error is ignored for certain events (start_recovery,
recoverd, takeip, releaseip). If these events time out, then the debug
hung script outputs the following:
3 scripts were executed last releaseip cycle
00.ctdb Status:OK Duration:4.381 Thu Jul 16 23:45:24 2015
01.reclock Status:OK Duration:13.422 Thu Jul 16 23:45:28 2015
10.external Status:DISABLED
10.interface Status:OK Duration:-1437083142.208 Thu Jul 16 23:45:42 2015
The endtime for timed out scripts is not set. Since the status is not
returned as -ETIME for some events, ctdb scriptstatus prints -ve duration.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11431
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
(cherry picked from commit 71b89b2b7a9768de437347e6678370b2682da892)
commit 1f7e86d813293a36e1f84bc4983c8cbb528cfc71
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Aug 14 12:54:00 2015 +0200
s3:lib: fix some corner cases of open_socket_out_cleanup()
In case of timeouts we retry the async_connect_send() and forgot
to remember it, this results in an abort() in async_connect_cleanup()
as the fd is already closed when calling fcntl(F_SETFL).
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Volker Lendecke <vl at samba.org>
(cherry picked from commit ce3c77fb45ccf4d45a0fa655325e30e748d89245)
commit 7ad714e2eb4758edbbdd774db2af3287c41c6eba
Author: Volker Lendecke <vl at samba.org>
Date: Mon Jun 29 19:00:55 2015 +0200
lib: Fix rundown of open_socket_out()
Under valgrind I've seen the abort in async_connect_cleanup kick in. Yes, it's
good that we check these return codes!
Bug: https://bugzilla.samba.org/show_bug.cgi?id=11316
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 Jun 30 20:24:37 CEST 2015 on sn-devel-104
(cherry picked from commit 6fc65aaf956f35e2068e2a6f8521af2f2351d31e)
-----------------------------------------------------------------------
Summary of changes:
ctdb/server/ctdb_event_helper.c | 44 ++++++++++++++++++++++++++-----------
ctdb/server/eventscript.c | 10 +++++++--
ctdb/tools/ctdb.c | 8 +++++++
source3/lib/util_sock.c | 48 ++++++++++++++++++++++++++++++-----------
4 files changed, 83 insertions(+), 27 deletions(-)
Changeset truncated at 500 lines:
diff --git a/ctdb/server/ctdb_event_helper.c b/ctdb/server/ctdb_event_helper.c
index 9ff763c..a1b5318 100644
--- a/ctdb/server/ctdb_event_helper.c
+++ b/ctdb/server/ctdb_event_helper.c
@@ -67,7 +67,7 @@ int main(int argc, char *argv[])
{
int log_fd, write_fd;
pid_t pid;
- int status, output;
+ int status, output, ret;
progname = argv[0];
@@ -99,33 +99,51 @@ int main(int argc, char *argv[])
pid = fork();
if (pid < 0) {
+ int save_errno = errno;
fprintf(stderr, "Failed to fork - %s\n", strerror(errno));
- exit(errno);
+ sys_write(write_fd, &save_errno, sizeof(save_errno));
+ exit(1);
}
if (pid == 0) {
- int save_errno;
-
- execv(argv[3], &argv[3]);
- if (errno == EACCES) {
- save_errno = check_executable(argv[3]);
- } else {
- save_errno = errno;
+ ret = check_executable(argv[3]);
+ if (ret != 0) {
+ _exit(ret);
+ }
+ ret = execv(argv[3], &argv[3]);
+ if (ret != 0) {
+ int save_errno = errno;
fprintf(stderr, "Error executing '%s' - %s\n",
- argv[3], strerror(errno));
+ argv[3], strerror(save_errno));
}
- _exit(save_errno);
+ /* This should never happen */
+ _exit(ENOEXEC);
}
- waitpid(pid, &status, 0);
+ ret = waitpid(pid, &status, 0);
+ if (ret == -1) {
+ output = -errno;
+ fprintf(stderr, "waitpid() failed - %s\n", strerror(errno));
+ sys_write(write_fd, &output, sizeof(output));
+ exit(1);
+ }
if (WIFEXITED(status)) {
output = WEXITSTATUS(status);
+ /* Only errors should be returned as -ve values */
if (output == ENOENT || output == ENOEXEC) {
output = -output;
}
sys_write(write_fd, &output, sizeof(output));
- exit(output);
+ exit(0);
+ }
+ if (WIFSIGNALED(status)) {
+ output = -EINTR;
+ fprintf(stderr, "Process terminated with signal - %d\n",
+ WTERMSIG(status));
+ sys_write(write_fd, &output, sizeof(output));
+ exit(0);
}
+ fprintf(stderr, "waitpid() status=%d\n", status);
exit(1);
}
diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c
index e3131b3..1f16580 100644
--- a/ctdb/server/eventscript.c
+++ b/ctdb/server/eventscript.c
@@ -379,6 +379,8 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
r = sys_read(state->fd[0], ¤t->status, sizeof(current->status));
if (r < 0) {
current->status = -errno;
+ } else if (r == 0) {
+ current->status = -EINTR;
} else if (r != sizeof(current->status)) {
current->status = -EIO;
}
@@ -396,8 +398,12 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
/* Aborted or finished all scripts? We're done. */
if (status != 0 || state->current+1 == state->scripts->num_scripts) {
- DEBUG(DEBUG_INFO,(__location__ " Eventscript %s %s finished with state %d\n",
- ctdb_eventscript_call_names[state->call], state->options, status));
+ if (status != 0) {
+ DEBUG(DEBUG_INFO,
+ ("Eventscript %s %s finished with state %d\n",
+ ctdb_eventscript_call_names[state->call],
+ state->options, status));
+ }
ctdb->event_script_timeouts = 0;
talloc_free(state);
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index c386d35..6911dff 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -1453,6 +1453,14 @@ static int control_one_scriptstatus(struct ctdb_context *ctdb,
for (i=0; i<script_status->num_scripts; i++) {
const char *status = NULL;
+ /* The ETIME status is ignored for certain events.
+ * In that case the status is 0, but endtime is not set.
+ */
+ if (script_status->scripts[i].status == 0 &&
+ timeval_is_zero(&script_status->scripts[i].finished)) {
+ script_status->scripts[i].status = -ETIME;
+ }
+
switch (script_status->scripts[i].status) {
case -ETIME:
status = "TIMEDOUT";
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index d865ffb..6cef378 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -539,16 +539,34 @@ struct open_socket_out_state {
socklen_t salen;
uint16_t port;
int wait_usec;
+ struct tevent_req *connect_subreq;
};
static void open_socket_out_connected(struct tevent_req *subreq);
-static int open_socket_out_state_destructor(struct open_socket_out_state *s)
+static void open_socket_out_cleanup(struct tevent_req *req,
+ enum tevent_req_state req_state)
{
- if (s->fd != -1) {
- close(s->fd);
+ struct open_socket_out_state *state =
+ tevent_req_data(req, struct open_socket_out_state);
+
+ /*
+ * Make sure that the async_connect_send subreq has a chance to reset
+ * fcntl before the socket goes away.
+ */
+ TALLOC_FREE(state->connect_subreq);
+
+ if (req_state == TEVENT_REQ_DONE) {
+ /*
+ * we keep the socket open for the caller to use
+ */
+ return;
+ }
+
+ if (state->fd != -1) {
+ close(state->fd);
+ state->fd = -1;
}
- return 0;
}
/****************************************************************************
@@ -562,7 +580,7 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
int timeout)
{
char addr[INET6_ADDRSTRLEN];
- struct tevent_req *result, *subreq;
+ struct tevent_req *result;
struct open_socket_out_state *state;
NTSTATUS status;
@@ -582,7 +600,8 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
status = map_nt_error_from_unix(errno);
goto post_status;
}
- talloc_set_destructor(state, open_socket_out_state_destructor);
+
+ tevent_req_set_cleanup_fn(result, open_socket_out_cleanup);
if (!tevent_req_set_endtime(
result, ev, timeval_current_ofs_msec(timeout))) {
@@ -616,16 +635,17 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
print_sockaddr(addr, sizeof(addr), &state->ss);
DEBUG(3,("Connecting to %s at port %u\n", addr, (unsigned int)port));
- subreq = async_connect_send(state, state->ev, state->fd,
- (struct sockaddr *)&state->ss,
- state->salen, NULL, NULL, NULL);
- if ((subreq == NULL)
+ state->connect_subreq = async_connect_send(
+ state, state->ev, state->fd, (struct sockaddr *)&state->ss,
+ state->salen, NULL, NULL, NULL);
+ if ((state->connect_subreq == NULL)
|| !tevent_req_set_endtime(
- subreq, state->ev,
+ state->connect_subreq, state->ev,
timeval_current_ofs(0, state->wait_usec))) {
goto fail;
}
- tevent_req_set_callback(subreq, open_socket_out_connected, result);
+ tevent_req_set_callback(state->connect_subreq,
+ open_socket_out_connected, result);
return result;
post_status:
@@ -647,6 +667,7 @@ static void open_socket_out_connected(struct tevent_req *subreq)
ret = async_connect_recv(subreq, &sys_errno);
TALLOC_FREE(subreq);
+ state->connect_subreq = NULL;
if (ret == 0) {
tevent_req_done(req);
return;
@@ -680,6 +701,7 @@ static void open_socket_out_connected(struct tevent_req *subreq)
tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
return;
}
+ state->connect_subreq = subreq;
tevent_req_set_callback(subreq, open_socket_out_connected, req);
return;
}
@@ -702,10 +724,12 @@ NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd)
NTSTATUS status;
if (tevent_req_is_nterror(req, &status)) {
+ tevent_req_received(req);
return status;
}
*pfd = state->fd;
state->fd = -1;
+ tevent_req_received(req);
return NT_STATUS_OK;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list