[SCM] Samba Shared Repository - branch master updated
Ralph Böhme
slow at samba.org
Mon Jul 11 21:46:02 UTC 2016
The branch, master has been updated
via a391e92 s3-messaging: use messaging_ctdbd_reinit() in messaging_reinit()
via f9913813 s3-messaging/ctdb: add messaging_ctdbd_reinit()
via c6373ab s3-messaging/ctdb: split messaging_ctdbd_init()
via 84da49f ctdbd_conn: add ctdbd_reinit_connection()
via 1184931 ctdbd_conn: split ctdbd_init_connection()
from 2f95ada ctdb: fix autotest with socket-wrapper installed in the system
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit a391e9202db6a8f64f2fe12d0ab5752f6e684f84
Author: Ralph Boehme <slow at samba.org>
Date: Sat Jul 9 14:33:52 2016 +0200
s3-messaging: use messaging_ctdbd_reinit() in messaging_reinit()
This is the last step to fix a regression introduced by
3fe3226daa8488e0fa787c40359c3401b6f05fc0 and
3fe3226daa8488e0fa787c40359c3401b6f05fc0^
where we pass the ctdb-messaging object conn to db_open() and add a
reference to it to the private db_ctdb_ctx for later use. Unfortunately
reinit_after_fork() destroys conn, leaving us with an invalid reference.
The previous patches added new lower level functions
messaging_ctdbd_reinit() and ctdbd_reinit_connection(), finally use them
them from messaging_reinit(). They preserve the conn object and simply
reinitialize the IPC fd.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Volker Lendecke <vl at samba.org>
Autobuild-User(master): Ralph Böhme <slow at samba.org>
Autobuild-Date(master): Mon Jul 11 23:45:20 CEST 2016 on sn-devel-144
commit f991381356b09c09edf410b2659bb4f833102be7
Author: Ralph Boehme <slow at samba.org>
Date: Sat Jul 9 14:30:35 2016 +0200
s3-messaging/ctdb: add messaging_ctdbd_reinit()
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit c6373aba00dd7a69b2e69c979510e3de04700b2d
Author: Ralph Boehme <slow at samba.org>
Date: Sat Jul 9 13:20:01 2016 +0200
s3-messaging/ctdb: split messaging_ctdbd_init()
Split out and internal function from messaging_ctdbd_init() that does
the connection setup. Keep the conn object allocation in
messaging_ctdbd_init().
This is in preperation of adding messaging_ctdbd_reinit() which will use
the new internal function as well.
messaging_ctdbd_init_internal() has a new reinit flag,
messaging_ctdbd_init() calls with reinit=false resulting in unmodified
behaviour.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit 84da49f89b905a80d82901bfc1e4c8ec534edd3d
Author: Ralph Boehme <slow at samba.org>
Date: Sat Jul 9 08:59:09 2016 +0200
ctdbd_conn: add ctdbd_reinit_connection()
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit 1184931001be983b858f44468aeb083140d924ad
Author: Ralph Boehme <slow at samba.org>
Date: Sat Jul 9 08:48:49 2016 +0200
ctdbd_conn: split ctdbd_init_connection()
Split ctdbd_init_connection() into an internal function that does the
connection setup and only keep the conn object allocation in
ctdbd_init_connection().
This is in preperation of adding ctdbd_reinit_connection() which will
use the new internal function as well.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Volker Lendecke <vl at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source3/include/ctdbd_conn.h | 3 ++
source3/include/messages.h | 3 ++
source3/lib/ctdb_dummy.c | 7 ++++
source3/lib/ctdbd_conn.c | 72 +++++++++++++++++++++++++--------
source3/lib/messages.c | 6 +--
source3/lib/messages_ctdbd.c | 95 +++++++++++++++++++++++++++++++-------------
6 files changed, 139 insertions(+), 47 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 11e71ba..bbebbce 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -33,6 +33,9 @@ struct messaging_rec;
int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
const char *sockname, int timeout,
struct ctdbd_connection **pconn);
+int ctdbd_reinit_connection(TALLOC_CTX *mem_ctx,
+ const char *sockname, int timeout,
+ struct ctdbd_connection *conn);
uint32_t ctdbd_vnn(const struct ctdbd_connection *conn);
diff --git a/source3/include/messages.h b/source3/include/messages.h
index 8bbe026..2eaf146 100644
--- a/source3/include/messages.h
+++ b/source3/include/messages.h
@@ -79,6 +79,9 @@ struct messaging_backend {
int messaging_ctdbd_init(struct messaging_context *msg_ctx,
TALLOC_CTX *mem_ctx,
struct messaging_backend **presult);
+int messaging_ctdbd_reinit(struct messaging_context *msg_ctx,
+ TALLOC_CTX *mem_ctx,
+ struct messaging_backend *backend);
struct ctdbd_connection *messaging_ctdbd_connection(void);
bool message_send_all(struct messaging_context *msg_ctx,
diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c
index ec0bcc4..8b617ba 100644
--- a/source3/lib/ctdb_dummy.c
+++ b/source3/lib/ctdb_dummy.c
@@ -83,6 +83,13 @@ int messaging_ctdbd_init(struct messaging_context *msg_ctx,
return ENOSYS;
}
+int messaging_ctdbd_reinit(struct messaging_context *msg_ctx,
+ TALLOC_CTX *mem_ctx,
+ struct messaging_backend *backend)
+{
+ return ENOSYS;
+}
+
struct ctdbd_connection *messaging_ctdbd_connection(void)
{
return NULL;
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index d073c72..1f8ac94 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -405,20 +405,13 @@ static int ctdbd_connection_destructor(struct ctdbd_connection *c)
* Get us a ctdbd connection
*/
-int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
- const char *sockname, int timeout,
- struct ctdbd_connection **pconn)
+static int ctdbd_init_connection_internal(TALLOC_CTX *mem_ctx,
+ const char *sockname, int timeout,
+ struct ctdbd_connection *conn)
{
- struct ctdbd_connection *conn;
int ret;
- if (!(conn = talloc_zero(mem_ctx, struct ctdbd_connection))) {
- DEBUG(0, ("talloc failed\n"));
- return ENOMEM;
- }
-
conn->timeout = timeout;
-
if (conn->timeout == 0) {
conn->timeout = -1;
}
@@ -426,31 +419,53 @@ int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
ret = ctdbd_connect(sockname, &conn->fd);
if (ret != 0) {
DEBUG(1, ("ctdbd_connect failed: %s\n", strerror(ret)));
- goto fail;
+ return ret;
}
talloc_set_destructor(conn, ctdbd_connection_destructor);
ret = get_cluster_vnn(conn, &conn->our_vnn);
-
if (ret != 0) {
DEBUG(10, ("get_cluster_vnn failed: %s\n", strerror(ret)));
- goto fail;
+ return ret;
}
if (!ctdbd_working(conn, conn->our_vnn)) {
DEBUG(2, ("Node is not working, can not connect\n"));
- ret = EIO;
- goto fail;
+ return EIO;
}
generate_random_buffer((unsigned char *)&conn->rand_srvid,
sizeof(conn->rand_srvid));
ret = register_with_ctdbd(conn, conn->rand_srvid, NULL, NULL);
-
if (ret != 0) {
DEBUG(5, ("Could not register random srvid: %s\n",
strerror(ret)));
+ return ret;
+ }
+
+ return 0;
+}
+
+int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
+ const char *sockname, int timeout,
+ struct ctdbd_connection **pconn)
+{
+ struct ctdbd_connection *conn;
+ int ret;
+
+ if (!(conn = talloc_zero(mem_ctx, struct ctdbd_connection))) {
+ DEBUG(0, ("talloc failed\n"));
+ return ENOMEM;
+ }
+
+ ret = ctdbd_init_connection_internal(mem_ctx,
+ sockname,
+ timeout,
+ conn);
+ if (ret != 0) {
+ DBG_ERR("ctdbd_init_connection_internal failed (%s)\n",
+ strerror(ret));
goto fail;
}
@@ -462,6 +477,31 @@ int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
return ret;
}
+int ctdbd_reinit_connection(TALLOC_CTX *mem_ctx,
+ const char *sockname, int timeout,
+ struct ctdbd_connection *conn)
+{
+ int ret;
+
+ ret = ctdbd_connection_destructor(conn);
+ if (ret != 0) {
+ DBG_ERR("ctdbd_connection_destructor failed\n");
+ return ret;
+ }
+
+ ret = ctdbd_init_connection_internal(mem_ctx,
+ sockname,
+ timeout,
+ conn);
+ if (ret != 0) {
+ DBG_ERR("ctdbd_init_connection_internal failed (%s)\n",
+ strerror(ret));
+ return ret;
+ }
+
+ return 0;
+}
+
int ctdbd_conn_get_fd(struct ctdbd_connection *conn)
{
return conn->fd;
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 65e975e..5d90947 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -416,11 +416,9 @@ NTSTATUS messaging_reinit(struct messaging_context *msg_ctx)
return map_nt_error_from_unix(ret);
}
- TALLOC_FREE(msg_ctx->remote);
-
if (lp_clustering()) {
- ret = messaging_ctdbd_init(msg_ctx, msg_ctx,
- &msg_ctx->remote);
+ ret = messaging_ctdbd_reinit(msg_ctx, msg_ctx,
+ msg_ctx->remote);
if (ret != 0) {
DEBUG(1, ("messaging_ctdbd_init failed: %s\n",
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index 1645ccf..5964894 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -174,41 +174,40 @@ static void messaging_ctdbd_readable(struct tevent_context *ev,
ctdbd_socket_readable(conn);
}
-int messaging_ctdbd_init(struct messaging_context *msg_ctx,
- TALLOC_CTX *mem_ctx,
- struct messaging_backend **presult)
+static int messaging_ctdbd_init_internal(struct messaging_context *msg_ctx,
+ TALLOC_CTX *mem_ctx,
+ struct messaging_ctdbd_context *ctx,
+ bool reinit)
{
- struct messaging_backend *result;
- struct messaging_ctdbd_context *ctx;
struct tevent_context *ev;
int ret, ctdb_fd;
- if (!(result = talloc(mem_ctx, struct messaging_backend))) {
- DEBUG(0, ("talloc failed\n"));
- return ENOMEM;
- }
-
- if (!(ctx = talloc(result, struct messaging_ctdbd_context))) {
- DEBUG(0, ("talloc failed\n"));
- TALLOC_FREE(result);
- return ENOMEM;
- }
-
- ret = ctdbd_init_connection(ctx, lp_ctdbd_socket(),
- lp_ctdb_timeout(), &ctx->conn);
-
- if (ret != 0) {
- DBG_DEBUG("ctdbd_init_connection failed: %s\n",
- strerror(ret));
- TALLOC_FREE(result);
- return ret;
+ if (reinit) {
+ ret = ctdbd_reinit_connection(ctx,
+ lp_ctdbd_socket(),
+ lp_ctdb_timeout(),
+ ctx->conn);
+ if (ret != 0) {
+ DBG_ERR("ctdbd_reinit_connection failed: %s\n",
+ strerror(ret));
+ return ret;
+ }
+ } else {
+ ret = ctdbd_init_connection(ctx,
+ lp_ctdbd_socket(),
+ lp_ctdb_timeout(),
+ &ctx->conn);
+ if (ret != 0) {
+ DBG_ERR("ctdbd_init_connection failed: %s\n",
+ strerror(ret));
+ return ret;
+ }
}
ret = register_with_ctdbd(ctx->conn, MSG_SRVID_SAMBA, NULL, NULL);
if (ret != 0) {
DBG_DEBUG("Could not register MSG_SRVID_SAMBA: %s\n",
strerror(ret));
- TALLOC_FREE(result);
return ret;
}
@@ -217,7 +216,6 @@ int messaging_ctdbd_init(struct messaging_context *msg_ctx,
if (ret != 0) {
DEBUG(10, ("register_with_ctdbd failed: %s\n",
strerror(ret)));
- TALLOC_FREE(result);
return ret;
}
@@ -227,7 +225,6 @@ int messaging_ctdbd_init(struct messaging_context *msg_ctx,
ctx->fde = tevent_add_fd(ev, ctx, ctdb_fd, TEVENT_FD_READ,
messaging_ctdbd_readable, ctx->conn);
if (ctx->fde == NULL) {
- TALLOC_FREE(result);
return ENOMEM;
}
@@ -237,9 +234,53 @@ int messaging_ctdbd_init(struct messaging_context *msg_ctx,
set_my_vnn(ctdbd_vnn(ctx->conn));
+ return 0;
+}
+
+int messaging_ctdbd_init(struct messaging_context *msg_ctx,
+ TALLOC_CTX *mem_ctx,
+ struct messaging_backend **presult)
+{
+ struct messaging_backend *result;
+ struct messaging_ctdbd_context *ctx;
+ int ret;
+
+ if (!(result = talloc(mem_ctx, struct messaging_backend))) {
+ DEBUG(0, ("talloc failed\n"));
+ return ENOMEM;
+ }
+
+ if (!(ctx = talloc(result, struct messaging_ctdbd_context))) {
+ DEBUG(0, ("talloc failed\n"));
+ TALLOC_FREE(result);
+ return ENOMEM;
+ }
+
+ ret = messaging_ctdbd_init_internal(msg_ctx, mem_ctx, ctx, false);
+ if (ret != 0) {
+ TALLOC_FREE(result);
+ return ret;
+ }
+
result->send_fn = messaging_ctdb_send;
result->private_data = (void *)ctx;
*presult = result;
return 0;
}
+
+int messaging_ctdbd_reinit(struct messaging_context *msg_ctx,
+ TALLOC_CTX *mem_ctx,
+ struct messaging_backend *backend)
+{
+ struct messaging_ctdbd_context *ctx = talloc_get_type_abort(
+ backend->private_data, struct messaging_ctdbd_context);
+ int ret;
+
+ ret = messaging_ctdbd_init_internal(msg_ctx, mem_ctx, ctx, true);
+ if (ret != 0) {
+ return ret;
+ }
+
+ return 0;
+}
--
Samba Shared Repository
More information about the samba-cvs
mailing list