[PATCH] Cleanups in ctdb_conn/ctdb
Volker Lendecke
Volker.Lendecke at SerNet.DE
Wed Apr 20 06:34:40 UTC 2016
Hi!
Review appreciated!
Thanks, Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 78395054bf118885e4c17c3172a64959d6f6e5b4 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 8 Apr 2016 15:59:08 +0200
Subject: [PATCH 01/11] ctdbd_conn: Adapt loop counter's type to the loop limit
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 04f6f2f..127c3ad 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -201,7 +201,8 @@ static bool ctdbd_working(struct ctdbd_connection *conn, uint32_t vnn)
struct ctdb_node_map_old *m;
uint32_t failure_flags;
bool ok = false;
- int i, ret;
+ uint32_t i;
+ int ret;
ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
CTDB_CONTROL_GET_NODEMAP, 0, 0,
--
2.1.4
From 6857193fc3b6d2de4bf581faf5aa9c5eb11aaabd Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 19 Apr 2016 16:14:30 +0200
Subject: [PATCH 02/11] ctdbd_conn: Use sys_poll_intr
This pulls in far less dependencies than poll_intr_one_fd and is not much more
complex to call
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 127c3ad..bb8ab0a 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -25,6 +25,7 @@
#include "system/select.h"
#include "lib/util/sys_rw_data.h"
#include "lib/util/iov_buf.h"
+#include "lib/util/select.h"
#include "messages.h"
@@ -296,12 +297,14 @@ static int ctdb_read_packet(int fd, int timeout, TALLOC_CTX *mem_ctx,
struct ctdb_req_header **result)
{
struct ctdb_req_header *req;
- int ret, revents;
uint32_t msglen;
ssize_t nread;
if (timeout != -1) {
- ret = poll_intr_one_fd(fd, POLLIN, timeout, &revents);
+ struct pollfd pfd = { .fd = fd, .events = POLLIN };
+ int ret;
+
+ ret = sys_poll_intr(&pfd, 1, timeout);
if (ret == -1) {
return errno;
}
--
2.1.4
From 3c31668f7a4f462e6cacda187cae6235e94cfb02 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 5 Apr 2016 09:52:01 +0200
Subject: [PATCH 03/11] ctdbd_conn: Use ctdbd_init_connection in ctdbd_probe
We are only interested in ctdb connectability here.
ctdbd_messaging_connection() does a few more calls not required here
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index bb8ab0a..3cec253 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -1304,8 +1304,8 @@ int ctdbd_probe(const char *sockname, int timeout)
struct ctdbd_connection *conn = NULL;
int ret;
- ret = ctdbd_messaging_connection(talloc_tos(), sockname, timeout,
- &conn);
+ ret = ctdbd_init_connection(talloc_tos(), sockname, timeout,
+ &conn);
/*
* We only care if we can connect.
--
2.1.4
From d0825a6a07bde2002c06cdaebb114eb40e901f0d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 5 Apr 2016 10:09:35 +0200
Subject: [PATCH 04/11] ctdbd_conn: Make ctdbd_init_connection public
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 4 ++++
source3/lib/ctdbd_conn.c | 6 +++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 27993c7..a4eab74 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -26,6 +26,10 @@ struct ctdbd_connection;
struct messaging_context;
struct messaging_rec;
+int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
+ const char *sockname, int timeout,
+ struct ctdbd_connection **pconn);
+
int ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
const char *sockname, int timeout,
struct ctdbd_connection **pconn);
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 3cec253..2751850 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -420,9 +420,9 @@ static int ctdbd_connection_destructor(struct ctdbd_connection *c)
* Get us a ctdbd connection
*/
-static int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
- const char *sockname, int timeout,
- struct ctdbd_connection **pconn)
+int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
+ const char *sockname, int timeout,
+ struct ctdbd_connection **pconn)
{
struct ctdbd_connection *conn;
int ret;
--
2.1.4
From 25cbf3e5cac56bf437c8377eaa4e5ce85c3332b8 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 5 Apr 2016 10:11:44 +0200
Subject: [PATCH 05/11] lib: Use ctdbd_init_connection in messaging_ctdbd_init
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/messages_ctdbd.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index 48563a8..a61c773 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -178,12 +178,20 @@ int messaging_ctdbd_init(struct messaging_context *msg_ctx,
return ENOMEM;
}
- ret = ctdbd_messaging_connection(ctx, lp_ctdbd_socket(),
- lp_ctdb_timeout(), &ctx->conn);
+ ret = ctdbd_init_connection(ctx, lp_ctdbd_socket(),
+ lp_ctdb_timeout(), &ctx->conn);
if (ret != 0) {
- DEBUG(10, ("ctdbd_messaging_connection failed: %s\n",
- strerror(ret)));
+ DBG_DEBUG("ctdbd_init_connection failed: %s\n",
+ strerror(ret));
+ TALLOC_FREE(result);
+ 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;
}
--
2.1.4
From 0d466553daa9e1bf2e0438fa4b71a7ccf883133a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 5 Apr 2016 10:14:11 +0200
Subject: [PATCH 06/11] ctdbd_conn: Remove unused ctdbd_messaging_connection
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 4 ----
source3/lib/ctdbd_conn.c | 30 ------------------------------
2 files changed, 34 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index a4eab74..bcaa094 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -30,10 +30,6 @@ int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
const char *sockname, int timeout,
struct ctdbd_connection **pconn);
-int 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);
int ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 2751850..9cceeb1 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -484,36 +484,6 @@ int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
return ret;
}
-/*
- * Get us a ctdbd connection and register us as a process
- */
-
-int ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
- const char *sockname, int timeout,
- struct ctdbd_connection **pconn)
-{
- struct ctdbd_connection *conn;
- int ret;
-
- ret = ctdbd_init_connection(mem_ctx, sockname, timeout, &conn);
-
- if (ret != 0) {
- return ret;
- }
-
- ret = register_with_ctdbd(conn, MSG_SRVID_SAMBA, NULL, NULL);
- if (ret != 0) {
- goto fail;
- }
-
- *pconn = conn;
- return 0;
-
- fail:
- TALLOC_FREE(conn);
- return ret;
-}
-
struct messaging_context *ctdb_conn_msg_ctx(struct ctdbd_connection *conn)
{
return conn->msg_ctx;
--
2.1.4
From c638d32cab45ff3b67fe1b9143ff8e8ac72696dd Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 5 Apr 2016 17:30:11 +0200
Subject: [PATCH 07/11] lib: Move ctdbd_init_connection out of ctdbd_traverse()
2 effects: This removes the [un]become_root calls from ctdbd_conn,
and it makes it possible to re-use the traversal connections, should
the setup/teardown become a problem in the future.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 24 ++++--------------------
source3/lib/dbwrap/dbwrap_ctdb.c | 36 ++++++++++++++++++++++++++++++++----
2 files changed, 36 insertions(+), 24 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 9cceeb1..1f0d61c 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -1014,32 +1014,21 @@ int ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
}
/*
- Traverse a ctdb database. This uses a kind-of hackish way to open a second
- connection to ctdbd to avoid the hairy recursive and async problems with
- everything in-line.
+ Traverse a ctdb database. "conn" must be an otherwise unused
+ ctdb_connection where no other messages but the traverse ones are
+ expected.
*/
-int ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
+int ctdbd_traverse(struct ctdbd_connection *conn, uint32_t db_id,
void (*fn)(TDB_DATA key, TDB_DATA data,
void *private_data),
void *private_data)
{
- struct ctdbd_connection *conn;
int ret;
TDB_DATA key, data;
struct ctdb_traverse_start t;
int cstatus;
- become_root();
- ret = ctdbd_init_connection(NULL, master->sockname, master->timeout,
- &conn);
- unbecome_root();
- if (ret != 0) {
- DEBUG(0, ("ctdbd_init_connection failed: %s\n",
- strerror(ret)));
- return ret;
- }
-
t.db_id = db_id;
t.srvid = conn->rand_srvid;
t.reqid = ctdbd_next_reqid(conn);
@@ -1061,7 +1050,6 @@ int ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
*/
ret = EIO;
}
- TALLOC_FREE(conn);
return ret;
}
@@ -1080,7 +1068,6 @@ int ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
if (hdr->operation != CTDB_REQ_MESSAGE) {
DEBUG(0, ("Got operation %u, expected a message\n",
(unsigned)hdr->operation));
- TALLOC_FREE(conn);
return EIO;
}
@@ -1089,7 +1076,6 @@ int ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
if (m->datalen < sizeof(uint32_t) || m->datalen != d->length) {
DEBUG(0, ("Got invalid traverse data of length %d\n",
(int)m->datalen));
- TALLOC_FREE(conn);
return EIO;
}
@@ -1100,14 +1086,12 @@ int ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
if (key.dsize == 0 && data.dsize == 0) {
/* end of traverse */
- TALLOC_FREE(conn);
return 0;
}
if (data.dsize < sizeof(struct ctdb_ltdb_header)) {
DEBUG(0, ("Got invalid ltdb header length %d\n",
(int)data.dsize));
- TALLOC_FREE(conn);
return EIO;
}
data.dsize -= sizeof(struct ctdb_ltdb_header);
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 93df7ef..59c0c78 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -1358,6 +1358,36 @@ static int traverse_persistent_callback_dbwrap(struct db_record *rec, void* data
return traverse_persistent_callback(NULL, rec->key, rec->value, data);
}
+static int db_ctdbd_traverse(uint32_t db_id,
+ void (*fn)(TDB_DATA key, TDB_DATA data,
+ void *private_data),
+ void *private_data)
+{
+ struct ctdbd_connection *conn;
+ int ret;
+
+ become_root();
+ ret = ctdbd_init_connection(talloc_tos(), lp_ctdbd_socket(),
+ lp_ctdb_timeout(), &conn);
+ unbecome_root();
+ if (ret != 0) {
+ DBG_WARNING("ctdbd_init_connection failed: %s\n",
+ strerror(ret));
+ return ret;
+ }
+
+ ret = ctdbd_traverse(conn, db_id, fn, private_data);
+ TALLOC_FREE(conn);
+
+ if (ret != 0) {
+ DBG_WARNING("ctdbd_traverse failed: %s\n",
+ strerror(ret));
+ return ret;
+ }
+
+ return 0;
+}
+
static int db_ctdb_traverse(struct db_context *db,
int (*fn)(struct db_record *rec,
@@ -1422,8 +1452,7 @@ static int db_ctdb_traverse(struct db_context *db,
return ret;
}
- ret = ctdbd_traverse(messaging_ctdbd_connection(), ctx->db_id,
- traverse_callback, &state);
+ ret = db_ctdbd_traverse(ctx->db_id, traverse_callback, &state);
if (ret != 0) {
return -1;
}
@@ -1512,8 +1541,7 @@ static int db_ctdb_traverse_read(struct db_context *db,
return tdb_traverse_read(ctx->wtdb->tdb, traverse_persistent_callback_read, &state);
}
- ret = ctdbd_traverse(messaging_ctdbd_connection(), ctx->db_id,
- traverse_read_callback, &state);
+ ret = db_ctdbd_traverse(ctx->db_id, traverse_read_callback, &state);
if (ret != 0) {
return -1;
}
--
2.1.4
From 91dbca8c5d794ccb5eb21711a62a9077c75bb93a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 5 Apr 2016 07:26:34 +0200
Subject: [PATCH 08/11] lib: serverid.h references struct server_id
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/serverid.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/source3/include/serverid.h b/source3/include/serverid.h
index 5db61b9..19caec8 100644
--- a/source3/include/serverid.h
+++ b/source3/include/serverid.h
@@ -22,6 +22,7 @@
#include "replace.h"
#include "lib/dbwrap/dbwrap.h"
+#include "librpc/gen_ndr/server_id.h"
/*
* Register a server with its unique id
--
2.1.4
From 8f6c4fc239ae52a7f0e1129ab25a7f984e54f201 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 8 Apr 2016 16:14:33 +0200
Subject: [PATCH 09/11] ctdbd_conn: Avoid "includes.h"
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 4 ++++
source3/lib/ctdbd_conn.c | 8 ++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index bcaa094..bf371e6 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -20,7 +20,11 @@
#ifndef _CTDBD_CONN_H
#define _CTDBD_CONN_H
+#include "replace.h"
+#include "system/filesys.h"
+#include "system/network.h"
#include <tdb.h>
+#include <tevent.h>
struct ctdbd_connection;
struct messaging_context;
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 1f0d61c..80b65f3 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -18,7 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "includes.h"
+#include "replace.h"
#include "util_tdb.h"
#include "serverid.h"
#include "ctdbd_conn.h"
@@ -26,6 +26,10 @@
#include "lib/util/sys_rw_data.h"
#include "lib/util/iov_buf.h"
#include "lib/util/select.h"
+#include "lib/util/debug.h"
+#include "lib/util/talloc_stack.h"
+#include "lib/util/genrand.h"
+#include "lib/util/fault.h"
#include "messages.h"
@@ -1053,7 +1057,7 @@ int ctdbd_traverse(struct ctdbd_connection *conn, uint32_t db_id,
return ret;
}
- while (True) {
+ while (true) {
struct ctdb_req_header *hdr = NULL;
struct ctdb_req_message_old *m;
struct ctdb_rec_data_old *d;
--
2.1.4
From 5b87ef6aed1fb87cae6502b35a87f5b56500bd59 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 13 Apr 2016 18:47:46 +0200
Subject: [PATCH 10/11] ctdbd_conn: Use ctdbd_control_local where possible
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 41 ++++++++++++++++++-----------------------
1 file changed, 18 insertions(+), 23 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 80b65f3..391ba8d 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -116,9 +116,8 @@ int register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
size_t num_callbacks;
struct ctdbd_srvid_cb *tmp;
- ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_REGISTER_SRVID, srvid, 0,
- tdb_null, NULL, NULL, &cstatus);
+ ret = ctdbd_control_local(conn, CTDB_CONTROL_REGISTER_SRVID, srvid, 0,
+ tdb_null, NULL, NULL, &cstatus);
if (ret != 0) {
return ret;
}
@@ -185,9 +184,8 @@ static int get_cluster_vnn(struct ctdbd_connection *conn, uint32_t *vnn)
{
int32_t cstatus=-1;
int ret;
- ret = ctdbd_control(conn,
- CTDB_CURRENT_NODE, CTDB_CONTROL_GET_PNN, 0, 0,
- tdb_null, NULL, NULL, &cstatus);
+ ret = ctdbd_control_local(conn, CTDB_CONTROL_GET_PNN, 0, 0,
+ tdb_null, NULL, NULL, &cstatus);
if (ret != 0) {
DEBUG(1, ("ctdbd_control failed: %s\n", strerror(ret)));
return ret;
@@ -209,9 +207,8 @@ static bool ctdbd_working(struct ctdbd_connection *conn, uint32_t vnn)
uint32_t i;
int ret;
- ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_GET_NODEMAP, 0, 0,
- tdb_null, talloc_tos(), &outdata, &cstatus);
+ ret = ctdbd_control_local(conn, CTDB_CONTROL_GET_NODEMAP, 0, 0,
+ tdb_null, talloc_tos(), &outdata, &cstatus);
if (ret != 0) {
DEBUG(1, ("ctdbd_control failed: %s\n", strerror(ret)));
return false;
@@ -828,9 +825,8 @@ char *ctdbd_dbpath(struct ctdbd_connection *conn,
data.dptr = (uint8_t*)&db_id;
data.dsize = sizeof(db_id);
- ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_GETDBPATH, 0, 0, data,
- mem_ctx, &rdata, &cstatus);
+ ret = ctdbd_control_local(conn, CTDB_CONTROL_GETDBPATH, 0, 0, data,
+ mem_ctx, &rdata, &cstatus);
if ((ret != 0) || cstatus != 0) {
DEBUG(0, (__location__ " ctdb_control for getdbpath failed: %s\n",
strerror(ret)));
@@ -853,11 +849,11 @@ int ctdbd_db_attach(struct ctdbd_connection *conn,
data = string_term_tdb_data(name);
- ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
- persistent
- ? CTDB_CONTROL_DB_ATTACH_PERSISTENT
- : CTDB_CONTROL_DB_ATTACH,
- tdb_flags, 0, data, NULL, &data, &cstatus);
+ ret = ctdbd_control_local(conn,
+ persistent
+ ? CTDB_CONTROL_DB_ATTACH_PERSISTENT
+ : CTDB_CONTROL_DB_ATTACH,
+ tdb_flags, 0, data, NULL, &data, &cstatus);
if (ret != 0) {
DEBUG(0, (__location__ " ctdb_control for db_attach "
"failed: %s\n", strerror(ret)));
@@ -879,9 +875,8 @@ int ctdbd_db_attach(struct ctdbd_connection *conn,
data.dptr = (uint8_t *)db_id;
data.dsize = sizeof(*db_id);
- ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_ENABLE_SEQNUM, 0, 0, data,
- NULL, NULL, &cstatus);
+ ret = ctdbd_control_local(conn, CTDB_CONTROL_ENABLE_SEQNUM, 0, 0, data,
+ NULL, NULL, &cstatus);
if ((ret != 0) || cstatus != 0) {
DEBUG(0, (__location__ " ctdb_control for enable seqnum "
"failed: %s\n", strerror(ret)));
@@ -1040,9 +1035,9 @@ int ctdbd_traverse(struct ctdbd_connection *conn, uint32_t db_id,
data.dptr = (uint8_t *)&t;
data.dsize = sizeof(t);
- ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_TRAVERSE_START, conn->rand_srvid,
- 0, data, NULL, NULL, &cstatus);
+ ret = ctdbd_control_local(conn, CTDB_CONTROL_TRAVERSE_START,
+ conn->rand_srvid,
+ 0, data, NULL, NULL, &cstatus);
if ((ret != 0) || (cstatus != 0)) {
DEBUG(0,("ctdbd_control failed: %s, %d\n", strerror(ret),
--
2.1.4
From c97b37a8cad3d35308386da7c39b6f8bfd1bf818 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 4 Apr 2016 16:23:09 +0200
Subject: [PATCH 11/11] ctdbd: Use talloc_memdup where appropriate
.... 40 bytes .text less ;-)
Signed-off-by: Volker Lendecke <vl at samba.org>
---
ctdb/server/ctdb_daemon.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index 9a33691..31c1609 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/server/ctdb_daemon.c
@@ -1708,9 +1708,9 @@ int32_t ctdb_control_register_notify(struct ctdb_context *ctdb, uint32_t client_
nl->ctdb = ctdb;
nl->srvid = notify->srvid;
nl->data.dsize = notify->len;
- nl->data.dptr = talloc_size(nl, nl->data.dsize);
+ nl->data.dptr = talloc_memdup(nl, notify->notify_data,
+ nl->data.dsize);
CTDB_NO_MEMORY(ctdb, nl->data.dptr);
- memcpy(nl->data.dptr, notify->notify_data, nl->data.dsize);
DLIST_ADD(client->notify, nl);
talloc_set_destructor(nl, ctdb_client_notify_destructor);
--
2.1.4
More information about the samba-technical
mailing list