The branch, master has been updated
       via  ad5a4a9 ctdbd_conn: Make "cstatus" int32_t
       via  2bd1bcf ctdbd_conn: Add some more debug info
       via  aad53cf ctdbd: Use talloc_memdup where appropriate
       via  445ad6e ctdbd_conn: Use ctdbd_control_local where possible
       via  f0525d4 ctdbd_conn: Avoid "includes.h"
       via  d36def8 lib: serverid.h references struct server_id
       via  ff72a8a lib: Move ctdbd_init_connection out of ctdbd_traverse()
       via  966cef0 ctdbd_conn: Remove unused ctdbd_messaging_connection
       via  e2d39ae lib: Use ctdbd_init_connection in messaging_ctdbd_init
       via  1ff4002 ctdbd_conn: Make ctdbd_init_connection public
       via  b1277ac ctdbd_conn: Use ctdbd_init_connection in ctdbd_probe
       via  14beae7 ctdbd_conn: Use sys_poll_intr
       via  d59ae31 ctdbd_conn: Adapt loop counter's type to the loop limit
      from  39bbd40 fix Invalid read of size 8

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit ad5a4a9e369248789b08f8ccad51d4d42df71bc9
Author: Volker Lendecke <[email protected]>
Date:   Thu Apr 21 13:31:39 2016 +0200

    ctdbd_conn: Make "cstatus" int32_t
    
    This converts the "cstatus" parameter of ctdbd_control_local to what it is
    defined as in the packet: int32_t. It was used inconsistently throughout the
    code.
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>
    
    Autobuild-User(master): Ralph Böhme <[email protected]>
    Autobuild-Date(master): Mon Apr 25 21:54:24 CEST 2016 on sn-devel-144

commit 2bd1bcf50c6d9e8fd486262742268f3208c0680d
Author: Volker Lendecke <[email protected]>
Date:   Thu Apr 21 11:21:26 2016 +0200

    ctdbd_conn: Add some more debug info
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit aad53cf59524355df757c9de7dca081da75b76d0
Author: Volker Lendecke <[email protected]>
Date:   Mon Apr 4 16:23:09 2016 +0200

    ctdbd: Use talloc_memdup where appropriate
    
    .... 40 bytes .text less ;-)
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 445ad6e8e42b6fb82aa736f7db904505175e8daf
Author: Volker Lendecke <[email protected]>
Date:   Wed Apr 13 18:47:46 2016 +0200

    ctdbd_conn: Use ctdbd_control_local where possible
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit f0525d4e07a5d741746f539a508668abeb14f0d5
Author: Volker Lendecke <[email protected]>
Date:   Fri Apr 8 16:14:33 2016 +0200

    ctdbd_conn: Avoid "includes.h"
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit d36def84aec84f63a92538726bed91dc197f9743
Author: Volker Lendecke <[email protected]>
Date:   Tue Apr 5 07:26:34 2016 +0200

    lib: serverid.h references struct server_id
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit ff72a8ae82ec2e7760d86bc7ea95837489a93df2
Author: Volker Lendecke <[email protected]>
Date:   Tue Apr 5 17:30:11 2016 +0200

    lib: Move ctdbd_init_connection out of ctdbd_traverse()
    
    2 effects: This removes the [un]become_root calls from ctdbd_conn,
    and it makes it possible to re-use the traversal connections, should
    the setup/teardown become a problem in the future.
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 966cef0d41d85d2753d3664a0e555bb444cef2e3
Author: Volker Lendecke <[email protected]>
Date:   Tue Apr 5 10:14:11 2016 +0200

    ctdbd_conn: Remove unused ctdbd_messaging_connection
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit e2d39aefae41da5a5614c5061d2aa30f40c5d65d
Author: Volker Lendecke <[email protected]>
Date:   Tue Apr 5 10:11:44 2016 +0200

    lib: Use ctdbd_init_connection in messaging_ctdbd_init
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 1ff4002b23d7ff1d9de145f1f356d9a729af9ae9
Author: Volker Lendecke <[email protected]>
Date:   Tue Apr 5 10:09:35 2016 +0200

    ctdbd_conn: Make ctdbd_init_connection public
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit b1277acb44a51d92af0e7d7e59856606b8806192
Author: Volker Lendecke <[email protected]>
Date:   Tue Apr 5 09:52:01 2016 +0200

    ctdbd_conn: Use ctdbd_init_connection in ctdbd_probe
    
    We are only interested in ctdb connectability here.
    ctdbd_messaging_connection() does a few more calls not required here
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 14beae7cc9059a1efcc93887b53563b336d26d14
Author: Volker Lendecke <[email protected]>
Date:   Tue Apr 19 16:14:30 2016 +0200

    ctdbd_conn: Use sys_poll_intr
    
    This pulls in far less dependencies than poll_intr_one_fd and is not much 
more
    complex to call
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit d59ae31cca4d889784ffe06b633e239b60fc0229
Author: Volker Lendecke <[email protected]>
Date:   Fri Apr 8 15:59:08 2016 +0200

    ctdbd_conn: Adapt loop counter's type to the loop limit
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/server/ctdb_daemon.c        |   4 +-
 source3/include/ctdbd_conn.h     |  12 ++--
 source3/include/serverid.h       |   1 +
 source3/lib/ctdbd_conn.c         | 142 ++++++++++++++-------------------------
 source3/lib/dbwrap/dbwrap_ctdb.c |  50 +++++++++++---
 source3/lib/messages_ctdbd.c     |  16 +++--
 6 files changed, 113 insertions(+), 112 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index a5fefe3..321b86e 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/server/ctdb_daemon.c
@@ -1709,9 +1709,9 @@ int32_t ctdb_control_register_notify(struct ctdb_context 
*ctdb, uint32_t client_
        nl->ctdb       = ctdb;
        nl->srvid      = notify->srvid;
        nl->data.dsize = notify->len;
-       nl->data.dptr  = talloc_size(nl, nl->data.dsize);
+       nl->data.dptr  = talloc_memdup(nl, notify->notify_data,
+                                      nl->data.dsize);
        CTDB_NO_MEMORY(ctdb, nl->data.dptr);
-       memcpy(nl->data.dptr, notify->notify_data, nl->data.dsize);
        
        DLIST_ADD(client->notify, nl);
        talloc_set_destructor(nl, ctdb_client_notify_destructor);
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index 27993c7..c91f700 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -20,15 +20,19 @@
 #ifndef _CTDBD_CONN_H
 #define _CTDBD_CONN_H
 
+#include "replace.h"
+#include "system/filesys.h"
+#include "system/network.h"
 #include <tdb.h>
+#include <tevent.h>
 
 struct ctdbd_connection;
 struct messaging_context;
 struct messaging_rec;
 
-int ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
-                              const char *sockname, int timeout,
-                              struct ctdbd_connection **pconn);
+int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
+                         const char *sockname, int timeout,
+                         struct ctdbd_connection **pconn);
 
 uint32_t ctdbd_vnn(const struct ctdbd_connection *conn);
 
@@ -80,7 +84,7 @@ int ctdbd_register_ips(struct ctdbd_connection *conn,
 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);
+                       int32_t *cstatus);
 int ctdb_watch_us(struct ctdbd_connection *conn);
 int ctdb_unwatch(struct ctdbd_connection *conn);
 
diff --git a/source3/include/serverid.h b/source3/include/serverid.h
index 5db61b9..19caec8 100644
--- a/source3/include/serverid.h
+++ b/source3/include/serverid.h
@@ -22,6 +22,7 @@
 
 #include "replace.h"
 #include "lib/dbwrap/dbwrap.h"
+#include "librpc/gen_ndr/server_id.h"
 
 /*
  * Register a server with its unique id
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 04f6f2f..9ea029a 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -18,13 +18,18 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
+#include "replace.h"
 #include "util_tdb.h"
 #include "serverid.h"
 #include "ctdbd_conn.h"
 #include "system/select.h"
 #include "lib/util/sys_rw_data.h"
 #include "lib/util/iov_buf.h"
+#include "lib/util/select.h"
+#include "lib/util/debug.h"
+#include "lib/util/talloc_stack.h"
+#include "lib/util/genrand.h"
+#include "lib/util/fault.h"
 
 #include "messages.h"
 
@@ -67,7 +72,7 @@ static int ctdbd_control(struct ctdbd_connection *conn,
                         uint64_t srvid, uint32_t flags,
                         TDB_DATA data,
                         TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
-                        int *cstatus);
+                        int32_t *cstatus);
 
 /*
  * exit on fatal communications errors with the ctdbd daemon
@@ -107,13 +112,13 @@ int register_with_ctdbd(struct ctdbd_connection *conn, 
uint64_t srvid,
                        void *private_data)
 {
 
-       int ret, cstatus;
+       int ret;
+       int32_t cstatus;
        size_t num_callbacks;
        struct ctdbd_srvid_cb *tmp;
 
-       ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
-                           CTDB_CONTROL_REGISTER_SRVID, srvid, 0,
-                           tdb_null, NULL, NULL, &cstatus);
+       ret = ctdbd_control_local(conn, CTDB_CONTROL_REGISTER_SRVID, srvid, 0,
+                                 tdb_null, NULL, NULL, &cstatus);
        if (ret != 0) {
                return ret;
        }
@@ -180,9 +185,8 @@ static int get_cluster_vnn(struct ctdbd_connection *conn, 
uint32_t *vnn)
 {
        int32_t cstatus=-1;
        int ret;
-       ret = ctdbd_control(conn,
-                           CTDB_CURRENT_NODE, CTDB_CONTROL_GET_PNN, 0, 0,
-                           tdb_null, NULL, NULL, &cstatus);
+       ret = ctdbd_control_local(conn, CTDB_CONTROL_GET_PNN, 0, 0,
+                                 tdb_null, NULL, NULL, &cstatus);
        if (ret != 0) {
                DEBUG(1, ("ctdbd_control failed: %s\n", strerror(ret)));
                return ret;
@@ -201,11 +205,11 @@ static bool ctdbd_working(struct ctdbd_connection *conn, 
uint32_t vnn)
        struct ctdb_node_map_old *m;
        uint32_t failure_flags;
        bool ok = false;
-       int i, ret;
+       uint32_t i;
+       int ret;
 
-       ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
-                           CTDB_CONTROL_GET_NODEMAP, 0, 0,
-                           tdb_null, talloc_tos(), &outdata, &cstatus);
+       ret = ctdbd_control_local(conn, CTDB_CONTROL_GET_NODEMAP, 0, 0,
+                                 tdb_null, talloc_tos(), &outdata, &cstatus);
        if (ret != 0) {
                DEBUG(1, ("ctdbd_control failed: %s\n", strerror(ret)));
                return false;
@@ -295,12 +299,14 @@ static int ctdb_read_packet(int fd, int timeout, 
TALLOC_CTX *mem_ctx,
                            struct ctdb_req_header **result)
 {
        struct ctdb_req_header *req;
-       int ret, revents;
        uint32_t msglen;
        ssize_t nread;
 
        if (timeout != -1) {
-               ret = poll_intr_one_fd(fd, POLLIN, timeout, &revents);
+               struct pollfd pfd = { .fd = fd, .events = POLLIN };
+               int ret;
+
+               ret = sys_poll_intr(&pfd, 1, timeout);
                if (ret == -1) {
                        return errno;
                }
@@ -416,9 +422,9 @@ static int ctdbd_connection_destructor(struct 
ctdbd_connection *c)
  * Get us a ctdbd connection
  */
 
-static int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
-                                const char *sockname, int timeout,
-                                struct ctdbd_connection **pconn)
+int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
+                         const char *sockname, int timeout,
+                         struct ctdbd_connection **pconn)
 {
        struct ctdbd_connection *conn;
        int ret;
@@ -480,36 +486,6 @@ static int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
        return ret;
 }
 
-/*
- * Get us a ctdbd connection and register us as a process
- */
-
-int ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
-                              const char *sockname, int timeout,
-                              struct ctdbd_connection **pconn)
-{
-        struct ctdbd_connection *conn;
-       int ret;
-
-       ret = ctdbd_init_connection(mem_ctx, sockname, timeout, &conn);
-
-       if (ret != 0) {
-               return ret;
-       }
-
-       ret = register_with_ctdbd(conn, MSG_SRVID_SAMBA, NULL, NULL);
-       if (ret != 0) {
-               goto fail;
-       }
-
-       *pconn = conn;
-       return 0;
-
- fail:
-       TALLOC_FREE(conn);
-       return ret;
-}
-
 struct messaging_context *ctdb_conn_msg_ctx(struct ctdbd_connection *conn)
 {
        return conn->msg_ctx;
@@ -638,7 +614,7 @@ static int ctdbd_control(struct ctdbd_connection *conn,
                         uint64_t srvid, uint32_t flags,
                         TDB_DATA data,
                         TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
-                        int *cstatus)
+                        int32_t *cstatus)
 {
        struct ctdb_req_control_old req;
        struct ctdb_req_header *hdr;
@@ -659,7 +635,9 @@ static int ctdbd_control(struct ctdbd_connection *conn,
        req.datalen          = data.dsize;
        req.flags            = flags;
 
-       DEBUG(10, ("ctdbd_control: Sending ctdb packet\n"));
+       DBG_DEBUG("Sending ctdb packet reqid=%"PRIu32", vnn=%"PRIu32", "
+                 "opcode=%"PRIu32", srvid=%"PRIu64"\n", req.hdr.reqid,
+                 req.hdr.destnode, req.opcode, req.srvid);
        ctdb_packet_dump(&req.hdr);
 
        iov[0].iov_base = &req;
@@ -850,9 +828,8 @@ char *ctdbd_dbpath(struct ctdbd_connection *conn,
        data.dptr = (uint8_t*)&db_id;
        data.dsize = sizeof(db_id);
 
-       ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
-                           CTDB_CONTROL_GETDBPATH, 0, 0, data,
-                           mem_ctx, &rdata, &cstatus);
+       ret = ctdbd_control_local(conn, CTDB_CONTROL_GETDBPATH, 0, 0, data,
+                                 mem_ctx, &rdata, &cstatus);
        if ((ret != 0) || cstatus != 0) {
                DEBUG(0, (__location__ " ctdb_control for getdbpath failed: 
%s\n",
                          strerror(ret)));
@@ -875,11 +852,11 @@ int ctdbd_db_attach(struct ctdbd_connection *conn,
 
        data = string_term_tdb_data(name);
 
-       ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
-                           persistent
-                           ? CTDB_CONTROL_DB_ATTACH_PERSISTENT
-                           : CTDB_CONTROL_DB_ATTACH,
-                           tdb_flags, 0, data, NULL, &data, &cstatus);
+       ret = ctdbd_control_local(conn,
+                                 persistent
+                                 ? CTDB_CONTROL_DB_ATTACH_PERSISTENT
+                                 : CTDB_CONTROL_DB_ATTACH,
+                                 tdb_flags, 0, data, NULL, &data, &cstatus);
        if (ret != 0) {
                DEBUG(0, (__location__ " ctdb_control for db_attach "
                          "failed: %s\n", strerror(ret)));
@@ -901,9 +878,8 @@ int ctdbd_db_attach(struct ctdbd_connection *conn,
        data.dptr = (uint8_t *)db_id;
        data.dsize = sizeof(*db_id);
 
-       ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
-                           CTDB_CONTROL_ENABLE_SEQNUM, 0, 0, data,
-                           NULL, NULL, &cstatus);
+       ret = ctdbd_control_local(conn, CTDB_CONTROL_ENABLE_SEQNUM, 0, 0, data,
+                                 NULL, NULL, &cstatus);
        if ((ret != 0) || cstatus != 0) {
                DEBUG(0, (__location__ " ctdb_control for enable seqnum "
                          "failed: %s\n", strerror(ret)));
@@ -1040,31 +1016,20 @@ int ctdbd_parse(struct ctdbd_connection *conn, uint32_t 
db_id,
 }
 
 /*
-  Traverse a ctdb database. This uses a kind-of hackish way to open a second
-  connection to ctdbd to avoid the hairy recursive and async problems with
-  everything in-line.
+  Traverse a ctdb database. "conn" must be an otherwise unused
+  ctdb_connection where no other messages but the traverse ones are
+  expected.
 */
 
-int ctdbd_traverse(struct ctdbd_connection *master, uint32_t db_id,
+int ctdbd_traverse(struct ctdbd_connection *conn, uint32_t db_id,
                        void (*fn)(TDB_DATA key, TDB_DATA data,
                                   void *private_data),
                        void *private_data)
 {
-       struct ctdbd_connection *conn;
        int ret;
        TDB_DATA key, data;
        struct ctdb_traverse_start t;
-       int cstatus;
-
-       become_root();
-       ret = ctdbd_init_connection(NULL, master->sockname, master->timeout,
-                                   &conn);
-       unbecome_root();
-       if (ret != 0) {
-               DEBUG(0, ("ctdbd_init_connection failed: %s\n",
-                         strerror(ret)));
-               return ret;
-       }
+       int32_t cstatus;
 
        t.db_id = db_id;
        t.srvid = conn->rand_srvid;
@@ -1073,9 +1038,9 @@ int ctdbd_traverse(struct ctdbd_connection *master, 
uint32_t db_id,
        data.dptr = (uint8_t *)&t;
        data.dsize = sizeof(t);
 
-       ret = ctdbd_control(conn, CTDB_CURRENT_NODE,
-                           CTDB_CONTROL_TRAVERSE_START, conn->rand_srvid,
-                           0, data, NULL, NULL, &cstatus);
+       ret = ctdbd_control_local(conn, CTDB_CONTROL_TRAVERSE_START,
+                                 conn->rand_srvid,
+                                 0, data, NULL, NULL, &cstatus);
 
        if ((ret != 0) || (cstatus != 0)) {
                DEBUG(0,("ctdbd_control failed: %s, %d\n", strerror(ret),
@@ -1087,11 +1052,10 @@ int ctdbd_traverse(struct ctdbd_connection *master, 
uint32_t db_id,
                         */
                        ret = EIO;
                }
-               TALLOC_FREE(conn);
                return ret;
        }
 
-       while (True) {
+       while (true) {
                struct ctdb_req_header *hdr = NULL;
                struct ctdb_req_message_old *m;
                struct ctdb_rec_data_old *d;
@@ -1106,7 +1070,6 @@ int ctdbd_traverse(struct ctdbd_connection *master, 
uint32_t db_id,
                if (hdr->operation != CTDB_REQ_MESSAGE) {
                        DEBUG(0, ("Got operation %u, expected a message\n",
                                  (unsigned)hdr->operation));
-                       TALLOC_FREE(conn);
                        return EIO;
                }
 
@@ -1115,7 +1078,6 @@ int ctdbd_traverse(struct ctdbd_connection *master, 
uint32_t db_id,
                if (m->datalen < sizeof(uint32_t) || m->datalen != d->length) {
                        DEBUG(0, ("Got invalid traverse data of length %d\n",
                                  (int)m->datalen));
-                       TALLOC_FREE(conn);
                        return EIO;
                }
 
@@ -1126,14 +1088,12 @@ int ctdbd_traverse(struct ctdbd_connection *master, 
uint32_t db_id,
 
                if (key.dsize == 0 && data.dsize == 0) {
                        /* end of traverse */
-                       TALLOC_FREE(conn);
                        return 0;
                }
 
                if (data.dsize < sizeof(struct ctdb_ltdb_header)) {
                        DEBUG(0, ("Got invalid ltdb header length %d\n",
                                  (int)data.dsize));
-                       TALLOC_FREE(conn);
                        return EIO;
                }
                data.dsize -= sizeof(struct ctdb_ltdb_header);
@@ -1243,7 +1203,7 @@ int ctdbd_register_ips(struct ctdbd_connection *conn,
 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)
+                       int32_t *cstatus)
 {
        return ctdbd_control(conn, CTDB_CURRENT_NODE, opcode, srvid, flags, 
data,
                             mem_ctx, outdata, cstatus);
@@ -1254,7 +1214,7 @@ int ctdb_watch_us(struct ctdbd_connection *conn)
        struct ctdb_notify_data_old reg_data;
        size_t struct_len;
        int ret;
-       int cstatus;
+       int32_t cstatus;
 
        reg_data.srvid = CTDB_SRVID_SAMBA_NOTIFY;
        reg_data.len = 1;
@@ -1278,7 +1238,7 @@ int ctdb_unwatch(struct ctdbd_connection *conn)
 {
        uint64_t srvid = CTDB_SRVID_SAMBA_NOTIFY;
        int ret;
-       int cstatus;
+       int32_t cstatus;
 
        ret = ctdbd_control_local(
                conn, CTDB_CONTROL_DEREGISTER_NOTIFY, conn->rand_srvid, 0,
@@ -1300,8 +1260,8 @@ int ctdbd_probe(const char *sockname, int timeout)
        struct ctdbd_connection *conn = NULL;
        int ret;
 
-       ret = ctdbd_messaging_connection(talloc_tos(), sockname, timeout,
-                                        &conn);
+       ret = ctdbd_init_connection(talloc_tos(), sockname, timeout,
+                                   &conn);
 
        /*
         * We only care if we can connect.
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 93df7ef..1e4df09 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -700,7 +700,7 @@ static int db_ctdb_transaction_commit(struct db_context *db)
        struct db_ctdb_ctx *ctx = talloc_get_type_abort(db->private_data,
                                                        struct db_ctdb_ctx);
        NTSTATUS rets;
-       int status;
+       int32_t status;
        struct db_ctdb_transaction_handle *h = ctx->transaction;
        uint64_t old_seqnum, new_seqnum;
        int ret;
@@ -855,7 +855,7 @@ static NTSTATUS db_ctdb_send_schedule_for_deletion(struct 
db_record *rec)
        int ret;
        struct ctdb_control_schedule_for_deletion *dd;
        TDB_DATA indata;
-       int cstatus;
+       int32_t cstatus;
        struct db_ctdb_rec *crec = talloc_get_type_abort(
                rec->private_data, struct db_ctdb_rec);
 
@@ -884,7 +884,7 @@ static NTSTATUS db_ctdb_send_schedule_for_deletion(struct 
db_record *rec)
 
        if ((ret != 0) || cstatus != 0) {
                DEBUG(1, (__location__ " Error sending local control "
-                         "SCHEDULE_FOR_DELETION: %s, cstatus = %d\n",
+                         "SCHEDULE_FOR_DELETION: %s, cstatus = %"PRIi32"\n",
                          strerror(ret), cstatus));
                if (ret != 0) {
                        status = map_nt_error_from_unix(ret);
@@ -1358,6 +1358,36 @@ static int traverse_persistent_callback_dbwrap(struct 
db_record *rec, void* data
        return traverse_persistent_callback(NULL, rec->key, rec->value, data);
 }
 
+static int db_ctdbd_traverse(uint32_t db_id,
+                            void (*fn)(TDB_DATA key, TDB_DATA data,
+                                       void *private_data),
+                            void *private_data)
+{
+       struct ctdbd_connection *conn;
+       int ret;
+
+       become_root();
+       ret = ctdbd_init_connection(talloc_tos(), lp_ctdbd_socket(),
+                                   lp_ctdb_timeout(), &conn);
+       unbecome_root();
+       if (ret != 0) {
+               DBG_WARNING("ctdbd_init_connection failed: %s\n",
+                           strerror(ret));
+               return ret;
+       }
+
+       ret = ctdbd_traverse(conn, db_id, fn, private_data);
+       TALLOC_FREE(conn);
+
+       if (ret != 0) {
+               DBG_WARNING("ctdbd_traverse failed: %s\n",
+                           strerror(ret));
+               return ret;
+       }
+
+       return 0;
+}
+
 
 static int db_ctdb_traverse(struct db_context *db,
                            int (*fn)(struct db_record *rec,
@@ -1422,8 +1452,7 @@ static int db_ctdb_traverse(struct db_context *db,
                return ret;
        }
 
-       ret = ctdbd_traverse(messaging_ctdbd_connection(), ctx->db_id,
-                            traverse_callback, &state);
+       ret = db_ctdbd_traverse(ctx->db_id, traverse_callback, &state);
        if (ret != 0) {
                return -1;
        }
@@ -1512,8 +1541,7 @@ static int db_ctdb_traverse_read(struct db_context *db,
                return tdb_traverse_read(ctx->wtdb->tdb, 
traverse_persistent_callback_read, &state);
        }
 
-       ret = ctdbd_traverse(messaging_ctdbd_connection(), ctx->db_id,
-                            traverse_read_callback, &state);
+       ret = db_ctdbd_traverse(ctx->db_id, traverse_read_callback, &state);
        if (ret != 0) {
                return -1;
        }
@@ -1552,7 +1580,7 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
        struct ctdbd_connection *conn;
        struct loadparm_context *lp_ctx;
        struct ctdb_db_priority prio;
-       int cstatus;
+       int32_t cstatus;
        int ret;
 
        if (!lp_clustering()) {


-- 
Samba Shared Repository

Reply via email to