[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Sat Oct 3 01:05:06 UTC 2015
The branch, master has been updated
via 97bb100 lib: Pass sockname and timeout to ctdbd_probe()
via 770b0e4 lib: Pass sockname and timeout to ctdbd_messaging_connection
via 025fb48 lib: Move lp_ctdbd_socket() to cluster_support.c
via ccd31e0 lib: Pass parameters to ctdbd_init_connection()
via 0bc244e lib: Store sockname in ctdbd_connection
via 6c86062 lib: Remove temporary ctdb_connection in ctdb_control
via 2aedb2d lib: Store ctdb_timeout in ctdb_connection
via 54c7b05 lib: Lift lp_ctdbd_socket() call up one level
from 6755376 kerberos: make sure we only use prompter type when available.
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 97bb100a765e5dc3983315df11c9654798a76574
Author: Volker Lendecke <vl at samba.org>
Date: Fri Sep 25 16:52:58 2015 -0700
lib: Pass sockname and timeout to ctdbd_probe()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Sat Oct 3 03:04:39 CEST 2015 on sn-devel-104
commit 770b0e40d27beaa8513aebd1590aa4783a4a7eed
Author: Volker Lendecke <vl at samba.org>
Date: Fri Sep 25 16:49:33 2015 -0700
lib: Pass sockname and timeout to ctdbd_messaging_connection
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 025fb48360028ec20f19858dab8d528c5abf1867
Author: Volker Lendecke <vl at samba.org>
Date: Thu Oct 1 12:28:21 2015 +0200
lib: Move lp_ctdbd_socket() to cluster_support.c
There we have a #ifdef CTDB_SOCKET anyway
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit ccd31e0c18f3eea2a92cc683ab197b904fdb37dc
Author: Volker Lendecke <vl at samba.org>
Date: Fri Sep 25 16:09:23 2015 -0700
lib: Pass parameters to ctdbd_init_connection()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 0bc244ee58ae9fce2574113dd244ffa03934f5d8
Author: Volker Lendecke <vl at samba.org>
Date: Fri Sep 25 15:49:16 2015 -0700
lib: Store sockname in ctdbd_connection
We'll need it in ctdbd_traverse()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 6c8606245381262ed43c14dec403b5a8a0eee5b5
Author: Volker Lendecke <vl at samba.org>
Date: Fri Sep 25 14:39:41 2015 -0700
lib: Remove temporary ctdb_connection in ctdb_control
I can just assume this is a bad hack for a condition that should have been
fixed in a different way. Today we pretty much expect a messaging_context to be
properly initialized everywhere, and this includes a ctdb connection.
If something later fails due to this commit, we need to do a
messaging_init before the offending call
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 2aedb2d0851a09ca63a886ae14ee666ead6f8702
Author: Volker Lendecke <vl at samba.org>
Date: Fri Sep 25 14:36:35 2015 -0700
lib: Store ctdb_timeout in ctdb_connection
This lifts the call to lp_ctdb_timeout() up
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 54c7b052832d59d4c373bdae81b1ee68b06d8218
Author: Volker Lendecke <vl at samba.org>
Date: Fri Sep 25 14:32:09 2015 -0700
lib: Lift lp_ctdbd_socket() call up one level
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source3/include/ctdbd_conn.h | 6 ++--
source3/lib/cluster_support.c | 16 +++++++++
source3/lib/cluster_support.h | 1 +
source3/lib/ctdb_dummy.c | 7 +---
source3/lib/ctdbd_conn.c | 74 ++++++++++++++++------------------------
source3/lib/dbwrap/dbwrap_ctdb.c | 7 ++--
source3/lib/dbwrap/dbwrap_open.c | 1 +
source3/lib/messages_ctdbd.c | 4 ++-
source3/lib/util_cluster.c | 3 +-
9 files changed, 62 insertions(+), 57 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 9f7ec9f..6c46cdb 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -27,10 +27,10 @@ struct messaging_context;
struct messaging_rec;
NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
+ const char *sockname, int timeout,
struct ctdbd_connection **pconn);
uint32_t ctdbd_vnn(const struct ctdbd_connection *conn);
-const char *lp_ctdbd_socket(void);
NTSTATUS ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
struct messaging_context *msg_ctx);
@@ -63,7 +63,7 @@ NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
void *private_data),
void *private_data);
-NTSTATUS ctdbd_traverse(uint32_t db_id,
+NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
void (*fn)(TDB_DATA key, TDB_DATA data,
void *private_data),
void *private_data);
@@ -92,6 +92,6 @@ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
const uint8_t *msg, size_t msglen,
void *private_data),
void *private_data);
-NTSTATUS ctdbd_probe(void);
+NTSTATUS ctdbd_probe(const char *sockname, int timeout);
#endif /* _CTDBD_CONN_H */
diff --git a/source3/lib/cluster_support.c b/source3/lib/cluster_support.c
index b8925aa..c11b1f7 100644
--- a/source3/lib/cluster_support.c
+++ b/source3/lib/cluster_support.c
@@ -54,3 +54,19 @@ const char *cluster_support_features(void)
return v;
}
+
+const char *lp_ctdbd_socket(void)
+{
+ const char *ret;
+
+ ret = lp__ctdbd_socket();
+ if (ret != NULL && strlen(ret) > 0) {
+ return ret;
+ }
+
+#ifdef CTDB_SOCKET
+ return CTDB_SOCKET;
+#else
+ return "";
+#endif
+}
diff --git a/source3/lib/cluster_support.h b/source3/lib/cluster_support.h
index 0a03d2b..5e040bb 100644
--- a/source3/lib/cluster_support.h
+++ b/source3/lib/cluster_support.h
@@ -18,3 +18,4 @@
bool cluster_support_available(void);
const char *cluster_support_features(void);
+const char *lp_ctdbd_socket(void);
diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c
index 2d1f6de..d8658cf 100644
--- a/source3/lib/ctdb_dummy.c
+++ b/source3/lib/ctdb_dummy.c
@@ -24,7 +24,7 @@
#include "lib/dbwrap/dbwrap_ctdb.h"
#include "torture/proto.h"
-NTSTATUS ctdbd_probe(void)
+NTSTATUS ctdbd_probe(const char *sockname, int timeout)
{
return NT_STATUS_NOT_IMPLEMENTED;
}
@@ -58,11 +58,6 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
return NT_STATUS_NOT_IMPLEMENTED;
}
-const char *lp_ctdbd_socket(void)
-{
- return "";
-}
-
bool ctdb_processes_exist(struct ctdbd_connection *conn,
const struct server_id *pids, int num_pids,
bool *results)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 9aec517..da2c3a9 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -43,6 +43,7 @@ struct ctdbd_srvid_cb {
};
struct ctdbd_connection {
+ const char *sockname; /* Needed in ctdbd_traverse */
struct messaging_context *msg_ctx;
uint32_t reqid;
uint32_t our_vnn;
@@ -50,6 +51,7 @@ struct ctdbd_connection {
struct ctdbd_srvid_cb *callbacks;
int fd;
struct tevent_fd *fde;
+ int timeout;
};
static uint32_t ctdbd_next_reqid(struct ctdbd_connection *conn)
@@ -249,25 +251,12 @@ uint32_t ctdbd_vnn(const struct ctdbd_connection *conn)
return conn->our_vnn;
}
-const char *lp_ctdbd_socket(void)
-{
- const char *ret;
-
- ret = lp__ctdbd_socket();
- if (ret != NULL && strlen(ret) > 0) {
- return ret;
- }
-
- return CTDB_SOCKET;
-}
-
/*
* Get us a ctdb connection
*/
-static int ctdbd_connect(int *pfd)
+static int ctdbd_connect(const char *sockname, int *pfd)
{
- const char *sockname = lp_ctdbd_socket();
struct sockaddr_un addr = { 0, };
int fd;
socklen_t salen;
@@ -304,19 +293,14 @@ static int ctdbd_connect(int *pfd)
return 0;
}
-static int ctdb_read_packet(int fd, TALLOC_CTX *mem_ctx,
+static int ctdb_read_packet(int fd, int timeout, TALLOC_CTX *mem_ctx,
struct ctdb_req_header **result)
{
- int timeout = lp_ctdb_timeout();
struct ctdb_req_header *req;
int ret, revents;
uint32_t msglen;
ssize_t nread;
- if (timeout == 0) {
- timeout = -1;
- }
-
if (timeout != -1) {
ret = poll_one_fd(fd, POLLIN, timeout, &revents);
if (ret == -1) {
@@ -376,7 +360,7 @@ static int ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid,
next_pkt:
- ret = ctdb_read_packet(conn->fd, mem_ctx, &hdr);
+ ret = ctdb_read_packet(conn->fd, conn->timeout, mem_ctx, &hdr);
if (ret != 0) {
DEBUG(0, ("ctdb_read_packet failed: %s\n", strerror(ret)));
cluster_fatal("ctdbd died\n");
@@ -429,6 +413,7 @@ static int ctdbd_connection_destructor(struct ctdbd_connection *c)
*/
static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
+ const char *sockname, int timeout,
struct ctdbd_connection **pconn)
{
struct ctdbd_connection *conn;
@@ -440,7 +425,20 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_MEMORY;
}
- ret = ctdbd_connect(&conn->fd);
+ conn->sockname = talloc_strdup(conn, sockname);
+ if (conn->sockname == NULL) {
+ DBG_ERR("%s: talloc failed\n", __func__);
+ status = NT_STATUS_NO_MEMORY;
+ goto fail;
+ }
+
+ conn->timeout = timeout;
+
+ if (conn->timeout == 0) {
+ conn->timeout = -1;
+ }
+
+ ret = ctdbd_connect(conn->sockname, &conn->fd);
if (ret != 0) {
status = map_nt_error_from_unix(ret);
DEBUG(1, ("ctdbd_connect failed: %s\n", strerror(ret)));
@@ -485,12 +483,13 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
*/
NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
+ const char *sockname, int timeout,
struct ctdbd_connection **pconn)
{
struct ctdbd_connection *conn;
NTSTATUS status;
- status = ctdbd_init_connection(mem_ctx, &conn);
+ status = ctdbd_init_connection(mem_ctx, sockname, timeout, &conn);
if (!NT_STATUS_IS_OK(status)) {
return status;
@@ -554,7 +553,7 @@ static void ctdbd_socket_handler(struct tevent_context *event_ctx,
struct ctdb_req_header *hdr = NULL;
int ret;
- ret = ctdb_read_packet(conn->fd, talloc_tos(), &hdr);
+ ret = ctdb_read_packet(conn->fd, conn->timeout, talloc_tos(), &hdr);
if (ret != 0) {
DEBUG(0, ("ctdb_read_packet failed: %s\n", strerror(ret)));
cluster_fatal("ctdbd died\n");
@@ -644,24 +643,11 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
struct ctdb_req_control req;
struct ctdb_req_header *hdr;
struct ctdb_reply_control *reply = NULL;
- struct ctdbd_connection *new_conn = NULL;
struct iovec iov[2];
ssize_t nwritten;
NTSTATUS status;
int ret;
- if (conn == NULL) {
- status = ctdbd_init_connection(NULL, &new_conn);
-
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(10, ("Could not init temp connection: %s\n",
- nt_errstr(status)));
- goto fail;
- }
-
- conn = new_conn;
- }
-
ZERO_STRUCT(req);
req.hdr.length = offsetof(struct ctdb_req_control, data) + data.dsize;
req.hdr.ctdb_magic = CTDB_MAGIC;
@@ -689,7 +675,6 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
}
if (flags & CTDB_CTRL_FLAG_NOREPLY) {
- TALLOC_FREE(new_conn);
if (cstatus) {
*cstatus = 0;
}
@@ -724,7 +709,6 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
status = NT_STATUS_OK;
fail:
- TALLOC_FREE(new_conn);
TALLOC_FREE(reply);
return status;
}
@@ -1072,7 +1056,7 @@ NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
everything in-line.
*/
-NTSTATUS ctdbd_traverse(uint32_t db_id,
+NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
void (*fn)(TDB_DATA key, TDB_DATA data,
void *private_data),
void *private_data)
@@ -1085,7 +1069,8 @@ NTSTATUS ctdbd_traverse(uint32_t db_id,
int cstatus;
become_root();
- status = ctdbd_init_connection(NULL, &conn);
+ status = ctdbd_init_connection(NULL, master->sockname, master->timeout,
+ &conn);
unbecome_root();
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("ctdbd_init_connection failed: %s\n",
@@ -1125,7 +1110,7 @@ NTSTATUS ctdbd_traverse(uint32_t db_id,
struct ctdb_rec_data *d;
int ret;
- ret = ctdb_read_packet(conn->fd, conn, &hdr);
+ ret = ctdb_read_packet(conn->fd, conn->timeout, conn, &hdr);
if (ret != 0) {
DEBUG(0, ("ctdb_read_packet failed: %s\n",
strerror(ret)));
@@ -1316,7 +1301,7 @@ NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn)
return status;
}
-NTSTATUS ctdbd_probe(void)
+NTSTATUS ctdbd_probe(const char *sockname, int timeout)
{
/*
* Do a very early check if ctdbd is around to avoid an abort and core
@@ -1325,7 +1310,8 @@ NTSTATUS ctdbd_probe(void)
struct ctdbd_connection *conn = NULL;
NTSTATUS status;
- status = ctdbd_messaging_connection(talloc_tos(), &conn);
+ status = ctdbd_messaging_connection(talloc_tos(), sockname, timeout,
+ &conn);
/*
* We only care if we can connect.
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 3b68338..9852bc7 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -35,6 +35,7 @@
#include "dbwrap/dbwrap_ctdb.h"
#include "g_lock.h"
#include "messages.h"
+#include "lib/cluster_support.h"
struct db_ctdb_transaction_handle {
struct db_ctdb_ctx *ctx;
@@ -1414,7 +1415,8 @@ static int db_ctdb_traverse(struct db_context *db,
return ret;
}
- status = ctdbd_traverse(ctx->db_id, traverse_callback, &state);
+ status = ctdbd_traverse(messaging_ctdbd_connection(), ctx->db_id,
+ traverse_callback, &state);
if (!NT_STATUS_IS_OK(status)) {
return -1;
}
@@ -1503,7 +1505,8 @@ static int db_ctdb_traverse_read(struct db_context *db,
return tdb_traverse_read(ctx->wtdb->tdb, traverse_persistent_callback_read, &state);
}
- status = ctdbd_traverse(ctx->db_id, traverse_read_callback, &state);
+ status = ctdbd_traverse(messaging_ctdbd_connection(), ctx->db_id,
+ traverse_read_callback, &state);
if (!NT_STATUS_IS_OK(status)) {
return -1;
}
diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c
index 64f484e..59fb3e4 100644
--- a/source3/lib/dbwrap/dbwrap_open.c
+++ b/source3/lib/dbwrap/dbwrap_open.c
@@ -25,6 +25,7 @@
#include "dbwrap/dbwrap_tdb.h"
#include "dbwrap/dbwrap_ctdb.h"
#include "lib/param/param.h"
+#include "lib/cluster_support.h"
#include "util_tdb.h"
#include "ctdbd_conn.h"
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index 294debe..4d8b574 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -23,6 +23,7 @@
#include "lib/util/iov_buf.h"
#include "lib/messages_util.h"
#include "ctdbd_conn.h"
+#include "lib/cluster_support.h"
struct messaging_ctdbd_context {
@@ -182,7 +183,8 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
return NT_STATUS_NO_MEMORY;
}
- status = ctdbd_messaging_connection(ctx, &ctx->conn);
+ status = ctdbd_messaging_connection(ctx, lp_ctdbd_socket(),
+ lp_ctdb_timeout(), &ctx->conn);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("ctdbd_messaging_connection failed: %s\n",
diff --git a/source3/lib/util_cluster.c b/source3/lib/util_cluster.c
index ef79c8b..85f006c 100644
--- a/source3/lib/util_cluster.c
+++ b/source3/lib/util_cluster.c
@@ -21,13 +21,14 @@
#include "includes.h"
#include "ctdbd_conn.h"
#include "util_cluster.h"
+#include "lib/cluster_support.h"
bool cluster_probe_ok(void)
{
if (lp_clustering()) {
NTSTATUS status;
- status = ctdbd_probe();
+ status = ctdbd_probe(lp_ctdbd_socket(), lp_ctdb_timeout());
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("clustering=yes but ctdbd connect failed: "
"%s\n", nt_errstr(status)));
--
Samba Shared Repository
More information about the samba-cvs
mailing list