[PATCHSET] remove deps from ctdbd_conn.c
Volker Lendecke
Volker.Lendecke at SerNet.DE
Wed Oct 7 12:36:06 UTC 2015
Hi!
Attached find a patchset that removes NT_STATUS from
ctdbd_conn.c. Why? We still don't have a real common
map_nt_error_from_unix & friends in source3, source4 and for
sure not ctdb. This is a small step to make ctdbd_conn.c
more generally useable.
One of the patches embedded is a bug fix for "ctdb timeout
!= 0"
Sorry for the dull read, but I did not find a saner way than
to move to 0/errno on a function by function level. I'm
happy to squash the whole thing into one.
Review&push 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 bc834bf74ce6b892a5c8c561df904fa5da362f10 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 19:51:01 -0700
Subject: [PATCH 01/31] lib: Fix error talloc leaks in ctdb_read_packet()
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index c743356..44f70f5 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -337,9 +337,11 @@ static int ctdb_read_packet(int fd, int timeout, TALLOC_CTX *mem_ctx,
nread = read_data(fd, ((char *)req) + sizeof(msglen),
msglen - sizeof(msglen));
if (nread == -1) {
+ TALLOC_FREE(req);
return errno;
}
if (nread == 0) {
+ TALLOC_FREE(req);
return EIO;
}
--
1.9.1
From dd9ae11e1047d9a9bc8f6a5dbb157bfd048724c5 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 19:54:31 -0700
Subject: [PATCH 02/31] lib: Add ctdbd_control_unix
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 42 ++++++++++++++++++++++++++++++------------
1 file changed, 30 insertions(+), 12 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 44f70f5..ee93799 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -68,6 +68,12 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
uint64_t srvid, uint32_t flags, TDB_DATA data,
TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
int *cstatus);
+static int ctdbd_control_unix(struct ctdbd_connection *conn,
+ uint32_t vnn, uint32_t opcode,
+ uint64_t srvid, uint32_t flags,
+ TDB_DATA data,
+ TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
+ int *cstatus);
/*
* exit on fatal communications errors with the ctdbd daemon
@@ -639,7 +645,7 @@ NTSTATUS ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
/*
* send/recv a generic ctdb control message
*/
-static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
+static int ctdbd_control_unix(struct ctdbd_connection *conn,
uint32_t vnn, uint32_t opcode,
uint64_t srvid, uint32_t flags,
TDB_DATA data,
@@ -651,7 +657,6 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
struct ctdb_reply_control *reply = NULL;
struct iovec iov[2];
ssize_t nwritten;
- NTSTATUS status;
int ret;
ZERO_STRUCT(req);
@@ -684,20 +689,19 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
if (cstatus) {
*cstatus = 0;
}
- return NT_STATUS_OK;
+ return 0;
}
ret = ctdb_read_req(conn, req.hdr.reqid, NULL, &hdr);
if (ret != 0) {
DEBUG(10, ("ctdb_read_req failed: %s\n", strerror(ret)));
- status = map_nt_error_from_unix(ret);
- goto fail;
+ return ret;
}
if (hdr->operation != CTDB_REPLY_CONTROL) {
DEBUG(0, ("received invalid reply\n"));
- status = NT_STATUS_INVALID_NETWORK_RESPONSE;
- goto fail;
+ TALLOC_FREE(hdr);
+ return EIO;
}
reply = (struct ctdb_reply_control *)hdr;
@@ -705,7 +709,7 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
if (!(outdata->dptr = (uint8_t *)talloc_memdup(
mem_ctx, reply->data, reply->datalen))) {
TALLOC_FREE(reply);
- return NT_STATUS_NO_MEMORY;
+ return ENOMEM;
}
outdata->dsize = reply->datalen;
}
@@ -713,11 +717,25 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
(*cstatus) = reply->status;
}
- status = NT_STATUS_OK;
-
- fail:
TALLOC_FREE(reply);
- return status;
+ return ret;
+}
+
+static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
+ uint32_t vnn, uint32_t opcode,
+ uint64_t srvid, uint32_t flags,
+ TDB_DATA data,
+ TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
+ int *cstatus)
+{
+ int ret;
+
+ ret = ctdbd_control_unix(conn, vnn, opcode, srvid, flags, data,
+ mem_ctx, outdata, cstatus);
+ if (ret != 0) {
+ return map_nt_error_from_unix(ret);
+ }
+ return NT_STATUS_OK;
}
/*
--
1.9.1
From 6b69d1f667a66fb87b08e39861ea909f50fb0cb0 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:00:32 -0700
Subject: [PATCH 03/31] lib: Use ctdbd_control_unix in register_with_ctdbd
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index ee93799..e307faf 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -113,16 +113,15 @@ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
void *private_data)
{
- NTSTATUS status;
- int cstatus;
+ int ret, cstatus;
size_t num_callbacks;
struct ctdbd_srvid_cb *tmp;
- status = ctdbd_control(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_REGISTER_SRVID, srvid, 0,
- tdb_null, NULL, NULL, &cstatus);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
+ ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE,
+ CTDB_CONTROL_REGISTER_SRVID, srvid, 0,
+ tdb_null, NULL, NULL, &cstatus);
+ if (ret != 0) {
+ return map_nt_error_from_unix(ret);
}
num_callbacks = talloc_array_length(conn->callbacks);
--
1.9.1
From deda2e20e355ce3c3a9541822f595ecd3b2c9bc4 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:00:32 -0700
Subject: [PATCH 04/31] lib: Use ctdbd_control_unix in get_cluster_vnn
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index e307faf..c684174 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -185,16 +185,16 @@ static int ctdbd_msg_call_back(struct ctdbd_connection *conn,
static NTSTATUS get_cluster_vnn(struct ctdbd_connection *conn, uint32_t *vnn)
{
int32_t cstatus=-1;
- NTSTATUS status;
- status = ctdbd_control(conn,
- CTDB_CURRENT_NODE, CTDB_CONTROL_GET_PNN, 0, 0,
- tdb_null, NULL, NULL, &cstatus);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(1, ("ctdbd_control failed: %s\n", nt_errstr(status)));
- return status;
+ int ret;
+ ret = ctdbd_control_unix(conn,
+ CTDB_CURRENT_NODE, CTDB_CONTROL_GET_PNN, 0, 0,
+ tdb_null, NULL, NULL, &cstatus);
+ if (ret != 0) {
+ DEBUG(1, ("ctdbd_control failed: %s\n", strerror(ret)));
+ return map_nt_error_from_unix(ret);
}
*vnn = (uint32_t)cstatus;
- return status;
+ return NT_STATUS_OK;
}
/*
--
1.9.1
From a41f1de7bf87b6d8402cb47cf9048215411b555e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:05:15 -0700
Subject: [PATCH 05/31] lib: Rename a variable
We'll have "int ret" in the next commit
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index c684174..30654cb 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -207,7 +207,7 @@ static bool ctdbd_working(struct ctdbd_connection *conn, uint32_t vnn)
TDB_DATA outdata;
struct ctdb_node_map *m;
uint32_t failure_flags;
- bool ret = false;
+ bool ok = false;
int i;
status = ctdbd_control(conn, CTDB_CURRENT_NODE,
@@ -245,10 +245,10 @@ static bool ctdbd_working(struct ctdbd_connection *conn, uint32_t vnn)
goto fail;
}
- ret = true;
+ ok = true;
fail:
TALLOC_FREE(outdata.dptr);
- return ret;
+ return ok;
}
uint32_t ctdbd_vnn(const struct ctdbd_connection *conn)
--
1.9.1
From 68aca57aa92f5d5d7cc09e95d2ffbba93a03a457 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:06:59 -0700
Subject: [PATCH 06/31] lib: Use ctdbd_control_unix in ctdbd_working
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 30654cb..eb585d1 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -203,18 +203,17 @@ static NTSTATUS get_cluster_vnn(struct ctdbd_connection *conn, uint32_t *vnn)
static bool ctdbd_working(struct ctdbd_connection *conn, uint32_t vnn)
{
int32_t cstatus=-1;
- NTSTATUS status;
TDB_DATA outdata;
struct ctdb_node_map *m;
uint32_t failure_flags;
bool ok = false;
- int i;
+ int i, ret;
- status = ctdbd_control(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_GET_NODEMAP, 0, 0,
- tdb_null, talloc_tos(), &outdata, &cstatus);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(1, ("ctdbd_control failed: %s\n", nt_errstr(status)));
+ ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE,
+ 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;
}
if ((cstatus != 0) || (outdata.dptr == NULL)) {
--
1.9.1
From f96f06c03706b72c12b1edc460da8bbd34c82afd Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:08:53 -0700
Subject: [PATCH 07/31] lib: Use ctdbd_control_unix in ctdbd_dbpath
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index eb585d1..ccdd76b 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -869,7 +869,7 @@ fail:
char *ctdbd_dbpath(struct ctdbd_connection *conn,
TALLOC_CTX *mem_ctx, uint32_t db_id)
{
- NTSTATUS status;
+ int ret;
TDB_DATA data;
TDB_DATA rdata = {0};
int32_t cstatus = 0;
@@ -877,11 +877,12 @@ char *ctdbd_dbpath(struct ctdbd_connection *conn,
data.dptr = (uint8_t*)&db_id;
data.dsize = sizeof(db_id);
- status = ctdbd_control(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_GETDBPATH, 0, 0, data,
- mem_ctx, &rdata, &cstatus);
- if (!NT_STATUS_IS_OK(status) || cstatus != 0) {
- DEBUG(0,(__location__ " ctdb_control for getdbpath failed\n"));
+ ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE,
+ 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)));
return NULL;
}
--
1.9.1
From e6f406356c08c6f2f461ae298b90cac67205c517 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:08:53 -0700
Subject: [PATCH 08/31] lib: Use ctdbd_control_unix in ctdbd_db_attach
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index ccdd76b..7bb1e35 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -895,22 +895,22 @@ char *ctdbd_dbpath(struct ctdbd_connection *conn,
NTSTATUS ctdbd_db_attach(struct ctdbd_connection *conn,
const char *name, uint32_t *db_id, int tdb_flags)
{
- NTSTATUS status;
+ int ret;
TDB_DATA data;
int32_t cstatus;
bool persistent = (tdb_flags & TDB_CLEAR_IF_FIRST) == 0;
data = string_term_tdb_data(name);
- status = ctdbd_control(conn, CTDB_CURRENT_NODE,
- persistent
- ? CTDB_CONTROL_DB_ATTACH_PERSISTENT
- : CTDB_CONTROL_DB_ATTACH,
- tdb_flags, 0, data, NULL, &data, &cstatus);
- if (!NT_STATUS_IS_OK(status)) {
+ ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE,
+ 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", nt_errstr(status)));
- return status;
+ "failed: %s\n", strerror(ret)));
+ return map_nt_error_from_unix(ret);
}
if (cstatus != 0 || data.dsize != sizeof(uint32_t)) {
@@ -928,14 +928,14 @@ NTSTATUS ctdbd_db_attach(struct ctdbd_connection *conn,
data.dptr = (uint8_t *)db_id;
data.dsize = sizeof(*db_id);
- status = ctdbd_control(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_ENABLE_SEQNUM, 0, 0, data,
- NULL, NULL, &cstatus);
- if (!NT_STATUS_IS_OK(status) || cstatus != 0) {
- DEBUG(0,(__location__ " ctdb_control for enable seqnum "
- "failed\n"));
- return NT_STATUS_IS_OK(status) ? NT_STATUS_INTERNAL_ERROR :
- status;
+ ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE,
+ 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)));
+ return (ret == 0) ? NT_STATUS_INTERNAL_ERROR :
+ map_nt_error_from_unix(ret);
}
return NT_STATUS_OK;
--
1.9.1
From 74f8c99a9a13fac88a99eb95dddf173ee91d1950 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:08:53 -0700
Subject: [PATCH 09/31] lib: Use ctdbd_control_unix in ctdbd_db_attach
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 7bb1e35..525aab7 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -1087,7 +1087,7 @@ NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
{
struct ctdbd_connection *conn;
NTSTATUS status;
-
+ int ret;
TDB_DATA key, data;
struct ctdb_traverse_start t;
int cstatus;
@@ -1109,13 +1109,14 @@ NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
data.dptr = (uint8_t *)&t;
data.dsize = sizeof(t);
- status = ctdbd_control(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_TRAVERSE_START, conn->rand_srvid, 0,
- data, NULL, NULL, &cstatus);
+ ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE,
+ CTDB_CONTROL_TRAVERSE_START, conn->rand_srvid,
+ 0, data, NULL, NULL, &cstatus);
- if (!NT_STATUS_IS_OK(status) || (cstatus != 0)) {
+ if ((ret != 0) || (cstatus != 0)) {
+ status = map_nt_error_from_unix(ret);
- DEBUG(0,("ctdbd_control failed: %s, %d\n", nt_errstr(status),
+ DEBUG(0,("ctdbd_control failed: %s, %d\n", strerror(ret),
cstatus));
if (NT_STATUS_IS_OK(status)) {
@@ -1132,7 +1133,6 @@ NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
struct ctdb_req_header *hdr = NULL;
struct ctdb_req_message *m;
struct ctdb_rec_data *d;
- int ret;
ret = ctdb_read_packet(conn->fd, conn->timeout, conn, &hdr);
if (ret != 0) {
--
1.9.1
From f7ece2ec6b9d52be91129f4c45eabe9c84033358 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:08:53 -0700
Subject: [PATCH 10/31] lib: Use ctdbd_control_unix in ctdbd_register_ips
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 525aab7..5840627 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -1227,6 +1227,7 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
struct ctdb_control_tcp_addr p;
TDB_DATA data = { .dptr = (uint8_t *)&p, .dsize = sizeof(p) };
NTSTATUS status;
+ int ret;
struct sockaddr_storage client;
struct sockaddr_storage server;
@@ -1265,9 +1266,14 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
* can send an extra ack to trigger a reset for our client, so it
* immediately reconnects
*/
- return ctdbd_control(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_TCP_CLIENT, 0,
- CTDB_CTRL_FLAG_NOREPLY, data, NULL, NULL, NULL);
+ ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE,
+ CTDB_CONTROL_TCP_CLIENT, 0,
+ CTDB_CTRL_FLAG_NOREPLY, data, NULL, NULL,
+ NULL);
+ if (ret != 0) {
+ return map_nt_error_from_unix(ret);
+ }
+ return NT_STATUS_OK;
}
/*
--
1.9.1
From 0d7ab9e244398fe418171ef624916b98554aeffa Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:29:56 -0700
Subject: [PATCH 11/31] lib: Remove ctdbd_control
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 31 ++++++++-----------------------
1 file changed, 8 insertions(+), 23 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 5840627..04fbe9c 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -63,11 +63,6 @@ static uint32_t ctdbd_next_reqid(struct ctdbd_connection *conn)
return conn->reqid;
}
-static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
- uint32_t vnn, uint32_t opcode,
- uint64_t srvid, uint32_t flags, TDB_DATA data,
- TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
- int *cstatus);
static int ctdbd_control_unix(struct ctdbd_connection *conn,
uint32_t vnn, uint32_t opcode,
uint64_t srvid, uint32_t flags,
@@ -719,23 +714,6 @@ static int ctdbd_control_unix(struct ctdbd_connection *conn,
return ret;
}
-static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
- uint32_t vnn, uint32_t opcode,
- uint64_t srvid, uint32_t flags,
- TDB_DATA data,
- TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
- int *cstatus)
-{
- int ret;
-
- ret = ctdbd_control_unix(conn, vnn, opcode, srvid, flags, data,
- mem_ctx, outdata, cstatus);
- if (ret != 0) {
- return map_nt_error_from_unix(ret);
- }
- return NT_STATUS_OK;
-}
-
/*
* see if a remote process exists
*/
@@ -1284,7 +1262,14 @@ NTSTATUS ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
int *cstatus)
{
- return ctdbd_control(conn, CTDB_CURRENT_NODE, opcode, srvid, flags, data, mem_ctx, outdata, cstatus);
+ int ret;
+
+ ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE, opcode, srvid, flags, data,
+ mem_ctx, outdata, cstatus);
+ if (ret != 0) {
+ return map_nt_error_from_unix(ret);
+ }
+ return NT_STATUS_OK;
}
NTSTATUS ctdb_watch_us(struct ctdbd_connection *conn)
--
1.9.1
From 17fc9eb2c872df9aca941c37b117b123c50d1fc5 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:31:52 -0700
Subject: [PATCH 12/31] lib: Rename ctdbd_control_unix to ctdbd_control
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 82 ++++++++++++++++++++++++------------------------
1 file changed, 41 insertions(+), 41 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 04fbe9c..bdb6746 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -63,12 +63,12 @@ static uint32_t ctdbd_next_reqid(struct ctdbd_connection *conn)
return conn->reqid;
}
-static int ctdbd_control_unix(struct ctdbd_connection *conn,
- uint32_t vnn, uint32_t opcode,
- uint64_t srvid, uint32_t flags,
- TDB_DATA data,
- TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
- int *cstatus);
+static int ctdbd_control(struct ctdbd_connection *conn,
+ uint32_t vnn, uint32_t opcode,
+ uint64_t srvid, uint32_t flags,
+ TDB_DATA data,
+ TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
+ int *cstatus);
/*
* exit on fatal communications errors with the ctdbd daemon
@@ -112,9 +112,9 @@ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
size_t num_callbacks;
struct ctdbd_srvid_cb *tmp;
- ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_REGISTER_SRVID, srvid, 0,
- tdb_null, NULL, NULL, &cstatus);
+ ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
+ CTDB_CONTROL_REGISTER_SRVID, srvid, 0,
+ tdb_null, NULL, NULL, &cstatus);
if (ret != 0) {
return map_nt_error_from_unix(ret);
}
@@ -181,9 +181,9 @@ static NTSTATUS get_cluster_vnn(struct ctdbd_connection *conn, uint32_t *vnn)
{
int32_t cstatus=-1;
int ret;
- ret = ctdbd_control_unix(conn,
- CTDB_CURRENT_NODE, CTDB_CONTROL_GET_PNN, 0, 0,
- tdb_null, NULL, NULL, &cstatus);
+ ret = ctdbd_control(conn,
+ CTDB_CURRENT_NODE, CTDB_CONTROL_GET_PNN, 0, 0,
+ tdb_null, NULL, NULL, &cstatus);
if (ret != 0) {
DEBUG(1, ("ctdbd_control failed: %s\n", strerror(ret)));
return map_nt_error_from_unix(ret);
@@ -204,9 +204,9 @@ static bool ctdbd_working(struct ctdbd_connection *conn, uint32_t vnn)
bool ok = false;
int i, ret;
- ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_GET_NODEMAP, 0, 0,
- tdb_null, talloc_tos(), &outdata, &cstatus);
+ ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
+ 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;
@@ -638,12 +638,12 @@ NTSTATUS ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
/*
* send/recv a generic ctdb control message
*/
-static int ctdbd_control_unix(struct ctdbd_connection *conn,
- uint32_t vnn, uint32_t opcode,
- uint64_t srvid, uint32_t flags,
- TDB_DATA data,
- TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
- int *cstatus)
+static int ctdbd_control(struct ctdbd_connection *conn,
+ uint32_t vnn, uint32_t opcode,
+ uint64_t srvid, uint32_t flags,
+ TDB_DATA data,
+ TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
+ int *cstatus)
{
struct ctdb_req_control req;
struct ctdb_req_header *hdr;
@@ -855,9 +855,9 @@ char *ctdbd_dbpath(struct ctdbd_connection *conn,
data.dptr = (uint8_t*)&db_id;
data.dsize = sizeof(db_id);
- ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_GETDBPATH, 0, 0, data,
- mem_ctx, &rdata, &cstatus);
+ ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
+ 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)));
@@ -880,11 +880,11 @@ NTSTATUS ctdbd_db_attach(struct ctdbd_connection *conn,
data = string_term_tdb_data(name);
- ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE,
- persistent
- ? CTDB_CONTROL_DB_ATTACH_PERSISTENT
- : CTDB_CONTROL_DB_ATTACH,
- tdb_flags, 0, data, NULL, &data, &cstatus);
+ ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
+ 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)));
@@ -906,9 +906,9 @@ NTSTATUS ctdbd_db_attach(struct ctdbd_connection *conn,
data.dptr = (uint8_t *)db_id;
data.dsize = sizeof(*db_id);
- ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_ENABLE_SEQNUM, 0, 0, data,
- NULL, NULL, &cstatus);
+ ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
+ 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)));
@@ -1087,9 +1087,9 @@ NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
data.dptr = (uint8_t *)&t;
data.dsize = sizeof(t);
- ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_TRAVERSE_START, conn->rand_srvid,
- 0, data, NULL, NULL, &cstatus);
+ ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
+ CTDB_CONTROL_TRAVERSE_START, conn->rand_srvid,
+ 0, data, NULL, NULL, &cstatus);
if ((ret != 0) || (cstatus != 0)) {
status = map_nt_error_from_unix(ret);
@@ -1244,10 +1244,10 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
* can send an extra ack to trigger a reset for our client, so it
* immediately reconnects
*/
- ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE,
- CTDB_CONTROL_TCP_CLIENT, 0,
- CTDB_CTRL_FLAG_NOREPLY, data, NULL, NULL,
- NULL);
+ ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
+ CTDB_CONTROL_TCP_CLIENT, 0,
+ CTDB_CTRL_FLAG_NOREPLY, data, NULL, NULL,
+ NULL);
if (ret != 0) {
return map_nt_error_from_unix(ret);
}
@@ -1264,8 +1264,8 @@ NTSTATUS ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
{
int ret;
- ret = ctdbd_control_unix(conn, CTDB_CURRENT_NODE, opcode, srvid, flags, data,
- mem_ctx, outdata, cstatus);
+ ret = ctdbd_control(conn, CTDB_CURRENT_NODE, opcode, srvid, flags, data,
+ mem_ctx, outdata, cstatus);
if (ret != 0) {
return map_nt_error_from_unix(ret);
}
--
1.9.1
From 5f1039d95888289f3a6547b578928c9018db31ae Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 13/31] lib: Make register_with_ctdbd return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 12 ++++++------
source3/lib/ctdb_dummy.c | 14 +++++++-------
source3/lib/ctdbd_conn.c | 40 +++++++++++++++++++++-------------------
source3/lib/messages_ctdbd.c | 11 +++++++++--
source3/smbd/notifyd/notifyd.c | 9 ++++-----
5 files changed, 47 insertions(+), 39 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 6c46cdb..1db0c0a 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -86,12 +86,12 @@ NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn);
struct ctdb_req_message;
-NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
- int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
- uint64_t dst_srvid,
- const uint8_t *msg, size_t msglen,
- void *private_data),
- void *private_data);
+int register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
+ int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
+ uint64_t dst_srvid,
+ const uint8_t *msg, size_t msglen,
+ void *private_data),
+ void *private_data);
NTSTATUS ctdbd_probe(const char *sockname, int timeout);
#endif /* _CTDBD_CONN_H */
diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c
index d8658cf..dea1db6 100644
--- a/source3/lib/ctdb_dummy.c
+++ b/source3/lib/ctdb_dummy.c
@@ -36,14 +36,14 @@ NTSTATUS ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
return NT_STATUS_NOT_IMPLEMENTED;
}
-NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
- int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
- uint64_t dst_srvid,
- const uint8_t *msg, size_t msglen,
- void *private_data),
- void *private_data)
+int register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
+ int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
+ uint64_t dst_srvid,
+ const uint8_t *msg, size_t msglen,
+ void *private_data),
+ void *private_data)
{
- return NT_STATUS_NOT_IMPLEMENTED;
+ return ENOSYS;
}
NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index bdb6746..347606c 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -100,12 +100,12 @@ static void ctdb_packet_dump(struct ctdb_req_header *hdr)
/*
* Register a srvid with ctdbd
*/
-NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
- int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
- uint64_t dst_srvid,
- const uint8_t *msg, size_t msglen,
- void *private_data),
- void *private_data)
+int register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
+ int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
+ uint64_t dst_srvid,
+ const uint8_t *msg, size_t msglen,
+ void *private_data),
+ void *private_data)
{
int ret, cstatus;
@@ -116,7 +116,7 @@ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
CTDB_CONTROL_REGISTER_SRVID, srvid, 0,
tdb_null, NULL, NULL, &cstatus);
if (ret != 0) {
- return map_nt_error_from_unix(ret);
+ return ret;
}
num_callbacks = talloc_array_length(conn->callbacks);
@@ -124,7 +124,7 @@ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
tmp = talloc_realloc(conn, conn->callbacks, struct ctdbd_srvid_cb,
num_callbacks + 1);
if (tmp == NULL) {
- return NT_STATUS_NO_MEMORY;
+ return ENOMEM;
}
conn->callbacks = tmp;
@@ -132,7 +132,7 @@ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
.srvid = srvid, .cb = cb, .private_data = private_data
};
- return NT_STATUS_OK;
+ return 0;
}
static int ctdbd_msg_call_back(struct ctdbd_connection *conn,
@@ -467,11 +467,12 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
generate_random_buffer((unsigned char *)&conn->rand_srvid,
sizeof(conn->rand_srvid));
- status = register_with_ctdbd(conn, conn->rand_srvid, NULL, NULL);
+ ret = register_with_ctdbd(conn, conn->rand_srvid, NULL, NULL);
- if (!NT_STATUS_IS_OK(status)) {
+ if (ret != 0) {
DEBUG(5, ("Could not register random srvid: %s\n",
- nt_errstr(status)));
+ strerror(ret)));
+ status = map_nt_error_from_unix(ret);
goto fail;
}
@@ -493,6 +494,7 @@ NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
{
struct ctdbd_connection *conn;
NTSTATUS status;
+ int ret;
status = ctdbd_init_connection(mem_ctx, sockname, timeout, &conn);
@@ -500,8 +502,9 @@ NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
return status;
}
- status = register_with_ctdbd(conn, MSG_SRVID_SAMBA, NULL, NULL);
- if (!NT_STATUS_IS_OK(status)) {
+ ret = register_with_ctdbd(conn, MSG_SRVID_SAMBA, NULL, NULL);
+ if (ret != 0) {
+ status = map_nt_error_from_unix(ret);
goto fail;
}
@@ -1204,7 +1207,6 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
{
struct ctdb_control_tcp_addr p;
TDB_DATA data = { .dptr = (uint8_t *)&p, .dsize = sizeof(p) };
- NTSTATUS status;
int ret;
struct sockaddr_storage client;
struct sockaddr_storage server;
@@ -1233,10 +1235,10 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
* We want to be told about IP releases
*/
- status = register_with_ctdbd(conn, CTDB_SRVID_RELEASE_IP,
- cb, private_data);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
+ ret = register_with_ctdbd(conn, CTDB_SRVID_RELEASE_IP,
+ cb, private_data);
+ if (ret != 0) {
+ return map_nt_error_from_unix(ret);
}
/*
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index 4d8b574..e6724a8 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -171,6 +171,7 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
struct messaging_backend *result;
struct messaging_ctdbd_context *ctx;
NTSTATUS status;
+ int ret;
if (!(result = talloc(mem_ctx, struct messaging_backend))) {
DEBUG(0, ("talloc failed\n"));
@@ -202,8 +203,14 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
return status;
}
- status = register_with_ctdbd(ctx->conn, getpid(),
- messaging_ctdb_recv, msg_ctx);
+ ret = register_with_ctdbd(ctx->conn, getpid(),
+ messaging_ctdb_recv, msg_ctx);
+ if (ret != 0) {
+ DEBUG(10, ("register_with_ctdbd failed: %s\n",
+ strerror(ret)));
+ TALLOC_FREE(result);
+ return map_nt_error_from_unix(ret);
+ }
global_ctdb_connection_pid = getpid();
global_ctdbd_connection = ctx->conn;
diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c
index 3a9bc75..5554273 100644
--- a/source3/smbd/notifyd/notifyd.c
+++ b/source3/smbd/notifyd/notifyd.c
@@ -181,7 +181,6 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct tevent_req *req, *subreq;
struct notifyd_state *state;
struct server_id_db *names_db;
- NTSTATUS status;
int ret;
req = tevent_req_create(mem_ctx, &state, struct notifyd_state);
@@ -275,10 +274,10 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
tevent_req_set_callback(subreq, notifyd_clean_peers_finished,
req);
- status = register_with_ctdbd(ctdbd_conn, CTDB_SRVID_SAMBA_NOTIFY_PROXY,
- notifyd_snoop_broadcast, state);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_error(req, map_errno_from_nt_status(status));
+ ret = register_with_ctdbd(ctdbd_conn, CTDB_SRVID_SAMBA_NOTIFY_PROXY,
+ notifyd_snoop_broadcast, state);
+ if (ret != 0) {
+ tevent_req_error(req, ret);
return tevent_req_post(req, ev);
}
--
1.9.1
From 3a923d2e70f9b3fb5ad03c73e63a56652c222378 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 14/31] lib: Make get_cluster_vnn return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 347606c..30c0936 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -177,7 +177,7 @@ static int ctdbd_msg_call_back(struct ctdbd_connection *conn,
/*
* get our vnn from the cluster
*/
-static NTSTATUS get_cluster_vnn(struct ctdbd_connection *conn, uint32_t *vnn)
+static int get_cluster_vnn(struct ctdbd_connection *conn, uint32_t *vnn)
{
int32_t cstatus=-1;
int ret;
@@ -186,10 +186,10 @@ static NTSTATUS get_cluster_vnn(struct ctdbd_connection *conn, uint32_t *vnn)
tdb_null, NULL, NULL, &cstatus);
if (ret != 0) {
DEBUG(1, ("ctdbd_control failed: %s\n", strerror(ret)));
- return map_nt_error_from_unix(ret);
+ return ret;
}
*vnn = (uint32_t)cstatus;
- return NT_STATUS_OK;
+ return ret;
}
/*
@@ -451,10 +451,11 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
}
talloc_set_destructor(conn, ctdbd_connection_destructor);
- status = get_cluster_vnn(conn, &conn->our_vnn);
+ ret = get_cluster_vnn(conn, &conn->our_vnn);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(10, ("get_cluster_vnn failed: %s\n", nt_errstr(status)));
+ if (ret != 0) {
+ DEBUG(10, ("get_cluster_vnn failed: %s\n", strerror(ret)));
+ status = map_nt_error_from_unix(ret);
goto fail;
}
--
1.9.1
From 22fd43b049d58093228dfcd223f12eea542c8c6b Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 15/31] lib: Make ctdbd_register_msg_ctx return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 4 ++--
source3/lib/ctdbd_conn.c | 8 ++++----
source3/lib/messages_ctdbd.c | 8 ++++----
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 1db0c0a..40c2d89 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -32,8 +32,8 @@ NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
uint32_t ctdbd_vnn(const struct ctdbd_connection *conn);
-NTSTATUS ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
- struct messaging_context *msg_ctx);
+int ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
+ struct messaging_context *msg_ctx);
struct messaging_context *ctdb_conn_msg_ctx(struct ctdbd_connection *conn);
int ctdbd_conn_get_fd(struct ctdbd_connection *conn);
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 30c0936..deb3e4e 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -582,8 +582,8 @@ static void ctdbd_socket_handler(struct tevent_context *event_ctx,
* Prepare a ctdbd connection to receive messages
*/
-NTSTATUS ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
- struct messaging_context *msg_ctx)
+int ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
+ struct messaging_context *msg_ctx)
{
SMB_ASSERT(conn->msg_ctx == NULL);
SMB_ASSERT(conn->fde == NULL);
@@ -595,12 +595,12 @@ NTSTATUS ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
ctdbd_socket_handler,
conn))) {
DEBUG(0, ("event_add_fd failed\n"));
- return NT_STATUS_NO_MEMORY;
+ return ENOMEM;
}
conn->msg_ctx = msg_ctx;
- return NT_STATUS_OK;
+ return 0;
}
NTSTATUS ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index e6724a8..599a9bd 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -194,13 +194,13 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
return status;
}
- status = ctdbd_register_msg_ctx(ctx->conn, msg_ctx);
+ ret = ctdbd_register_msg_ctx(ctx->conn, msg_ctx);
- if (!NT_STATUS_IS_OK(status)) {
+ if (ret != 0) {
DEBUG(10, ("ctdbd_register_msg_ctx failed: %s\n",
- nt_errstr(status)));
+ strerror(ret)));
TALLOC_FREE(result);
- return status;
+ return map_nt_error_from_unix(ret);
}
ret = register_with_ctdbd(ctx->conn, getpid(),
--
1.9.1
From 731ca17dc8f93f2984ccf5e8a63755ba5adf8ae0 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 16/31] lib: Make ctdbd_init_connection return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index deb3e4e..efedfd4 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -417,23 +417,22 @@ static int ctdbd_connection_destructor(struct ctdbd_connection *c)
* Get us a ctdbd connection
*/
-static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
- const char *sockname, int timeout,
- struct ctdbd_connection **pconn)
+static int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
+ const char *sockname, int timeout,
+ struct ctdbd_connection **pconn)
{
struct ctdbd_connection *conn;
int ret;
- NTSTATUS status;
if (!(conn = talloc_zero(mem_ctx, struct ctdbd_connection))) {
DEBUG(0, ("talloc failed\n"));
- return NT_STATUS_NO_MEMORY;
+ return ENOMEM;
}
conn->sockname = talloc_strdup(conn, sockname);
if (conn->sockname == NULL) {
DBG_ERR("%s: talloc failed\n", __func__);
- status = NT_STATUS_NO_MEMORY;
+ ret = ENOMEM;
goto fail;
}
@@ -445,7 +444,6 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
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)));
goto fail;
}
@@ -455,13 +453,12 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
if (ret != 0) {
DEBUG(10, ("get_cluster_vnn failed: %s\n", strerror(ret)));
- status = map_nt_error_from_unix(ret);
goto fail;
}
if (!ctdbd_working(conn, conn->our_vnn)) {
DEBUG(2, ("Node is not working, can not connect\n"));
- status = NT_STATUS_INTERNAL_DB_ERROR;
+ ret = EIO;
goto fail;
}
@@ -473,16 +470,15 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
if (ret != 0) {
DEBUG(5, ("Could not register random srvid: %s\n",
strerror(ret)));
- status = map_nt_error_from_unix(ret);
goto fail;
}
*pconn = conn;
- return NT_STATUS_OK;
+ return 0;
fail:
TALLOC_FREE(conn);
- return status;
+ return ret;
}
/*
@@ -497,10 +493,10 @@ NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
NTSTATUS status;
int ret;
- status = ctdbd_init_connection(mem_ctx, sockname, timeout, &conn);
+ ret = ctdbd_init_connection(mem_ctx, sockname, timeout, &conn);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
+ if (ret != 0) {
+ return map_nt_error_from_unix(ret);
}
ret = register_with_ctdbd(conn, MSG_SRVID_SAMBA, NULL, NULL);
@@ -1075,13 +1071,13 @@ NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
int cstatus;
become_root();
- status = ctdbd_init_connection(NULL, master->sockname, master->timeout,
- &conn);
+ ret = ctdbd_init_connection(NULL, master->sockname, master->timeout,
+ &conn);
unbecome_root();
- if (!NT_STATUS_IS_OK(status)) {
+ if (ret != 0) {
DEBUG(0, ("ctdbd_init_connection failed: %s\n",
- nt_errstr(status)));
- return status;
+ strerror(ret)));
+ return map_nt_error_from_unix(ret);
}
t.db_id = db_id;
--
1.9.1
From e1d1f7450d97ca18fc5d98fc9734a53d39b533d0 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 17/31] lib: Make ctdbd_messaging_connection return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 6 +++---
source3/lib/ctdbd_conn.c | 22 ++++++++++------------
source3/lib/messages_ctdbd.c | 11 +++++------
3 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 40c2d89..9d71927 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -26,9 +26,9 @@ struct ctdbd_connection;
struct messaging_context;
struct messaging_rec;
-NTSTATUS ctdbd_messaging_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);
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index efedfd4..5b19299 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -485,32 +485,30 @@ static int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
* Get us a ctdbd connection and register us as a process
*/
-NTSTATUS ctdbd_messaging_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)
{
struct ctdbd_connection *conn;
- NTSTATUS status;
int ret;
ret = ctdbd_init_connection(mem_ctx, sockname, timeout, &conn);
if (ret != 0) {
- return map_nt_error_from_unix(ret);
+ return ret;
}
ret = register_with_ctdbd(conn, MSG_SRVID_SAMBA, NULL, NULL);
if (ret != 0) {
- status = map_nt_error_from_unix(ret);
goto fail;
}
*pconn = conn;
- return NT_STATUS_OK;
+ return 0;
fail:
TALLOC_FREE(conn);
- return status;
+ return ret;
}
struct messaging_context *ctdb_conn_msg_ctx(struct ctdbd_connection *conn)
@@ -1322,15 +1320,15 @@ NTSTATUS ctdbd_probe(const char *sockname, int timeout)
* later
*/
struct ctdbd_connection *conn = NULL;
- NTSTATUS status;
+ int ret;
- status = ctdbd_messaging_connection(talloc_tos(), sockname, timeout,
- &conn);
+ ret = ctdbd_messaging_connection(talloc_tos(), sockname, timeout,
+ &conn);
/*
* We only care if we can connect.
*/
TALLOC_FREE(conn);
- return status;
+ return map_nt_error_from_unix(ret);
}
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index 599a9bd..a9ec04f 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -170,7 +170,6 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
{
struct messaging_backend *result;
struct messaging_ctdbd_context *ctx;
- NTSTATUS status;
int ret;
if (!(result = talloc(mem_ctx, struct messaging_backend))) {
@@ -184,14 +183,14 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
return NT_STATUS_NO_MEMORY;
}
- status = ctdbd_messaging_connection(ctx, lp_ctdbd_socket(),
- lp_ctdb_timeout(), &ctx->conn);
+ ret = ctdbd_messaging_connection(ctx, lp_ctdbd_socket(),
+ lp_ctdb_timeout(), &ctx->conn);
- if (!NT_STATUS_IS_OK(status)) {
+ if (ret != 0) {
DEBUG(10, ("ctdbd_messaging_connection failed: %s\n",
- nt_errstr(status)));
+ strerror(ret)));
TALLOC_FREE(result);
- return status;
+ return map_nt_error_from_unix(ret);
}
ret = ctdbd_register_msg_ctx(ctx->conn, msg_ctx);
--
1.9.1
From c0cd38790b48466de9673a619933d2e9eb3ed2cf Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 18/31] lib: Make ctdbd_messaging_send_iov return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 6 +++---
source3/lib/ctdb_dummy.c | 8 ++++----
source3/lib/ctdbd_conn.c | 8 ++++----
source3/lib/messages_ctdbd.c | 9 ++-------
source3/smbd/notifyd/notifyd.c | 8 ++++----
5 files changed, 17 insertions(+), 22 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 9d71927..7a3b07b 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -38,9 +38,9 @@ struct messaging_context *ctdb_conn_msg_ctx(struct ctdbd_connection *conn);
int ctdbd_conn_get_fd(struct ctdbd_connection *conn);
-NTSTATUS ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
- uint32_t dst_vnn, uint64_t dst_srvid,
- const struct iovec *iov, int iovlen);
+int ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
+ uint32_t dst_vnn, uint64_t dst_srvid,
+ const struct iovec *iov, int iovlen);
bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn,
pid_t pid);
diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c
index dea1db6..838b24d 100644
--- a/source3/lib/ctdb_dummy.c
+++ b/source3/lib/ctdb_dummy.c
@@ -29,11 +29,11 @@ NTSTATUS ctdbd_probe(const char *sockname, int timeout)
return NT_STATUS_NOT_IMPLEMENTED;
}
-NTSTATUS ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
- uint32_t dst_vnn, uint64_t dst_srvid,
- const struct iovec *iov, int iovlen)
+int ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
+ uint32_t dst_vnn, uint64_t dst_srvid,
+ const struct iovec *iov, int iovlen)
{
- return NT_STATUS_NOT_IMPLEMENTED;
+ return ENOSYS;
}
int register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 5b19299..e41b0d4 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -597,9 +597,9 @@ int ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
return 0;
}
-NTSTATUS ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
- uint32_t dst_vnn, uint64_t dst_srvid,
- const struct iovec *iov, int iovlen)
+int ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
+ uint32_t dst_vnn, uint64_t dst_srvid,
+ const struct iovec *iov, int iovlen)
{
struct ctdb_req_message r;
struct iovec iov2[iovlen+1];
@@ -630,7 +630,7 @@ NTSTATUS ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
cluster_fatal("cluster dispatch daemon msg write error\n");
}
- return NT_STATUS_OK;
+ return 0;
}
/*
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index a9ec04f..a0c8d90 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -82,7 +82,6 @@ static int messaging_ctdb_send(struct server_id src,
backend->private_data, struct messaging_ctdbd_context);
uint8_t hdr[MESSAGE_HDR_LENGTH];
struct iovec iov2[iovlen+1];
- NTSTATUS status;
if (num_fds > 0) {
return ENOSYS;
@@ -92,12 +91,8 @@ static int messaging_ctdb_send(struct server_id src,
iov2[0] = (struct iovec){ .iov_base = hdr, .iov_len = sizeof(hdr) };
memcpy(&iov2[1], iov, iovlen * sizeof(*iov));
- status = ctdbd_messaging_send_iov(ctx->conn, pid.vnn, pid.pid,
- iov2, iovlen+1);
- if (NT_STATUS_IS_OK(status)) {
- return 0;
- }
- return map_errno_from_nt_status(status);
+ return ctdbd_messaging_send_iov(ctx->conn, pid.vnn, pid.pid,
+ iov2, iovlen+1);
}
static int messaging_ctdbd_destructor(struct messaging_ctdbd_context *ctx)
diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c
index 5554273..06f48cf 100644
--- a/source3/smbd/notifyd/notifyd.c
+++ b/source3/smbd/notifyd/notifyd.c
@@ -942,11 +942,11 @@ static void notifyd_broadcast_reclog(struct ctdbd_connection *ctdbd_conn,
struct server_id src,
struct messaging_reclog *log)
{
- NTSTATUS status;
enum ndr_err_code ndr_err;
uint8_t msghdr[MESSAGE_HDR_LENGTH];
DATA_BLOB blob;
struct iovec iov[2];
+ int ret;
if (log == NULL) {
return;
@@ -971,13 +971,13 @@ static void notifyd_broadcast_reclog(struct ctdbd_connection *ctdbd_conn,
iov[1] = (struct iovec) { .iov_base = blob.data,
.iov_len = blob.length };
- status = ctdbd_messaging_send_iov(
+ ret = ctdbd_messaging_send_iov(
ctdbd_conn, CTDB_BROADCAST_VNNMAP,
CTDB_SRVID_SAMBA_NOTIFY_PROXY, iov, ARRAY_SIZE(iov));
TALLOC_FREE(blob.data);
- if (!NT_STATUS_IS_OK(status)) {
+ if (ret != 0) {
DEBUG(1, ("%s: ctdbd_messaging_send failed: %s\n",
- __func__, nt_errstr(status)));
+ __func__, strerror(ret)));
goto done;
}
--
1.9.1
From 590394aabbf1a74ba999f52b9871d70e27cda964 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 19/31] lib: Make ctdbd_db_attach return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 4 ++--
source3/lib/ctdbd_conn.c | 15 +++++++--------
source3/lib/dbwrap/dbwrap_ctdb.c | 7 +++++--
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 7a3b07b..7e56a4c6 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -51,8 +51,8 @@ bool ctdb_processes_exist(struct ctdbd_connection *conn,
char *ctdbd_dbpath(struct ctdbd_connection *conn,
TALLOC_CTX *mem_ctx, uint32_t db_id);
-NTSTATUS ctdbd_db_attach(struct ctdbd_connection *conn, const char *name,
- uint32_t *db_id, int tdb_flags);
+int ctdbd_db_attach(struct ctdbd_connection *conn, const char *name,
+ uint32_t *db_id, int tdb_flags);
NTSTATUS ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id,
TDB_DATA key);
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index e41b0d4..d759be6 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -868,8 +868,8 @@ char *ctdbd_dbpath(struct ctdbd_connection *conn,
/*
* attach to a ctdb database
*/
-NTSTATUS ctdbd_db_attach(struct ctdbd_connection *conn,
- const char *name, uint32_t *db_id, int tdb_flags)
+int ctdbd_db_attach(struct ctdbd_connection *conn,
+ const char *name, uint32_t *db_id, int tdb_flags)
{
int ret;
TDB_DATA data;
@@ -886,19 +886,19 @@ NTSTATUS ctdbd_db_attach(struct ctdbd_connection *conn,
if (ret != 0) {
DEBUG(0, (__location__ " ctdb_control for db_attach "
"failed: %s\n", strerror(ret)));
- return map_nt_error_from_unix(ret);
+ return ret;
}
if (cstatus != 0 || data.dsize != sizeof(uint32_t)) {
DEBUG(0,(__location__ " ctdb_control for db_attach failed\n"));
- return NT_STATUS_INTERNAL_ERROR;
+ return EIO;
}
*db_id = *(uint32_t *)data.dptr;
talloc_free(data.dptr);
if (!(tdb_flags & TDB_SEQNUM)) {
- return NT_STATUS_OK;
+ return 0;
}
data.dptr = (uint8_t *)db_id;
@@ -910,11 +910,10 @@ NTSTATUS ctdbd_db_attach(struct ctdbd_connection *conn,
if ((ret != 0) || cstatus != 0) {
DEBUG(0, (__location__ " ctdb_control for enable seqnum "
"failed: %s\n", strerror(ret)));
- return (ret == 0) ? NT_STATUS_INTERNAL_ERROR :
- map_nt_error_from_unix(ret);
+ return (ret == 0) ? EIO : ret;
}
- return NT_STATUS_OK;
+ return 0;
}
/*
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 9402bdd..c495c5c 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -1547,6 +1547,7 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
struct ctdb_db_priority prio;
NTSTATUS status;
int cstatus;
+ int ret;
if (!lp_clustering()) {
DEBUG(10, ("Clustering disabled -- no ctdb\n"));
@@ -1582,8 +1583,10 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
return NULL;
}
- if (!NT_STATUS_IS_OK(ctdbd_db_attach(conn, name, &db_ctdb->db_id, tdb_flags))) {
- DEBUG(0, ("ctdbd_db_attach failed for %s\n", name));
+ ret = ctdbd_db_attach(conn, name, &db_ctdb->db_id, tdb_flags);
+ if (ret != 0) {
+ DEBUG(0, ("ctdbd_db_attach failed for %s: %s\n", name,
+ strerror(ret)));
TALLOC_FREE(result);
return NULL;
}
--
1.9.1
From 15c27ea571e17592dabec7820ce792884e7b9450 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 20/31] lib: Make ctdbd_migrate return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 3 +--
source3/lib/ctdbd_conn.c | 9 ++-------
source3/lib/dbwrap/dbwrap_ctdb.c | 9 +++++----
3 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 7e56a4c6..6ebd451 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -54,8 +54,7 @@ char *ctdbd_dbpath(struct ctdbd_connection *conn,
int ctdbd_db_attach(struct ctdbd_connection *conn, const char *name,
uint32_t *db_id, int tdb_flags);
-NTSTATUS ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id,
- TDB_DATA key);
+int ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id, TDB_DATA key);
NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
TDB_DATA key, bool local_copy,
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index d759be6..899d616 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -919,14 +919,12 @@ int ctdbd_db_attach(struct ctdbd_connection *conn,
/*
* force the migration of a record to this node
*/
-NTSTATUS ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id,
- TDB_DATA key)
+int ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id, TDB_DATA key)
{
struct ctdb_req_call req;
struct ctdb_req_header *hdr;
struct iovec iov[2];
ssize_t nwritten;
- NTSTATUS status;
int ret;
ZERO_STRUCT(req);
@@ -958,21 +956,18 @@ NTSTATUS ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id,
ret = ctdb_read_req(conn, req.hdr.reqid, NULL, &hdr);
if (ret != 0) {
DEBUG(10, ("ctdb_read_req failed: %s\n", strerror(ret)));
- status = map_nt_error_from_unix(ret);
goto fail;
}
if (hdr->operation != CTDB_REPLY_CALL) {
DEBUG(0, ("received invalid reply\n"));
- status = NT_STATUS_INTERNAL_ERROR;
goto fail;
}
- status = NT_STATUS_OK;
fail:
TALLOC_FREE(hdr);
- return status;
+ return ret;
}
/*
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index c495c5c..57afc85 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -1019,6 +1019,7 @@ static struct db_record *fetch_locked_internal(struct db_ctdb_ctx *ctx,
double ctdb_time = 0;
int duration_msecs;
int lockret;
+ int ret;
if (!(result = talloc(mem_ctx, struct db_record))) {
DEBUG(0, ("talloc failed\n"));
@@ -1105,13 +1106,13 @@ again:
((struct ctdb_ltdb_header *)ctdb_data.dptr)->flags : 0));
GetTimeOfDay(&ctdb_start_time);
- status = ctdbd_migrate(messaging_ctdbd_connection(), ctx->db_id,
- key);
+ ret = ctdbd_migrate(messaging_ctdbd_connection(), ctx->db_id,
+ key);
ctdb_time += timeval_elapsed(&ctdb_start_time);
- if (!NT_STATUS_IS_OK(status)) {
+ if (ret != 0) {
DEBUG(5, ("ctdb_migrate failed: %s\n",
- nt_errstr(status)));
+ strerror(ret)));
TALLOC_FREE(result);
return NULL;
}
--
1.9.1
From 38749334d10cb529d0f4224a757b1305f42959f7 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 21/31] lib: Make ctdbd_parse return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 10 +++++-----
source3/lib/ctdbd_conn.c | 19 +++++++++----------
source3/lib/dbwrap/dbwrap_ctdb.c | 10 +++++++---
3 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 6ebd451..c2a6939 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -56,11 +56,11 @@ int ctdbd_db_attach(struct ctdbd_connection *conn, const char *name,
int ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id, TDB_DATA key);
-NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
- TDB_DATA key, bool local_copy,
- void (*parser)(TDB_DATA key, TDB_DATA data,
- void *private_data),
- void *private_data);
+int ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
+ TDB_DATA key, bool local_copy,
+ void (*parser)(TDB_DATA key, TDB_DATA data,
+ void *private_data),
+ void *private_data);
NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
void (*fn)(TDB_DATA key, TDB_DATA data,
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 899d616..ac2c56d 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -973,18 +973,17 @@ int ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id, TDB_DATA key)
/*
* Fetch a record and parse it
*/
-NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
- TDB_DATA key, bool local_copy,
- void (*parser)(TDB_DATA key, TDB_DATA data,
- void *private_data),
- void *private_data)
+int ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
+ TDB_DATA key, bool local_copy,
+ void (*parser)(TDB_DATA key, TDB_DATA data,
+ void *private_data),
+ void *private_data)
{
struct ctdb_req_call req;
struct ctdb_req_header *hdr = NULL;
struct ctdb_reply_call *reply;
struct iovec iov[2];
ssize_t nwritten;
- NTSTATUS status;
uint32_t flags;
int ret;
@@ -1022,7 +1021,7 @@ NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
if ((hdr == NULL) || (hdr->operation != CTDB_REPLY_CALL)) {
DEBUG(0, ("received invalid reply\n"));
- status = NT_STATUS_INTERNAL_ERROR;
+ ret = EIO;
goto fail;
}
reply = (struct ctdb_reply_call *)hdr;
@@ -1031,17 +1030,17 @@ NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
/*
* Treat an empty record as non-existing
*/
- status = NT_STATUS_NOT_FOUND;
+ ret = ENOENT;
goto fail;
}
parser(key, make_tdb_data(&reply->data[0], reply->datalen),
private_data);
- status = NT_STATUS_OK;
+ ret = 0;
fail:
TALLOC_FREE(hdr);
- return status;
+ return ret;
}
/*
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 57afc85..c90e59b 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -1009,7 +1009,6 @@ static struct db_record *fetch_locked_internal(struct db_ctdb_ctx *ctx,
{
struct db_record *result;
struct db_ctdb_rec *crec;
- NTSTATUS status;
TDB_DATA ctdb_data;
int migrate_attempts;
struct timeval migrate_start;
@@ -1256,6 +1255,7 @@ static NTSTATUS db_ctdb_parse_record(struct db_context *db, TDB_DATA key,
db->private_data, struct db_ctdb_ctx);
struct db_ctdb_parse_record_state state;
NTSTATUS status;
+ int ret;
state.parser = parser;
state.private_data = private_data;
@@ -1293,8 +1293,12 @@ static NTSTATUS db_ctdb_parse_record(struct db_context *db, TDB_DATA key,
return NT_STATUS_OK;
}
- return ctdbd_parse(messaging_ctdbd_connection(), ctx->db_id, key,
- state.ask_for_readonly_copy, parser, private_data);
+ ret = ctdbd_parse(messaging_ctdbd_connection(), ctx->db_id, key,
+ state.ask_for_readonly_copy, parser, private_data);
+ if (ret != 0) {
+ return map_nt_error_from_unix(ret);
+ }
+ return NT_STATUS_OK;
}
struct traverse_state {
--
1.9.1
From 0ded2ce1bf17d4282623d09731cdf34739b34bf2 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 22/31] lib: Make ctdbd_traverse return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 8 ++++----
source3/lib/ctdbd_conn.c | 24 ++++++++++--------------
source3/lib/dbwrap/dbwrap_ctdb.c | 20 ++++++++++----------
3 files changed, 24 insertions(+), 28 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index c2a6939..de3ab46 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -62,10 +62,10 @@ int ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
void *private_data),
void *private_data);
-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);
+int ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
+ void (*fn)(TDB_DATA key, TDB_DATA data,
+ void *private_data),
+ void *private_data);
NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
const struct sockaddr_storage *server,
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index ac2c56d..fb812a3 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -1015,7 +1015,6 @@ int ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
ret = ctdb_read_req(conn, req.hdr.reqid, NULL, &hdr);
if (ret != 0) {
DEBUG(10, ("ctdb_read_req failed: %s\n", strerror(ret)));
- status = map_nt_error_from_unix(ret);
goto fail;
}
@@ -1049,13 +1048,12 @@ int ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
everything in-line.
*/
-NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
+int ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
void (*fn)(TDB_DATA key, TDB_DATA data,
void *private_data),
void *private_data)
{
struct ctdbd_connection *conn;
- NTSTATUS status;
int ret;
TDB_DATA key, data;
struct ctdb_traverse_start t;
@@ -1068,7 +1066,7 @@ NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
if (ret != 0) {
DEBUG(0, ("ctdbd_init_connection failed: %s\n",
strerror(ret)));
- return map_nt_error_from_unix(ret);
+ return ret;
}
t.db_id = db_id;
@@ -1083,19 +1081,17 @@ NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
0, data, NULL, NULL, &cstatus);
if ((ret != 0) || (cstatus != 0)) {
- status = map_nt_error_from_unix(ret);
-
DEBUG(0,("ctdbd_control failed: %s, %d\n", strerror(ret),
cstatus));
- if (NT_STATUS_IS_OK(status)) {
+ if (ret == 0) {
/*
* We need a mapping here
*/
- status = NT_STATUS_UNSUCCESSFUL;
+ ret = EIO;
}
TALLOC_FREE(conn);
- return status;
+ return ret;
}
while (True) {
@@ -1114,7 +1110,7 @@ NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
DEBUG(0, ("Got operation %u, expected a message\n",
(unsigned)hdr->operation));
TALLOC_FREE(conn);
- return NT_STATUS_UNEXPECTED_IO_ERROR;
+ return EIO;
}
m = (struct ctdb_req_message *)hdr;
@@ -1123,7 +1119,7 @@ NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
DEBUG(0, ("Got invalid traverse data of length %d\n",
(int)m->datalen));
TALLOC_FREE(conn);
- return NT_STATUS_UNEXPECTED_IO_ERROR;
+ return EIO;
}
key.dsize = d->keylen;
@@ -1134,14 +1130,14 @@ NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
if (key.dsize == 0 && data.dsize == 0) {
/* end of traverse */
TALLOC_FREE(conn);
- return NT_STATUS_OK;
+ 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 NT_STATUS_UNEXPECTED_IO_ERROR;
+ return EIO;
}
data.dsize -= sizeof(struct ctdb_ltdb_header);
data.dptr += sizeof(struct ctdb_ltdb_header);
@@ -1150,7 +1146,7 @@ NTSTATUS ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
fn(key, data, private_data);
}
}
- return NT_STATUS_OK;
+ return 0;
}
/*
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index c90e59b..914ca4f 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -1362,7 +1362,7 @@ static int db_ctdb_traverse(struct db_context *db,
void *private_data),
void *private_data)
{
- NTSTATUS status;
+ int ret;
struct db_ctdb_ctx *ctx = talloc_get_type_abort(db->private_data,
struct db_ctdb_ctx);
struct traverse_state state;
@@ -1374,7 +1374,6 @@ static int db_ctdb_traverse(struct db_context *db,
if (db->persistent) {
struct tdb_context *ltdb = ctx->wtdb->tdb;
- int ret;
/* for persistent databases we don't need to do a ctdb traverse,
we can do a faster local traverse */
@@ -1392,6 +1391,7 @@ static int db_ctdb_traverse(struct db_context *db,
struct ctdb_rec_data *rec=NULL;
int i;
int count = 0;
+ NTSTATUS status;
if (newkeys == NULL) {
return -1;
@@ -1420,9 +1420,9 @@ static int db_ctdb_traverse(struct db_context *db,
return ret;
}
- status = ctdbd_traverse(messaging_ctdbd_connection(), ctx->db_id,
- traverse_callback, &state);
- if (!NT_STATUS_IS_OK(status)) {
+ ret = ctdbd_traverse(messaging_ctdbd_connection(), ctx->db_id,
+ traverse_callback, &state);
+ if (ret != 0) {
return -1;
}
return state.count;
@@ -1494,7 +1494,7 @@ static int db_ctdb_traverse_read(struct db_context *db,
void *private_data),
void *private_data)
{
- NTSTATUS status;
+ int ret;
struct db_ctdb_ctx *ctx = talloc_get_type_abort(db->private_data,
struct db_ctdb_ctx);
struct traverse_state state;
@@ -1510,9 +1510,9 @@ 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(messaging_ctdbd_connection(), ctx->db_id,
- traverse_read_callback, &state);
- if (!NT_STATUS_IS_OK(status)) {
+ ret = ctdbd_traverse(messaging_ctdbd_connection(), ctx->db_id,
+ traverse_read_callback, &state);
+ if (ret != 0) {
return -1;
}
return state.count;
@@ -1658,7 +1658,7 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
/* honor permissions if user has specified O_CREAT */
if (open_flags & O_CREAT) {
- int fd, ret;
+ int fd;
fd = tdb_fd(db_ctdb->wtdb->tdb);
ret = fchmod(fd, mode);
if (ret == -1) {
--
1.9.1
From 7fcc6ad2ff52a57f1ae3885700b7e36ca84c0725 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 23/31] lib: Make ctdbd_register_ips return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 16 ++++++++--------
source3/lib/ctdb_dummy.c | 18 +++++++++---------
source3/lib/ctdbd_conn.c | 24 ++++++++++++------------
source3/smbd/process.c | 7 ++++++-
4 files changed, 35 insertions(+), 30 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index de3ab46..ff1bc95 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -67,14 +67,14 @@ int ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
void *private_data),
void *private_data);
-NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
- const struct sockaddr_storage *server,
- const struct sockaddr_storage *client,
- int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
- uint64_t dst_srvid,
- const uint8_t *msg, size_t msglen,
- void *private_data),
- void *private_data);
+int ctdbd_register_ips(struct ctdbd_connection *conn,
+ const struct sockaddr_storage *server,
+ const struct sockaddr_storage *client,
+ int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
+ uint64_t dst_srvid,
+ const uint8_t *msg, size_t msglen,
+ void *private_data),
+ void *private_data);
NTSTATUS ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
uint64_t srvid, uint32_t flags, TDB_DATA data,
diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c
index 838b24d..7afb6b3 100644
--- a/source3/lib/ctdb_dummy.c
+++ b/source3/lib/ctdb_dummy.c
@@ -46,16 +46,16 @@ int register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
return ENOSYS;
}
-NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
- const struct sockaddr_storage *_server,
- const struct sockaddr_storage *_client,
- int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
- uint64_t dst_srvid,
- const uint8_t *msg, size_t msglen,
- void *private_data),
- void *private_data)
+int ctdbd_register_ips(struct ctdbd_connection *conn,
+ const struct sockaddr_storage *_server,
+ const struct sockaddr_storage *_client,
+ int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
+ uint64_t dst_srvid,
+ const uint8_t *msg, size_t msglen,
+ void *private_data),
+ void *private_data)
{
- return NT_STATUS_NOT_IMPLEMENTED;
+ return ENOSYS;
}
bool ctdb_processes_exist(struct ctdbd_connection *conn,
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index fb812a3..0ba0d75 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -1180,14 +1180,14 @@ static void smbd_ctdb_canonicalize_ip(const struct sockaddr_storage *in,
* Register us as a server for a particular tcp connection
*/
-NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
- const struct sockaddr_storage *_server,
- const struct sockaddr_storage *_client,
- int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
- uint64_t dst_srvid,
- const uint8_t *msg, size_t msglen,
- void *private_data),
- void *private_data)
+int ctdbd_register_ips(struct ctdbd_connection *conn,
+ const struct sockaddr_storage *_server,
+ const struct sockaddr_storage *_client,
+ int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
+ uint64_t dst_srvid,
+ const uint8_t *msg, size_t msglen,
+ void *private_data),
+ void *private_data)
{
struct ctdb_control_tcp_addr p;
TDB_DATA data = { .dptr = (uint8_t *)&p, .dsize = sizeof(p) };
@@ -1212,7 +1212,7 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
memcpy(&p.src.ip6, &client, sizeof(p.src.ip6));
break;
default:
- return NT_STATUS_INTERNAL_ERROR;
+ return EIO;
}
/*
@@ -1222,7 +1222,7 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
ret = register_with_ctdbd(conn, CTDB_SRVID_RELEASE_IP,
cb, private_data);
if (ret != 0) {
- return map_nt_error_from_unix(ret);
+ return ret;
}
/*
@@ -1235,9 +1235,9 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
CTDB_CTRL_FLAG_NOREPLY, data, NULL, NULL,
NULL);
if (ret != 0) {
- return map_nt_error_from_unix(ret);
+ return ret;
}
- return NT_STATUS_OK;
+ return 0;
}
/*
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 74d34ef..3d8d340 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -2693,6 +2693,7 @@ static NTSTATUS smbd_register_ips(struct smbXsrv_connection *xconn,
{
struct smbd_release_ip_state *state;
struct ctdbd_connection *cconn;
+ int ret;
cconn = messaging_ctdbd_connection();
if (cconn == NULL) {
@@ -2712,7 +2713,11 @@ static NTSTATUS smbd_register_ips(struct smbXsrv_connection *xconn,
return NT_STATUS_NO_MEMORY;
}
- return ctdbd_register_ips(cconn, srv, clnt, release_ip, state);
+ ret = ctdbd_register_ips(cconn, srv, clnt, release_ip, state);
+ if (ret != 0) {
+ return map_nt_error_from_unix(ret);
+ }
+ return NT_STATUS_OK;
}
static void msg_kill_client_ip(struct messaging_context *msg_ctx,
--
1.9.1
From 9551b4d1644bd68eb5badf7a3cdbcecb791f8ab2 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 24/31] lib: Make ctdbd_control_local return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 8 +++----
source3/lib/ctdbd_conn.c | 40 +++++++++++++++------------------
source3/lib/dbwrap/dbwrap_ctdb.c | 48 ++++++++++++++++++++--------------------
3 files changed, 46 insertions(+), 50 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index ff1bc95..7073c0c 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -76,10 +76,10 @@ int ctdbd_register_ips(struct ctdbd_connection *conn,
void *private_data),
void *private_data);
-NTSTATUS ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
- uint64_t srvid, uint32_t flags, TDB_DATA data,
- TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
- int *cstatus);
+int ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
+ uint64_t srvid, uint32_t flags, TDB_DATA data,
+ TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
+ int *cstatus);
NTSTATUS ctdb_watch_us(struct ctdbd_connection *conn);
NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn);
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 0ba0d75..3d9f8f0 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -1243,26 +1243,20 @@ int ctdbd_register_ips(struct ctdbd_connection *conn,
/*
call a control on the local node
*/
-NTSTATUS ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
- uint64_t srvid, uint32_t flags, TDB_DATA data,
- TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
- int *cstatus)
+int ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
+ uint64_t srvid, uint32_t flags, TDB_DATA data,
+ TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
+ int *cstatus)
{
- int ret;
-
- ret = ctdbd_control(conn, CTDB_CURRENT_NODE, opcode, srvid, flags, data,
- mem_ctx, outdata, cstatus);
- if (ret != 0) {
- return map_nt_error_from_unix(ret);
- }
- return NT_STATUS_OK;
+ return ctdbd_control(conn, CTDB_CURRENT_NODE, opcode, srvid, flags, data,
+ mem_ctx, outdata, cstatus);
}
NTSTATUS ctdb_watch_us(struct ctdbd_connection *conn)
{
struct ctdb_client_notify_register reg_data;
size_t struct_len;
- NTSTATUS status;
+ int ret;
int cstatus;
reg_data.srvid = CTDB_SRVID_SAMBA_NOTIFY;
@@ -1272,34 +1266,36 @@ NTSTATUS ctdb_watch_us(struct ctdbd_connection *conn)
struct_len = offsetof(struct ctdb_client_notify_register,
notify_data) + reg_data.len;
- status = ctdbd_control_local(
+ ret = ctdbd_control_local(
conn, CTDB_CONTROL_REGISTER_NOTIFY, conn->rand_srvid, 0,
make_tdb_data((uint8_t *)®_data, struct_len),
NULL, NULL, &cstatus);
- if (!NT_STATUS_IS_OK(status)) {
+ if (ret != 0) {
DEBUG(1, ("ctdbd_control_local failed: %s\n",
- nt_errstr(status)));
+ strerror(ret)));
+ return map_nt_error_from_unix(ret);
}
- return status;
+ return NT_STATUS_OK;
}
NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn)
{
struct ctdb_client_notify_deregister dereg_data;
- NTSTATUS status;
+ int ret;
int cstatus;
dereg_data.srvid = CTDB_SRVID_SAMBA_NOTIFY;
- status = ctdbd_control_local(
+ ret = ctdbd_control_local(
conn, CTDB_CONTROL_DEREGISTER_NOTIFY, conn->rand_srvid, 0,
make_tdb_data((uint8_t *)&dereg_data, sizeof(dereg_data)),
NULL, NULL, &cstatus);
- if (!NT_STATUS_IS_OK(status)) {
+ if (ret != 0) {
DEBUG(1, ("ctdbd_control_local failed: %s\n",
- nt_errstr(status)));
+ strerror(ret)));
+ return map_nt_error_from_unix(ret);
}
- return status;
+ return NT_STATUS_OK;
}
NTSTATUS ctdbd_probe(const char *sockname, int timeout)
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 914ca4f..e024fe5 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -761,12 +761,12 @@ static int db_ctdb_transaction_commit(struct db_context *db)
again:
/* tell ctdbd to commit to the other nodes */
- rets = ctdbd_control_local(messaging_ctdbd_connection(),
- CTDB_CONTROL_TRANS3_COMMIT,
- h->ctx->db_id, 0,
- db_ctdb_marshall_finish(h->m_write),
- NULL, NULL, &status);
- if (!NT_STATUS_IS_OK(rets) || status != 0) {
+ ret = ctdbd_control_local(messaging_ctdbd_connection(),
+ CTDB_CONTROL_TRANS3_COMMIT,
+ h->ctx->db_id, 0,
+ db_ctdb_marshall_finish(h->m_write),
+ NULL, NULL, &status);
+ if ((ret != 0) || status != 0) {
/*
* The TRANS3_COMMIT control should only possibly fail when a
* recovery has been running concurrently. In any case, the db
@@ -853,6 +853,7 @@ static NTSTATUS db_ctdb_store(struct db_record *rec, TDB_DATA data, int flag)
static NTSTATUS db_ctdb_send_schedule_for_deletion(struct db_record *rec)
{
NTSTATUS status;
+ int ret;
struct ctdb_control_schedule_for_deletion *dd;
TDB_DATA indata;
int cstatus;
@@ -872,21 +873,21 @@ static NTSTATUS db_ctdb_send_schedule_for_deletion(struct db_record *rec)
dd->keylen = rec->key.dsize;
memcpy(dd->key, rec->key.dptr, rec->key.dsize);
- status = ctdbd_control_local(messaging_ctdbd_connection(),
- CTDB_CONTROL_SCHEDULE_FOR_DELETION,
- crec->ctdb_ctx->db_id,
- CTDB_CTRL_FLAG_NOREPLY, /* flags */
- indata,
- NULL, /* outdata */
- NULL, /* errmsg */
- &cstatus);
+ ret = ctdbd_control_local(messaging_ctdbd_connection(),
+ CTDB_CONTROL_SCHEDULE_FOR_DELETION,
+ crec->ctdb_ctx->db_id,
+ CTDB_CTRL_FLAG_NOREPLY, /* flags */
+ indata,
+ NULL, /* outdata */
+ NULL, /* errmsg */
+ &cstatus);
talloc_free(indata.dptr);
- if (!NT_STATUS_IS_OK(status) || cstatus != 0) {
+ if ((ret != 0) || cstatus != 0) {
DEBUG(1, (__location__ " Error sending local control "
"SCHEDULE_FOR_DELETION: %s, cstatus = %d\n",
- nt_errstr(status), cstatus));
- if (NT_STATUS_IS_OK(status)) {
+ strerror(ret), cstatus));
+ if (ret != 0) {
status = NT_STATUS_UNSUCCESSFUL;
}
}
@@ -1550,7 +1551,6 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
struct ctdbd_connection *conn;
struct loadparm_context *lp_ctx;
struct ctdb_db_priority prio;
- NTSTATUS status;
int cstatus;
int ret;
@@ -1608,14 +1608,14 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
prio.db_id = db_ctdb->db_id;
prio.priority = lock_order;
- status = ctdbd_control_local(
+ ret = ctdbd_control_local(
conn, CTDB_CONTROL_SET_DB_PRIORITY, 0, 0,
make_tdb_data((uint8_t *)&prio, sizeof(prio)),
NULL, NULL, &cstatus);
- if (!NT_STATUS_IS_OK(status) || (cstatus != 0)) {
+ if ((ret != 0) || (cstatus != 0)) {
DEBUG(1, ("CTDB_CONTROL_SET_DB_PRIORITY failed: %s, %d\n",
- nt_errstr(status), cstatus));
+ strerror(ret), cstatus));
TALLOC_FREE(result);
return NULL;
}
@@ -1628,12 +1628,12 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
indata = make_tdb_data((uint8_t *)&db_ctdb->db_id,
sizeof(db_ctdb->db_id));
- status = ctdbd_control_local(
+ ret = ctdbd_control_local(
conn, CTDB_CONTROL_SET_DB_READONLY, 0, 0, indata,
NULL, NULL, &cstatus);
- if (!NT_STATUS_IS_OK(status) || (cstatus != 0)) {
+ if ((ret != 0) || (cstatus != 0)) {
DEBUG(1, ("CTDB_CONTROL_SET_DB_READONLY failed: "
- "%s, %d\n", nt_errstr(status), cstatus));
+ "%s, %d\n", strerror(ret), cstatus));
TALLOC_FREE(result);
return NULL;
}
--
1.9.1
From 6e2b66848dd02798238208907e9e2c2ac666fd25 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 25/31] lib: Make ctdb_watch_us return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 2 +-
source3/lib/ctdbd_conn.c | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 7073c0c..1fb77fd 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -80,7 +80,7 @@ int ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
uint64_t srvid, uint32_t flags, TDB_DATA data,
TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
int *cstatus);
-NTSTATUS ctdb_watch_us(struct ctdbd_connection *conn);
+int ctdb_watch_us(struct ctdbd_connection *conn);
NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn);
struct ctdb_req_message;
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 3d9f8f0..ee598c6 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -1252,7 +1252,7 @@ int ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
mem_ctx, outdata, cstatus);
}
-NTSTATUS ctdb_watch_us(struct ctdbd_connection *conn)
+int ctdb_watch_us(struct ctdbd_connection *conn)
{
struct ctdb_client_notify_register reg_data;
size_t struct_len;
@@ -1273,9 +1273,8 @@ NTSTATUS ctdb_watch_us(struct ctdbd_connection *conn)
if (ret != 0) {
DEBUG(1, ("ctdbd_control_local failed: %s\n",
strerror(ret)));
- return map_nt_error_from_unix(ret);
}
- return NT_STATUS_OK;
+ return ret;
}
NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn)
--
1.9.1
From ae061b1fcbe7a04c79e30f3c7671617acfdbceac Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 26/31] lib: Make ctdb_unwatch return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 2 +-
source3/lib/ctdbd_conn.c | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 1fb77fd..a42deae 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -81,7 +81,7 @@ int ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
int *cstatus);
int ctdb_watch_us(struct ctdbd_connection *conn);
-NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn);
+int ctdb_unwatch(struct ctdbd_connection *conn);
struct ctdb_req_message;
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index ee598c6..0f5b41e 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -1277,7 +1277,7 @@ int ctdb_watch_us(struct ctdbd_connection *conn)
return ret;
}
-NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn)
+int ctdb_unwatch(struct ctdbd_connection *conn)
{
struct ctdb_client_notify_deregister dereg_data;
int ret;
@@ -1292,9 +1292,8 @@ NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn)
if (ret != 0) {
DEBUG(1, ("ctdbd_control_local failed: %s\n",
strerror(ret)));
- return map_nt_error_from_unix(ret);
}
- return NT_STATUS_OK;
+ return ret;
}
NTSTATUS ctdbd_probe(const char *sockname, int timeout)
--
1.9.1
From 53265cdf847f988aae85b128edc6c66c601b2d94 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 27/31] lib: Make ctdbd_probe return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 2 +-
source3/lib/ctdb_dummy.c | 4 ++--
source3/lib/ctdbd_conn.c | 4 ++--
source3/lib/util_cluster.c | 8 ++++----
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index a42deae..1381569 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -91,6 +91,6 @@ int 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(const char *sockname, int timeout);
+int ctdbd_probe(const char *sockname, int timeout);
#endif /* _CTDBD_CONN_H */
diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c
index 7afb6b3..c2783ee 100644
--- a/source3/lib/ctdb_dummy.c
+++ b/source3/lib/ctdb_dummy.c
@@ -24,9 +24,9 @@
#include "lib/dbwrap/dbwrap_ctdb.h"
#include "torture/proto.h"
-NTSTATUS ctdbd_probe(const char *sockname, int timeout)
+int ctdbd_probe(const char *sockname, int timeout)
{
- return NT_STATUS_NOT_IMPLEMENTED;
+ return ENOSYS;
}
int ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 0f5b41e..f091da7 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -1296,7 +1296,7 @@ int ctdb_unwatch(struct ctdbd_connection *conn)
return ret;
}
-NTSTATUS ctdbd_probe(const char *sockname, int timeout)
+int ctdbd_probe(const char *sockname, int timeout)
{
/*
* Do a very early check if ctdbd is around to avoid an abort and core
@@ -1313,5 +1313,5 @@ NTSTATUS ctdbd_probe(const char *sockname, int timeout)
*/
TALLOC_FREE(conn);
- return map_nt_error_from_unix(ret);
+ return ret;
}
diff --git a/source3/lib/util_cluster.c b/source3/lib/util_cluster.c
index 85f006c..bfa1154 100644
--- a/source3/lib/util_cluster.c
+++ b/source3/lib/util_cluster.c
@@ -26,12 +26,12 @@
bool cluster_probe_ok(void)
{
if (lp_clustering()) {
- NTSTATUS status;
+ int ret;
- status = ctdbd_probe(lp_ctdbd_socket(), lp_ctdb_timeout());
- if (!NT_STATUS_IS_OK(status)) {
+ ret = ctdbd_probe(lp_ctdbd_socket(), lp_ctdb_timeout());
+ if (ret != 0) {
DEBUG(0, ("clustering=yes but ctdbd connect failed: "
- "%s\n", nt_errstr(status)));
+ "%s\n", strerror(ret)));
return false;
}
}
--
1.9.1
From 319c309334058e5094f2f45a780461d00d9d1b30 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 22:30:35 -0700
Subject: [PATCH 28/31] lib: Remove messaging_tevent_context() dependency from
ctdbd_conn.c
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/ctdbd_conn.h | 3 ++-
source3/lib/ctdbd_conn.c | 12 +++++-------
source3/lib/messages_ctdbd.c | 3 ++-
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 1381569..9342ddc 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -33,7 +33,8 @@ int ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
uint32_t ctdbd_vnn(const struct ctdbd_connection *conn);
int ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
- struct messaging_context *msg_ctx);
+ struct messaging_context *msg_ctx,
+ struct tevent_context *ev);
struct messaging_context *ctdb_conn_msg_ctx(struct ctdbd_connection *conn);
int ctdbd_conn_get_fd(struct ctdbd_connection *conn);
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index f091da7..990819e 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -577,17 +577,15 @@ static void ctdbd_socket_handler(struct tevent_context *event_ctx,
*/
int ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
- struct messaging_context *msg_ctx)
+ struct messaging_context *msg_ctx,
+ struct tevent_context *ev)
{
SMB_ASSERT(conn->msg_ctx == NULL);
SMB_ASSERT(conn->fde == NULL);
- if (!(conn->fde = tevent_add_fd(messaging_tevent_context(msg_ctx),
- conn,
- conn->fd,
- TEVENT_FD_READ,
- ctdbd_socket_handler,
- conn))) {
+ conn->fde = tevent_add_fd(ev, conn, conn->fd, TEVENT_FD_READ,
+ ctdbd_socket_handler, conn);
+ if (conn->fde == NULL) {
DEBUG(0, ("event_add_fd failed\n"));
return ENOMEM;
}
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index a0c8d90..5acd468 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -188,7 +188,8 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
return map_nt_error_from_unix(ret);
}
- ret = ctdbd_register_msg_ctx(ctx->conn, msg_ctx);
+ ret = ctdbd_register_msg_ctx(ctx->conn, msg_ctx,
+ messaging_tevent_context(msg_ctx));
if (ret != 0) {
DEBUG(10, ("ctdbd_register_msg_ctx failed: %s\n",
--
1.9.1
From df3b14d66603ef2ff6727a62cb7ba61a5bb7a580 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 22:33:12 -0700
Subject: [PATCH 29/31] lib: Use poll_intr_one_fd in ctdb_read_packet
This is an actual bug fix if someone sets "ctdb timeout" to something != 0
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 990819e..9e598ac 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -301,7 +301,7 @@ static int ctdb_read_packet(int fd, int timeout, TALLOC_CTX *mem_ctx,
ssize_t nread;
if (timeout != -1) {
- ret = poll_one_fd(fd, POLLIN, timeout, &revents);
+ ret = poll_intr_one_fd(fd, POLLIN, timeout, &revents);
if (ret == -1) {
return errno;
}
--
1.9.1
From 05deac91a0623e548c7426b09b1c075f7a328ab8 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 30/31] lib: Make messaging_ctdbd_init return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/messages.h | 6 +++---
source3/lib/ctdb_dummy.c | 6 +++---
source3/lib/messages.c | 18 ++++++++----------
source3/lib/messages_ctdbd.c | 18 +++++++++---------
4 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/source3/include/messages.h b/source3/include/messages.h
index c620f92..5ad155b 100644
--- a/source3/include/messages.h
+++ b/source3/include/messages.h
@@ -74,9 +74,9 @@ struct messaging_backend {
void *private_data;
};
-NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
- TALLOC_CTX *mem_ctx,
- struct messaging_backend **presult);
+int messaging_ctdbd_init(struct messaging_context *msg_ctx,
+ TALLOC_CTX *mem_ctx,
+ struct messaging_backend **presult);
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 c2783ee..5162242 100644
--- a/source3/lib/ctdb_dummy.c
+++ b/source3/lib/ctdb_dummy.c
@@ -81,11 +81,11 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
return NULL;
}
-NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
- TALLOC_CTX *mem_ctx,
+int messaging_ctdbd_init(struct messaging_context *msg_ctx,
+ TALLOC_CTX *mem_ctx,
struct messaging_backend **presult)
{
- return NT_STATUS_NOT_IMPLEMENTED;
+ return ENOSYS;
}
struct ctdbd_connection *messaging_ctdbd_connection(void)
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 07d1c83..717cd4c 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -291,7 +291,6 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev)
{
struct messaging_context *ctx;
- NTSTATUS status;
int ret;
const char *lck_path;
const char *priv_path;
@@ -349,11 +348,11 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
talloc_set_destructor(ctx, messaging_context_destructor);
if (lp_clustering()) {
- status = messaging_ctdbd_init(ctx, ctx, &ctx->remote);
+ ret = messaging_ctdbd_init(ctx, ctx, &ctx->remote);
- if (!NT_STATUS_IS_OK(status)) {
+ if (ret != 0) {
DEBUG(2, ("messaging_ctdbd_init failed: %s\n",
- nt_errstr(status)));
+ strerror(ret)));
TALLOC_FREE(ctx);
return NULL;
}
@@ -390,7 +389,6 @@ struct server_id messaging_server_id(const struct messaging_context *msg_ctx)
*/
NTSTATUS messaging_reinit(struct messaging_context *msg_ctx)
{
- NTSTATUS status;
int ret;
TALLOC_FREE(msg_ctx->msg_dgm_ref);
@@ -410,13 +408,13 @@ NTSTATUS messaging_reinit(struct messaging_context *msg_ctx)
TALLOC_FREE(msg_ctx->remote);
if (lp_clustering()) {
- status = messaging_ctdbd_init(msg_ctx, msg_ctx,
- &msg_ctx->remote);
+ ret = messaging_ctdbd_init(msg_ctx, msg_ctx,
+ &msg_ctx->remote);
- if (!NT_STATUS_IS_OK(status)) {
+ if (ret != 0) {
DEBUG(1, ("messaging_ctdbd_init failed: %s\n",
- nt_errstr(status)));
- return status;
+ strerror(ret)));
+ return map_nt_error_from_unix(ret);
}
}
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index 5acd468..90bae76 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -159,9 +159,9 @@ static int messaging_ctdb_recv(
return 0;
}
-NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
- TALLOC_CTX *mem_ctx,
- struct messaging_backend **presult)
+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;
@@ -169,13 +169,13 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
if (!(result = talloc(mem_ctx, struct messaging_backend))) {
DEBUG(0, ("talloc failed\n"));
- return NT_STATUS_NO_MEMORY;
+ return ENOMEM;
}
if (!(ctx = talloc(result, struct messaging_ctdbd_context))) {
DEBUG(0, ("talloc failed\n"));
TALLOC_FREE(result);
- return NT_STATUS_NO_MEMORY;
+ return ENOMEM;
}
ret = ctdbd_messaging_connection(ctx, lp_ctdbd_socket(),
@@ -185,7 +185,7 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
DEBUG(10, ("ctdbd_messaging_connection failed: %s\n",
strerror(ret)));
TALLOC_FREE(result);
- return map_nt_error_from_unix(ret);
+ return ret;
}
ret = ctdbd_register_msg_ctx(ctx->conn, msg_ctx,
@@ -195,7 +195,7 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
DEBUG(10, ("ctdbd_register_msg_ctx failed: %s\n",
strerror(ret)));
TALLOC_FREE(result);
- return map_nt_error_from_unix(ret);
+ return ret;
}
ret = register_with_ctdbd(ctx->conn, getpid(),
@@ -204,7 +204,7 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
DEBUG(10, ("register_with_ctdbd failed: %s\n",
strerror(ret)));
TALLOC_FREE(result);
- return map_nt_error_from_unix(ret);
+ return ret;
}
global_ctdb_connection_pid = getpid();
@@ -217,5 +217,5 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
result->private_data = (void *)ctx;
*presult = result;
- return NT_STATUS_OK;
+ return 0;
}
--
1.9.1
From 4f6e529327edf1fed151340be6718c5703e507dc Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Oct 2015 20:42:05 -0700
Subject: [PATCH 31/31] lib: Make messaging_send_iov_from return 0/errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/messages.h | 10 +++++-----
source3/lib/messages.c | 36 ++++++++++++++++++------------------
source3/lib/messages_ctdbd.c | 10 +++++-----
source3/smbd/notifyd/notifyd.c | 8 ++++----
4 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/source3/include/messages.h b/source3/include/messages.h
index 5ad155b..9a3ea25 100644
--- a/source3/include/messages.h
+++ b/source3/include/messages.h
@@ -123,11 +123,11 @@ NTSTATUS messaging_send(struct messaging_context *msg_ctx,
NTSTATUS messaging_send_buf(struct messaging_context *msg_ctx,
struct server_id server, uint32_t msg_type,
const uint8_t *buf, size_t len);
-NTSTATUS messaging_send_iov_from(struct messaging_context *msg_ctx,
- struct server_id src, struct server_id dst,
- uint32_t msg_type,
- const struct iovec *iov, int iovlen,
- const int *fds, size_t num_fds);
+int messaging_send_iov_from(struct messaging_context *msg_ctx,
+ struct server_id src, struct server_id dst,
+ uint32_t msg_type,
+ const struct iovec *iov, int iovlen,
+ const int *fds, size_t num_fds);
NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx,
struct server_id server, uint32_t msg_type,
const struct iovec *iov, int iovlen,
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 717cd4c..03e6097 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -518,37 +518,34 @@ NTSTATUS messaging_send_buf(struct messaging_context *msg_ctx,
return messaging_send(msg_ctx, server, msg_type, &blob);
}
-NTSTATUS messaging_send_iov_from(struct messaging_context *msg_ctx,
- struct server_id src, struct server_id dst,
- uint32_t msg_type,
- const struct iovec *iov, int iovlen,
- const int *fds, size_t num_fds)
+int messaging_send_iov_from(struct messaging_context *msg_ctx,
+ struct server_id src, struct server_id dst,
+ uint32_t msg_type,
+ const struct iovec *iov, int iovlen,
+ const int *fds, size_t num_fds)
{
int ret;
uint8_t hdr[MESSAGE_HDR_LENGTH];
struct iovec iov2[iovlen+1];
if (server_id_is_disconnected(&dst)) {
- return NT_STATUS_INVALID_PARAMETER_MIX;
+ return EINVAL;
}
if (num_fds > INT8_MAX) {
- return NT_STATUS_INVALID_PARAMETER_MIX;
+ return EINVAL;
}
if (!procid_is_local(&dst)) {
if (num_fds > 0) {
- return NT_STATUS_NOT_SUPPORTED;
+ return ENOSYS;
}
ret = msg_ctx->remote->send_fn(src, dst,
msg_type, iov, iovlen,
NULL, 0,
msg_ctx->remote);
- if (ret != 0) {
- return map_nt_error_from_unix(ret);
- }
- return NT_STATUS_OK;
+ return ret;
}
message_hdr_put(hdr, msg_type, src, dst);
@@ -559,10 +556,7 @@ NTSTATUS messaging_send_iov_from(struct messaging_context *msg_ctx,
ret = messaging_dgm_send(dst.pid, iov2, iovlen+1, fds, num_fds);
unbecome_root();
- if (ret != 0) {
- return map_nt_error_from_unix(ret);
- }
- return NT_STATUS_OK;
+ return ret;
}
NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx,
@@ -570,8 +564,14 @@ NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx,
const struct iovec *iov, int iovlen,
const int *fds, size_t num_fds)
{
- return messaging_send_iov_from(msg_ctx, msg_ctx->id, dst, msg_type,
- iov, iovlen, fds, num_fds);
+ int ret;
+
+ ret = messaging_send_iov_from(msg_ctx, msg_ctx->id, dst, msg_type,
+ iov, iovlen, fds, num_fds);
+ if (ret != 0) {
+ return map_nt_error_from_unix(ret);
+ }
+ return NT_STATUS_OK;
}
static struct messaging_rec *messaging_rec_dup(TALLOC_CTX *mem_ctx,
diff --git a/source3/lib/messages_ctdbd.c b/source3/lib/messages_ctdbd.c
index 90bae76..48563a8 100644
--- a/source3/lib/messages_ctdbd.c
+++ b/source3/lib/messages_ctdbd.c
@@ -112,7 +112,7 @@ static int messaging_ctdb_recv(
struct messaging_context *msg_ctx = talloc_get_type_abort(
private_data, struct messaging_context);
struct server_id me = messaging_server_id(msg_ctx);
- NTSTATUS status;
+ int ret;
struct iovec iov;
struct server_id src, dst;
enum messaging_type msg_type;
@@ -148,12 +148,12 @@ static int messaging_ctdb_recv(
* Go through the event loop
*/
- status = messaging_send_iov_from(msg_ctx, src, dst, msg_type,
- &iov, 1, NULL, 0);
+ ret = messaging_send_iov_from(msg_ctx, src, dst, msg_type,
+ &iov, 1, NULL, 0);
- if (!NT_STATUS_IS_OK(status)) {
+ if (ret != 0) {
DEBUG(10, ("%s: messaging_send_iov_from failed: %s\n",
- __func__, nt_errstr(status)));
+ __func__, strerror(ret)));
}
return 0;
diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c
index 06f48cf..141556d 100644
--- a/source3/smbd/notifyd/notifyd.c
+++ b/source3/smbd/notifyd/notifyd.c
@@ -791,7 +791,7 @@ static void notifyd_send_delete(struct messaging_context *msg_ctx,
};
uint8_t nul = 0;
struct iovec iov[3];
- NTSTATUS status;
+ int ret;
/*
* Send a rec_change to ourselves to delete a dead entry
@@ -803,13 +803,13 @@ static void notifyd_send_delete(struct messaging_context *msg_ctx,
iov[1] = (struct iovec) { .iov_base = key.dptr, .iov_len = key.dsize };
iov[2] = (struct iovec) { .iov_base = &nul, .iov_len = sizeof(nul) };
- status = messaging_send_iov_from(
+ ret = messaging_send_iov_from(
msg_ctx, instance->client, messaging_server_id(msg_ctx),
MSG_SMB_NOTIFY_REC_CHANGE, iov, ARRAY_SIZE(iov), NULL, 0);
- if (!NT_STATUS_IS_OK(status)) {
+ if (ret != 0) {
DEBUG(10, ("%s: messaging_send_iov_from returned %s\n",
- __func__, nt_errstr(status)));
+ __func__, strerror(ret)));
}
}
--
1.9.1
More information about the samba-technical
mailing list