[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Wed Aug 20 23:12:04 MDT 2014


The branch, master has been updated
       via  e411873 ctdb-build: Avoid unused variable warning in output from rpcgen
       via  6fd3ce5 ctdb-daemon: Fix some strict-aliasing warnings
       via  2807b18 ctdb-util: Fix warning about ignored result from system()
       via  c1558ad ctdb: Use sys_read() and sys_write() to ensure correct signal interaction
       via  fcd6ee1 ctdb-common: Copy functions sys_read() and sys_write() from source3
       via  72fa984 ctdb-tools: Be more helpful when CTDB CLI tool is run on unconfigured node
       via  26a02a6 ctdb-tools: Factor out new function find_node_xpnn() from control_xpnn()
      from  47e7440 replace: Remove unused item returned by FAILED()

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


- Log -----------------------------------------------------------------
commit e4118730d1eb84959e10f4ce4995ce75d0ba7365
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 4 14:52:00 2014 +1000

    ctdb-build: Avoid unused variable warning in output from rpcgen
    
      default/ctdb/utils/smnotify/gen_xdr.c: In function ‘xdr_status’:
      default/ctdb/utils/smnotify/gen_xdr.c:11:20: warning: unused variable ‘buf’ [-Wunused-variable]
        register int32_t *buf;
                          ^
    
    When generating the code, change it to assign the variable to itself.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Thu Aug 21 07:11:02 CEST 2014 on sn-devel-104

commit 6fd3ce53914c5c5aa79b972b42258c722b227b88
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 4 14:50:17 2014 +1000

    ctdb-daemon: Fix some strict-aliasing warnings
    
    Seeing these with -Wall:
    
      ../server/ctdb_call.c:1117:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
         record_flags = *(uint32_t *)&c->data[c->keylen + c->datalen];
         ^
    
    memcpy() seems to be the easiest way to get fix these.  The
    alternative would be to use unmarshalling functions.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 2807b185f438c40544d4fd133bc386e411b12d0c
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jul 30 21:10:01 2014 +1000

    ctdb-util: Fix warning about ignored result from system()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit c1558adeaa980fb4bd6177d36250ec8262e9b9fe
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jul 30 21:03:53 2014 +1000

    ctdb: Use sys_read() and sys_write() to ensure correct signal interaction
    
    ... and avoid compiler warnings in some cases.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit fcd6ee1eac8627e75f72019027513cc46429a3a9
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jul 30 20:50:59 2014 +1000

    ctdb-common: Copy functions sys_read() and sys_write() from source3
    
    We really should extricate these from source3 and into some common
    code.  However, just copy them for now to help get rid of a lot of
    warnings.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 72fa984423b77eaddb16b63e6c3857600e054836
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 21 09:26:39 2014 +1000

    ctdb-tools: Be more helpful when CTDB CLI tool is run on unconfigured node
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 26a02a64cda0501d57db686dee61fda0846083ee
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Aug 8 10:43:44 2014 +1000

    ctdb-tools: Factor out new function find_node_xpnn() from control_xpnn()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

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

Summary of changes:
 ctdb/common/ctdb_io.c               |   10 +++--
 ctdb/common/ctdb_util.c             |   10 ++++--
 ctdb/common/system_util.c           |   34 ++++++++++++++++++++
 ctdb/include/ctdb_private.h         |    3 ++
 ctdb/server/ctdb_call.c             |   10 +++--
 ctdb/server/ctdb_event_helper.c     |    2 +-
 ctdb/server/ctdb_lock.c             |    2 +-
 ctdb/server/ctdb_lock_helper.c      |    2 +-
 ctdb/server/ctdb_logging.c          |   16 +++++-----
 ctdb/server/ctdb_recover.c          |    6 ++--
 ctdb/server/ctdb_recoverd.c         |    4 +-
 ctdb/server/ctdb_takeover.c         |    4 +-
 ctdb/server/ctdb_traverse.c         |    6 ++--
 ctdb/server/ctdb_update_record.c    |    4 +-
 ctdb/server/ctdb_vacuum.c           |    4 +-
 ctdb/server/eventscript.c           |    2 +-
 ctdb/tests/src/ctdb_porting_tests.c |    2 +-
 ctdb/tools/ctdb.c                   |   59 +++++++++++++++++++++++------------
 ctdb/wscript                        |    4 ++-
 19 files changed, 125 insertions(+), 59 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/common/ctdb_io.c b/ctdb/common/ctdb_io.c
index b5f8a72..467ec9a 100644
--- a/ctdb/common/ctdb_io.c
+++ b/ctdb/common/ctdb_io.c
@@ -196,7 +196,9 @@ static void queue_io_read(struct ctdb_queue *queue)
 	}
 
 	if (num_ready > 0) {
-		nread = read(queue->fd, queue->buffer.data + queue->buffer.length, num_ready);
+		nread = sys_read(queue->fd,
+				 queue->buffer.data + queue->buffer.length,
+				 num_ready);
 		if (nread <= 0) {
 			DEBUG(DEBUG_ERR, ("read error nread=%d\n", (int)nread));
 			goto failed;
@@ -230,9 +232,9 @@ static void queue_io_write(struct ctdb_queue *queue)
 		struct ctdb_queue_pkt *pkt = queue->out_queue;
 		ssize_t n;
 		if (queue->ctdb->flags & CTDB_FLAG_TORTURE) {
-			n = write(queue->fd, pkt->data, 1);
+			n = sys_write(queue->fd, pkt->data, 1);
 		} else {
-			n = write(queue->fd, pkt->data, pkt->length);
+			n = sys_write(queue->fd, pkt->data, pkt->length);
 		}
 
 		if (n == -1 && errno != EAGAIN && errno != EWOULDBLOCK) {
@@ -308,7 +310,7 @@ int ctdb_queue_send(struct ctdb_queue *queue, uint8_t *data, uint32_t length)
 	   queue overhead. This relies on non-blocking sockets */
 	if (queue->out_queue == NULL && queue->fd != -1 &&
 	    !(queue->ctdb->flags & CTDB_FLAG_TORTURE)) {
-		ssize_t n = write(queue->fd, data, length2);
+		ssize_t n = sys_write(queue->fd, data, length2);
 		if (n == -1 && errno != EAGAIN && errno != EWOULDBLOCK) {
 			talloc_free(queue->fde);
 			queue->fde = NULL;
diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c
index c4ac583..b9b0ad7 100644
--- a/ctdb/common/ctdb_util.c
+++ b/ctdb/common/ctdb_util.c
@@ -73,7 +73,7 @@ void ctdb_die(struct ctdb_context *ctdb, const char *msg)
  */
 void ctdb_external_trace(void)
 {
-
+	int ret;
 	const char * t = getenv("CTDB_EXTERNAL_TRACE");
 	char * cmd;
 
@@ -83,7 +83,11 @@ void ctdb_external_trace(void)
 
 	cmd = talloc_asprintf(NULL, "%s %lu", t, (unsigned long) getpid());
 	DEBUG(DEBUG_WARNING,("begin external trace: %s\n", cmd));
-	system(cmd);
+	ret = system(cmd);
+	if (ret == -1) {
+		DEBUG(DEBUG_ERR,
+		      ("external trace command \"%s\" failed\n", cmd));
+	}
 	DEBUG(DEBUG_WARNING,("end external trace: %s\n", cmd));
 	talloc_free(cmd);
 }
@@ -323,7 +327,7 @@ struct ctdb_rec_data *ctdb_marshall_loop_next(struct ctdb_marshall_buffer *m, st
 		if (r->datalen < sizeof(*header)) {
 			return NULL;
 		}
-		*header = *(struct ctdb_ltdb_header *)&r->data[r->keylen];
+		memcpy(header, &r->data[r->keylen], sizeof(*header));
 	}
 
 	return r;
diff --git a/ctdb/common/system_util.c b/ctdb/common/system_util.c
index fe0f403..344e7d7 100644
--- a/ctdb/common/system_util.c
+++ b/ctdb/common/system_util.c
@@ -369,3 +369,37 @@ void mkdir_p_or_die(const char *dir, int mode)
 		exit(1);
 	}
 }
+
+/* A read wrapper that will deal with EINTR.  For now, copied from
+ * source3/lib/system.c
+ */
+ssize_t sys_read(int fd, void *buf, size_t count)
+{
+        ssize_t ret;
+
+        do {
+                ret = read(fd, buf, count);
+#if defined(EWOULDBLOCK)
+        } while (ret == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK));
+#else
+        } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
+#endif
+        return ret;
+}
+
+/* A write wrapper that will deal with EINTR.  For now, copied from
+ * source3/lib/system.c
+ */
+ssize_t sys_write(int fd, const void *buf, size_t count)
+{
+        ssize_t ret;
+
+        do {
+                ret = write(fd, buf, count);
+#if defined(EWOULDBLOCK)
+        } while (ret == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK));
+#else
+        } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
+#endif
+        return ret;
+}
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 416cf56..36ebe70 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -1607,4 +1607,7 @@ struct lock_request *ctdb_lock_alldb(struct ctdb_context *ctdb,
 int mkdir_p(const char *dir, int mode);
 void mkdir_p_or_die(const char *dir, int mode);
 
+ssize_t sys_read(int fd, void *buf, size_t count);
+ssize_t sys_write(int fd, const void *buf, size_t count);
+
 #endif
diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c
index a4fa03d..901e585 100644
--- a/ctdb/server/ctdb_call.c
+++ b/ctdb/server/ctdb_call.c
@@ -437,7 +437,8 @@ void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr
 	len = offsetof(struct ctdb_req_dmaster, data) + key.dsize + data.dsize
 			+ sizeof(uint32_t);
 	if (len <= c->hdr.length) {
-		record_flags = *(uint32_t *)&c->data[c->keylen + c->datalen];
+		memcpy(&record_flags, &c->data[c->keylen + c->datalen],
+		       sizeof(record_flags));
 	}
 
 	ctdb_db = find_ctdb_db(ctdb, c->db_id);
@@ -1114,7 +1115,8 @@ void ctdb_reply_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 	len = offsetof(struct ctdb_reply_dmaster, data) + key.dsize + data.dsize
 		+ sizeof(uint32_t);
 	if (len <= c->hdr.length) {
-		record_flags = *(uint32_t *)&c->data[c->keylen + c->datalen];
+		memcpy(&record_flags, &c->data[c->keylen + c->datalen],
+		       sizeof(record_flags));
 	}
 
 	ret = ctdb_ltdb_lock_requeue(ctdb_db, key, hdr,
@@ -1457,7 +1459,7 @@ static void revokechild_handler(struct event_context *ev, struct fd_event *fde,
 	int ret;
 	char c;
 
-	ret = read(rc->fd[0], &c, 1);
+	ret = sys_read(rc->fd[0], &c, 1);
 	if (ret != 1) {
 		DEBUG(DEBUG_ERR,("Failed to read status from revokechild. errno:%d\n", errno));
 		rc->status = -1;
@@ -1675,7 +1677,7 @@ int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb, struct ctdb_db_contex
 		c = ctdb_revoke_all_delegations(ctdb, ctdb_db, tdata, key, header, data);
 
 child_finished:
-		write(rc->fd[1], &c, 1);
+		sys_write(rc->fd[1], &c, 1);
 		/* make sure we die when our parent dies */
 		while (ctdb_kill(ctdb, parent, 0) == 0 || errno != ESRCH) {
 			sleep(5);
diff --git a/ctdb/server/ctdb_event_helper.c b/ctdb/server/ctdb_event_helper.c
index 238103a..9ff763c 100644
--- a/ctdb/server/ctdb_event_helper.c
+++ b/ctdb/server/ctdb_event_helper.c
@@ -123,7 +123,7 @@ int main(int argc, char *argv[])
 		if (output == ENOENT || output == ENOEXEC) {
 			output = -output;
 		}
-		write(write_fd, &output, sizeof(output));
+		sys_write(write_fd, &output, sizeof(output));
 		exit(output);
 	}
 
diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c
index 72352af..93137df 100644
--- a/ctdb/server/ctdb_lock.c
+++ b/ctdb/server/ctdb_lock.c
@@ -443,7 +443,7 @@ static void ctdb_lock_handler(struct tevent_context *ev,
 	}
 
 	/* Read the status from the child process */
-	if (read(lock_ctx->fd[0], &c, 1) != 1) {
+	if (sys_read(lock_ctx->fd[0], &c, 1) != 1) {
 		locked = false;
 	} else {
 		locked = (c == 0 ? true : false);
diff --git a/ctdb/server/ctdb_lock_helper.c b/ctdb/server/ctdb_lock_helper.c
index 709130c..d831a2d 100644
--- a/ctdb/server/ctdb_lock_helper.c
+++ b/ctdb/server/ctdb_lock_helper.c
@@ -26,7 +26,7 @@ static char *progname = NULL;
 
 static void send_result(int fd, char result)
 {
-	write(fd, &result, 1);
+	sys_write(fd, &result, 1);
 	if (result == 1) {
 		exit(1);
 	}
diff --git a/ctdb/server/ctdb_logging.c b/ctdb/server/ctdb_logging.c
index f22c9f3..9f6f3b5 100644
--- a/ctdb/server/ctdb_logging.c
+++ b/ctdb/server/ctdb_logging.c
@@ -129,7 +129,7 @@ int start_syslog_daemon(struct ctdb_context *ctdb)
 		set_close_on_exec(state->fd[0]);
 
 		close(startup_fd[1]);
-		n = read(startup_fd[0], &dummy, sizeof(dummy));
+		n = sys_read(startup_fd[0], &dummy, sizeof(dummy));
 		close(startup_fd[0]);
 		if (n < sizeof(dummy)) {
 			return -1;
@@ -182,7 +182,7 @@ int start_syslog_daemon(struct ctdb_context *ctdb)
 
 	/* Tell parent that we're up */
 	ret = 0;
-	write(startup_fd[1], &ret, sizeof(ret));
+	sys_write(startup_fd[1], &ret, sizeof(ret));
 	close(startup_fd[1]);
 
 	event_loop_wait(ctdb->ev);
@@ -304,7 +304,7 @@ static void ctdb_logfile_log(const char *format, va_list ap)
 	if (ret == -1) {
 		const char *errstr = "vasprintf failed\n";
 
-		write(log_state->fd, errstr, strlen(errstr));
+		sys_write(log_state->fd, errstr, strlen(errstr));
 		return;
 	}
 
@@ -319,11 +319,11 @@ static void ctdb_logfile_log(const char *format, va_list ap)
 	free(s);
 	if (ret == -1) {
 		const char *errstr = "asprintf failed\n";
-		write(log_state->fd, errstr, strlen(errstr));
+		sys_write(log_state->fd, errstr, strlen(errstr));
 		return;
 	}
 	if (s2) {
-		write(log_state->fd, s2, strlen(s2));
+		sys_write(log_state->fd, s2, strlen(s2));
 		free(s2);
 	}
 }
@@ -337,12 +337,12 @@ static void ctdb_logfile_log_add(const char *format, va_list ap)
 	if (ret == -1) {
 		const char *errstr = "vasprintf failed\n";
 
-		write(log_state->fd, errstr, strlen(errstr));
+		sys_write(log_state->fd, errstr, strlen(errstr));
 		return;
 	}
 
 	if (s) {
-		write(log_state->fd, s, strlen(s));
+		sys_write(log_state->fd, s, strlen(s));
 		free(s);
 	}
 }
@@ -424,7 +424,7 @@ static void ctdb_log_handler(struct event_context *ev, struct fd_event *fde,
 		return;
 	}
 
-	n = read(log->pfd, &log->buf[log->buf_used],
+	n = sys_read(log->pfd, &log->buf[log->buf_used],
 		 sizeof(log->buf) - log->buf_used);
 	if (n > 0) {
 		log->buf_used += n;
diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c
index ecf3aba..d45b7f6 100644
--- a/ctdb/server/ctdb_recover.c
+++ b/ctdb/server/ctdb_recover.c
@@ -534,7 +534,7 @@ static void set_recmode_handler(struct event_context *ev, struct fd_event *fde,
 	   the file   which at this time SHOULD be locked by the recovery
 	   daemon on the recmaster
 	*/		
-	ret = read(state->fd[0], &c, 1);
+	ret = sys_read(state->fd[0], &c, 1);
 	if (ret != 1 || c != 0) {
 		ctdb_request_control_reply(state->ctdb, state->c, NULL, -1, "managed to lock reclock file from inside daemon");
 		talloc_free(state);
@@ -679,11 +679,11 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
 			cc = 1;
 		}
 
-		write(state->fd[1], &cc, 1);
+		sys_write(state->fd[1], &cc, 1);
 		/* make sure we die when our parent dies */
 		while (ctdb_kill(ctdb, parent, 0) == 0 || errno != ESRCH) {
 			sleep(5);
-			write(state->fd[1], &cc, 1);
+			sys_write(state->fd[1], &cc, 1);
 		}
 		_exit(0);
 	}
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index 50709a6..9b553b7 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -3383,7 +3383,7 @@ static void reclock_child_handler(struct event_context *ev, struct fd_event *fde
 	talloc_free(state->te);
 	state->te = NULL;
 
-	ret = read(state->fd[0], &c, 1);
+	ret = sys_read(state->fd[0], &c, 1);
 	if (ret != 1 || c != RECLOCK_OK) {
 		DEBUG(DEBUG_ERR,(__location__ " reclock child process returned error %d\n", c));
 		state->status = RECLOCK_FAILED;
@@ -3445,7 +3445,7 @@ static int check_recovery_lock(struct ctdb_context *ctdb)
 			cc = RECLOCK_FAILED;
 		}
 
-		write(state->fd[1], &cc, 1);
+		sys_write(state->fd[1], &cc, 1);
 		/* make sure we die when our parent dies */
 		while (ctdb_kill(ctdb, parent, 0) == 0 || errno != ESRCH) {
 			sleep(5);
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
index 8449288..a3b9592 100644
--- a/ctdb/server/ctdb_takeover.c
+++ b/ctdb/server/ctdb_takeover.c
@@ -4471,7 +4471,7 @@ static void ctdb_reloadips_child_handler(struct event_context *ev, struct fd_eve
 	char res;
 	int ret;
 
-	ret = read(h->fd[0], &res, 1);
+	ret = sys_read(h->fd[0], &res, 1);
 	if (ret < 1 || res != 0) {
 		DEBUG(DEBUG_ERR, (__location__ " Reloadips child process returned error\n"));
 		res = 1;
@@ -4708,7 +4708,7 @@ int32_t ctdb_control_reload_public_ips(struct ctdb_context *ctdb, struct ctdb_re
 			}
 		}
 
-		write(h->fd[1], &res, 1);
+		sys_write(h->fd[1], &res, 1);
 		/* make sure we die when our parent dies */
 		while (ctdb_kill(ctdb, parent, 0) == 0 || errno != ESRCH) {
 			sleep(5);
diff --git a/ctdb/server/ctdb_traverse.c b/ctdb/server/ctdb_traverse.c
index 99e7e8f..64f2530 100644
--- a/ctdb/server/ctdb_traverse.c
+++ b/ctdb/server/ctdb_traverse.c
@@ -62,7 +62,7 @@ static void ctdb_traverse_child_handler(struct tevent_context *ev, struct tevent
 	ssize_t n;
 
 	/* Read the number of records sent by traverse child */
-	n = read(h->fd[0], &res, sizeof(res));
+	n = sys_read(h->fd[0], &res, sizeof(res));
 	if (n < 0 || n != sizeof(res)) {
 		/* Traverse child failed */
 		DEBUG(DEBUG_ERR, ("Local traverse failed db:%s reqid:%d\n",
@@ -213,7 +213,7 @@ static struct ctdb_traverse_local_handle *ctdb_traverse_local(struct ctdb_db_con
 		d = ctdb_marshall_record(h, h->reqid, tdb_null, NULL, tdb_null);
 		if (d == NULL) {
 			res = 0;
-			write(h->fd[1], &res, sizeof(int));
+			sys_write(h->fd[1], &res, sizeof(int));
 			_exit(0);
 		}
 
@@ -243,7 +243,7 @@ static struct ctdb_traverse_local_handle *ctdb_traverse_local(struct ctdb_db_con
 			}
 		}
 
-		write(h->fd[1], &res, sizeof(res));
+		sys_write(h->fd[1], &res, sizeof(res));
 
 		while (ctdb_kill(ctdb, parent, 0) == 0 || errno != ESRCH) {
 			sleep(5);
diff --git a/ctdb/server/ctdb_update_record.c b/ctdb/server/ctdb_update_record.c
index 7bfa08a..81e3625 100644
--- a/ctdb/server/ctdb_update_record.c
+++ b/ctdb/server/ctdb_update_record.c
@@ -191,7 +191,7 @@ static void childwrite_handler(struct event_context *ev, struct fd_event *fde,
 
 	talloc_set_destructor(h, NULL);
 
-	ret = read(h->fd[0], &c, 1);
+	ret = sys_read(h->fd[0], &c, 1);
 	if (ret < 1) {
 		DEBUG(DEBUG_ERR, (__location__ " Read returned %d. Childwrite failed\n", ret));
 		c = 1;
@@ -258,7 +258,7 @@ static struct childwrite_handle *ctdb_childwrite(
 			c = 1;
 		}
 
-		write(result->fd[1], &c, 1);
+		sys_write(result->fd[1], &c, 1);
 
 		/* make sure we die when our parent dies */
 		while (ctdb_kill(ctdb_db->ctdb, parent, 0) == 0 || errno != ESRCH) {
diff --git a/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c
index c3054bf..5013339 100644
--- a/ctdb/server/ctdb_vacuum.c
+++ b/ctdb/server/ctdb_vacuum.c
@@ -1411,7 +1411,7 @@ static void vacuum_child_handler(struct event_context *ev, struct fd_event *fde,
 	DEBUG(DEBUG_INFO,("Vacuuming child process %d finished for db %s\n", child_ctx->child_pid, child_ctx->vacuum_handle->ctdb_db->db_name));
 	child_ctx->child_pid = -1;
 
-	ret = read(child_ctx->fd[0], &c, 1);
+	ret = sys_read(child_ctx->fd[0], &c, 1);
 	if (ret != 1 || c != 0) {
 		child_ctx->status = VACUUM_ERROR;
 		DEBUG(DEBUG_ERR, ("A vacuum child process failed with an error for database %s. ret=%d c=%d\n", child_ctx->vacuum_handle->ctdb_db->db_name, ret, c));
@@ -1503,7 +1503,7 @@ ctdb_vacuum_event(struct event_context *ev, struct timed_event *te,
 		}
 		cc = ctdb_vacuum_and_repack_db(ctdb_db, full_vacuum_run);
 
-		write(child_ctx->fd[1], &cc, 1);
+		sys_write(child_ctx->fd[1], &cc, 1);
 		_exit(0);
 	}
 
diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c
index 604b8de..447a83c 100644
--- a/ctdb/server/eventscript.c
+++ b/ctdb/server/eventscript.c
@@ -364,7 +364,7 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
 		return;
 	}
 
-	r = read(state->fd[0], &current->status, sizeof(current->status));
+	r = sys_read(state->fd[0], &current->status, sizeof(current->status));
 	if (r < 0) {
 		current->status = -errno;
 	} else if (r != sizeof(current->status)) {
diff --git a/ctdb/tests/src/ctdb_porting_tests.c b/ctdb/tests/src/ctdb_porting_tests.c
index 063c6da..6752f84 100644
--- a/ctdb/tests/src/ctdb_porting_tests.c
+++ b/ctdb/tests/src/ctdb_porting_tests.c
@@ -141,7 +141,7 @@ static int socket_client_connect(void)
 
 static int socket_client_write(int client)
 {
-	if (write(client, "\0", 1) == -1) {
+	if (sys_write(client, "\0", 1) == -1) {
 		DEBUG(DEBUG_CRIT,("Unable to write to client socket: %s\n", strerror(errno)));
 		return -1;
 	}
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 3b158fd..ca79363 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -885,14 +885,12 @@ static struct pnn_node *read_nodes_file(TALLOC_CTX *mem_ctx)
   discover the pnn by loading the nodes file and try to bind to all
   addresses one at a time until the ip address is found.
  */
-static int control_xpnn(struct ctdb_context *ctdb, int argc, const char **argv)
+static int find_node_xpnn(void)
 {
 	TALLOC_CTX *mem_ctx = talloc_new(NULL);
 	struct pnn_node *pnn_nodes;
 	struct pnn_node *pnn_node;
 
-	assert_single_node_only();
-
 	pnn_nodes = read_nodes_file(mem_ctx);
 	if (pnn_nodes == NULL) {
 		DEBUG(DEBUG_ERR,("Failed to read nodes file\n"));
@@ -902,9 +900,8 @@ static int control_xpnn(struct ctdb_context *ctdb, int argc, const char **argv)
 
 	for(pnn_node=pnn_nodes;pnn_node;pnn_node=pnn_node->next) {
 		if (ctdb_sys_have_ip(&pnn_node->addr)) {
-			printf("PNN:%d\n", pnn_node->pnn);
 			talloc_free(mem_ctx);
-			return 0;
+			return pnn_node->pnn;
 		}
 	}
 
@@ -913,6 +910,21 @@ static int control_xpnn(struct ctdb_context *ctdb, int argc, const char **argv)
 	return -1;
 }
 
+static int control_xpnn(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+	uint32_t pnn;
+
+	assert_single_node_only();
+
+	pnn = find_node_xpnn();
+	if (pnn == -1) {
+		return -1;
+	}
+
+	printf("PNN:%d\n", pnn);
+	return 0;
+}
+
 /* Helpers for ctdb status
  */
 static bool is_partially_online(struct ctdb_context *ctdb, struct ctdb_node_and_flags *node)


-- 
Samba Shared Repository


More information about the samba-cvs mailing list