From bdc049dfcea9756f4d5a1f2ad6fb0685181f8ad0 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Tue, 29 Nov 2016 12:55:06 +1100 Subject: [PATCH] ctdb-common: Drop CTDB's copy of sys_read() and sys_write() Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs Autobuild-User(master): Amitay Isaacs Autobuild-Date(master): Tue Nov 29 11:22:40 CET 2016 on sn-devel-144 --- ctdb/common/ctdb_io.c | 2 +- ctdb/common/system.h | 3 --- ctdb/common/system_util.c | 34 --------------------------- ctdb/server/ctdb_call.c | 1 + ctdb/server/ctdb_cluster_mutex.c | 2 +- ctdb/server/ctdb_event_helper.c | 1 + ctdb/server/ctdb_lock.c | 2 +- ctdb/server/ctdb_lock_helper.c | 2 ++ ctdb/server/ctdb_logging.c | 2 +- ctdb/server/ctdb_logging_file.c | 3 +-- ctdb/server/ctdb_mutex_fcntl_helper.c | 2 ++ ctdb/server/ctdb_recoverd.c | 1 + ctdb/server/ctdb_recovery_helper.c | 15 +----------- ctdb/server/ctdb_takeover.c | 1 + ctdb/server/ctdb_traverse.c | 1 + ctdb/server/ctdb_update_record.c | 1 + ctdb/server/ctdb_vacuum.c | 2 +- ctdb/server/eventscript.c | 2 +- ctdb/tools/ctdb.c | 1 + ctdb/wscript | 15 ++++++------ 20 files changed, 27 insertions(+), 66 deletions(-) diff --git a/ctdb/common/ctdb_io.c b/ctdb/common/ctdb_io.c index 806c57f6db2..152d535f0e5 100644 --- a/ctdb/common/ctdb_io.c +++ b/ctdb/common/ctdb_io.c @@ -30,11 +30,11 @@ #include "lib/util/dlinklist.h" #include "lib/util/debug.h" +#include "lib/util/sys_rw.h" #include "ctdb_private.h" #include "ctdb_client.h" -#include "common/system.h" #include "common/logging.h" #include "common/common.h" diff --git a/ctdb/common/system.h b/ctdb/common/system.h index 2007814ce3b..2875760806a 100644 --- a/ctdb/common/system.h +++ b/ctdb/common/system.h @@ -60,9 +60,6 @@ void lockdown_memory(bool valgrinding); 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); - void ctdb_wait_for_process_to_exit(pid_t pid); int ctdb_parse_connections(FILE *fp, TALLOC_CTX *mem_ctx, diff --git a/ctdb/common/system_util.c b/ctdb/common/system_util.c index 9e897c21c4b..57452aa6a1a 100644 --- a/ctdb/common/system_util.c +++ b/ctdb/common/system_util.c @@ -349,40 +349,6 @@ void mkdir_p_or_die(const char *dir, int mode) } } -/* 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; -} - void ctdb_wait_for_process_to_exit(pid_t pid) { while (kill(pid, 0) == 0 || errno != ESRCH) { diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c index 3478419fd4c..670491132ab 100644 --- a/ctdb/server/ctdb_call.c +++ b/ctdb/server/ctdb_call.c @@ -30,6 +30,7 @@ #include "lib/util/dlinklist.h" #include "lib/util/debug.h" #include "lib/util/samba_util.h" +#include "lib/util/sys_rw.h" #include "lib/util/util_process.h" #include "ctdb_private.h" diff --git a/ctdb/server/ctdb_cluster_mutex.c b/ctdb/server/ctdb_cluster_mutex.c index 34484913ce1..93977463e0c 100644 --- a/ctdb/server/ctdb_cluster_mutex.c +++ b/ctdb/server/ctdb_cluster_mutex.c @@ -28,12 +28,12 @@ #include "lib/util/time.h" #include "lib/util/strv.h" #include "lib/util/strv_util.h" +#include "lib/util/sys_rw.h" #include "lib/util/blocking.h" #include "ctdb_private.h" #include "common/common.h" #include "common/logging.h" -#include "common/system.h" #include "ctdb_cluster_mutex.h" diff --git a/ctdb/server/ctdb_event_helper.c b/ctdb/server/ctdb_event_helper.c index 7b6e8434695..5e48b9ccfda 100644 --- a/ctdb/server/ctdb_event_helper.c +++ b/ctdb/server/ctdb_event_helper.c @@ -25,6 +25,7 @@ #include #include "lib/util/blocking.h" +#include "lib/util/sys_rw.h" #include "ctdb_private.h" diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c index 3a58711bc4b..139ead02eac 100644 --- a/ctdb/server/ctdb_lock.c +++ b/ctdb/server/ctdb_lock.c @@ -28,10 +28,10 @@ #include "lib/util/dlinklist.h" #include "lib/util/debug.h" #include "lib/util/samba_util.h" +#include "lib/util/sys_rw.h" #include "ctdb_private.h" -#include "common/system.h" #include "common/common.h" #include "common/logging.h" diff --git a/ctdb/server/ctdb_lock_helper.c b/ctdb/server/ctdb_lock_helper.c index 9ac7c0cea13..d7f8fe146f7 100644 --- a/ctdb/server/ctdb_lock_helper.c +++ b/ctdb/server/ctdb_lock_helper.c @@ -24,6 +24,8 @@ #include #include +#include "lib/util/sys_rw.h" + #include "protocol/protocol.h" #include "common/system.h" diff --git a/ctdb/server/ctdb_logging.c b/ctdb/server/ctdb_logging.c index fbafe9be340..87dbd3be8ea 100644 --- a/ctdb/server/ctdb_logging.c +++ b/ctdb/server/ctdb_logging.c @@ -29,12 +29,12 @@ #include "lib/util/dlinklist.h" #include "lib/util/debug.h" #include "lib/util/blocking.h" +#include "lib/util/sys_rw.h" #include "lib/util/time.h" #include "ctdb_private.h" #include "ctdb_client.h" -#include "common/system.h" #include "common/common.h" #include "common/logging.h" diff --git a/ctdb/server/ctdb_logging_file.c b/ctdb/server/ctdb_logging_file.c index 488de263a80..fc6720b942e 100644 --- a/ctdb/server/ctdb_logging_file.c +++ b/ctdb/server/ctdb_logging_file.c @@ -25,13 +25,12 @@ #include #include "lib/util/debug.h" +#include "lib/util/sys_rw.h" #include "lib/util/time_basic.h" #include "ctdb_private.h" #include "ctdb_client.h" -#include "common/system.h" - #define CTDB_LOG_FILE_PREFIX "file" struct file_state { diff --git a/ctdb/server/ctdb_mutex_fcntl_helper.c b/ctdb/server/ctdb_mutex_fcntl_helper.c index 87358beb234..7b66c78cd8e 100644 --- a/ctdb/server/ctdb_mutex_fcntl_helper.c +++ b/ctdb/server/ctdb_mutex_fcntl_helper.c @@ -21,6 +21,8 @@ #include "system/filesys.h" #include "system/network.h" +#include "lib/util/sys_rw.h" + /* protocol.h is just needed for ctdb_sock_addr, which is used in system.h */ #include "protocol/protocol.h" #include "common/system.h" diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index 68618333ad7..c310102ed86 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -32,6 +32,7 @@ #include "lib/util/dlinklist.h" #include "lib/util/debug.h" #include "lib/util/samba_util.h" +#include "lib/util/sys_rw.h" #include "lib/util/util_process.h" #include "ctdb_private.h" diff --git a/ctdb/server/ctdb_recovery_helper.c b/ctdb/server/ctdb_recovery_helper.c index 7dfb707b458..09bc9897893 100644 --- a/ctdb/server/ctdb_recovery_helper.c +++ b/ctdb/server/ctdb_recovery_helper.c @@ -27,6 +27,7 @@ #include #include "lib/tdb_wrap/tdb_wrap.h" +#include "lib/util/sys_rw.h" #include "lib/util/time.h" #include "lib/util/tevent_unix.h" @@ -55,20 +56,6 @@ static void LOG(const char *fmt, ...) * Utility functions */ -static 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; -} - static bool generic_recv(struct tevent_req *req, int *perr) { int err; diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index f71c5fbab55..c2ae1df21bf 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -30,6 +30,7 @@ #include "lib/util/dlinklist.h" #include "lib/util/debug.h" #include "lib/util/samba_util.h" +#include "lib/util/sys_rw.h" #include "lib/util/util_process.h" #include "ctdb_private.h" diff --git a/ctdb/server/ctdb_traverse.c b/ctdb/server/ctdb_traverse.c index 11a5385ba91..1f9504224ad 100644 --- a/ctdb/server/ctdb_traverse.c +++ b/ctdb/server/ctdb_traverse.c @@ -30,6 +30,7 @@ #include "lib/util/dlinklist.h" #include "lib/util/debug.h" #include "lib/util/samba_util.h" +#include "lib/util/sys_rw.h" #include "lib/util/util_process.h" #include "ctdb_private.h" diff --git a/ctdb/server/ctdb_update_record.c b/ctdb/server/ctdb_update_record.c index 56f3b837a4b..63d1b5c1212 100644 --- a/ctdb/server/ctdb_update_record.c +++ b/ctdb/server/ctdb_update_record.c @@ -28,6 +28,7 @@ #include "lib/tdb_wrap/tdb_wrap.h" #include "lib/util/debug.h" #include "lib/util/samba_util.h" +#include "lib/util/sys_rw.h" #include "lib/util/util_process.h" #include "ctdb_private.h" diff --git a/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c index 174ccb23309..5ffab1deb80 100644 --- a/ctdb/server/ctdb_vacuum.c +++ b/ctdb/server/ctdb_vacuum.c @@ -31,13 +31,13 @@ #include "lib/util/dlinklist.h" #include "lib/util/debug.h" #include "lib/util/samba_util.h" +#include "lib/util/sys_rw.h" #include "lib/util/util_process.h" #include "ctdb_private.h" #include "ctdb_client.h" #include "common/rb_tree.h" -#include "common/system.h" #include "common/common.h" #include "common/logging.h" diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c index 86d37d901e2..8f6ffd18829 100644 --- a/ctdb/server/eventscript.c +++ b/ctdb/server/eventscript.c @@ -31,11 +31,11 @@ #include "lib/util/dlinklist.h" #include "lib/util/debug.h" #include "lib/util/samba_util.h" +#include "lib/util/sys_rw.h" #include "ctdb_private.h" #include "common/rb_tree.h" -#include "common/system.h" #include "common/common.h" #include "common/logging.h" diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index a1024ae33b5..59719757df9 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -32,6 +32,7 @@ #include "ctdb_version.h" #include "lib/util/debug.h" #include "lib/util/samba_util.h" +#include "lib/util/sys_rw.h" #include "common/db_hash.h" #include "common/logging.h" diff --git a/ctdb/wscript b/ctdb/wscript index a69e57b2a82..f4bccefd6a3 100644 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -412,7 +412,8 @@ def build(bld): ctdb_update_record.c ctdb_lock.c ctdb_fork.c'''), includes='include', - deps='ctdb-ipalloc replace popt talloc tevent tdb talloc_report') + deps='''ctdb-ipalloc replace sys_rw + popt talloc tevent tdb talloc_report''') bld.SAMBA_BINARY('ctdbd', source='', @@ -425,7 +426,7 @@ def build(bld): bld.SAMBA_BINARY('ctdb', source='tools/ctdb.c', deps='''ctdb-client2 ctdb-protocol ctdb-util ctdb-system - samba-util popt''', + samba-util sys_rw popt''', install_path='${BINDIR}', manpages='ctdb.1') @@ -444,25 +445,25 @@ def build(bld): bld.SAMBA_BINARY('ctdb_lock_helper', source='server/ctdb_lock_helper.c', - deps='samba-util ctdb-system talloc tdb', + deps='samba-util sys_rw ctdb-system talloc tdb', includes='include', install_path='${CTDB_HELPER_BINDIR}') bld.SAMBA_BINARY('ctdb_event_helper', source='server/ctdb_event_helper.c', includes='include', - deps='samba-util ctdb-system replace tdb', + deps='samba-util sys_rw ctdb-system replace tdb', install_path='${CTDB_HELPER_BINDIR}') bld.SAMBA_BINARY('ctdb_recovery_helper', source='server/ctdb_recovery_helper.c', deps='''ctdb-client2 ctdb-protocol ctdb-util - samba-util replace tdb''', + samba-util sys_rw replace tdb''', install_path='${CTDB_HELPER_BINDIR}') bld.SAMBA_BINARY('ctdb_mutex_fcntl_helper', source='server/ctdb_mutex_fcntl_helper.c', - deps='ctdb-system', + deps='sys_rw ctdb-system', includes='include', install_path='${CTDB_HELPER_BINDIR}') @@ -739,7 +740,7 @@ def build(bld): bld.SAMBA_BINARY('ibwrapper_test', source='ib/ibwrapper_test.c', includes='include', - deps='replace talloc ctdb-client ctdb-common' + + deps='replace talloc ctdb-client ctdb-common sys_rw' + ib_deps, install_path='${CTDB_TEST_LIBEXECDIR}')