[SCM] Samba Shared Repository - branch master updated

Martin Schwenke martins at samba.org
Sat Jul 28 05:27:03 UTC 2018


The branch, master has been updated
       via  a44e698 ctdb-docs: Replace obsolete reference to CTDB_DEBUG_HUNG_SCRIPT option
       via  be43e08 ctdb-common: Fix the TCP packet length check
       via  3047202 ctdb-tests: Strip all spaces from od output
       via  6f5ed2b ctdb-tests: Fix a typo
       via  65cc36f ctdb-tests: Use errcode to translate ETIMEDOUT
       via  22c3078 ctdb-tests: Replace md5sum with posix cksum
       via  07844c2 ctdb-tests: Use portable wc -c instead of stat -c "%s"
       via  96d5c7d ctdb-scripts: date "+%N" is non-portable
       via  68542db ctdb-tests: Simplify pattern matching for ctime output
       via  4152e98 ctdb-tests: Do not try to match pstree output in eventd tests
       via  3bf753e ctdb-common: Add fd argument to ctdb_connection_list_read()
       via  c9b42d2 ctdb-protocol: Avoid fgets in ctdb_connection_list_read
       via  c7041b0 ctdb-common: Add line based I/O
       via  0273171 ctdb-tests: Porting tests should ignore unsupported features
       via  23952c9 ctdb-tests: Use sigcode to match signals
       via  b0028dd ctdb-tests: Add signal code matching utility
       via  b7dbe9f ctdb-tests: Add ps output filter for freebsd
       via  e1236a8 ctdb-client: Switch to ETIMEDOUT instead of ETIME
       via  b886a95 ctdb-daemon: Switch to using ETIMEDOUT instead of ETIME
       via  c8756ec ctdb-event: Switch to ETIMEDOUT instead of ETIME
       via  a42a723 ctdb-common: Switch to ETIMEDOUT from ETIME
       via  e8a1b3d ctdb-tests: Add required_error() to match on error codes
       via  af8c31e ctdb-tests: Add errno matching utility
       via  f13824b ctdb-tests: Switch some test stubs to use /bin/sh
       via  2f2c35a ctdb-tests: Improve portability by not using mktemp --tmpdir option
       via  896c77d ctdb-tests: Avoid use of non-portable getopt in stubs
       via  56ffca3 ctdb-tests: Avoid use of non-portable getopt in run_tests.sh
       via  4a39bc4 ctdb-tools: Avoid use of non-portable getopt in onnode
       via  dd9d8a2 ctdb-tests: Improve portability by not using /bin/bash directly
       via  73298ac ctdb-tools: Improve portability by not using /bin/bash directly
      from  2ba5fb2 autobuild: Test with and without building bundled popt

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


- Log -----------------------------------------------------------------
commit a44e6987b1e469ae202777cd575fd81c19e1ac6c
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jul 12 17:38:38 2018 +1000

    ctdb-docs: Replace obsolete reference to CTDB_DEBUG_HUNG_SCRIPT option
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13546
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Sat Jul 28 07:26:24 CEST 2018 on sn-devel-144

commit be43e08072ebce937ed0a02cd8d9d1c6072b178d
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jul 26 14:51:44 2018 +1000

    ctdb-common: Fix the TCP packet length check
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 3047202ce733d1a767fbc83c7021cb83bb83e0e1
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jul 19 17:41:55 2018 +1000

    ctdb-tests: Strip all spaces from od output
    
    On freebsd, there are trailing spaces in od output.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 6f5ed2b8b829e01fc675537e47095868ff8b5aa2
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jul 19 17:41:07 2018 +1000

    ctdb-tests: Fix a typo
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 65cc36f24d8a92c749dbc3700802e1d83a9ceb9f
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jul 19 17:40:40 2018 +1000

    ctdb-tests: Use errcode to translate ETIMEDOUT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 22c3078c8b10c88f8aff22caa7c92a06f387f17d
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jul 19 16:10:15 2018 +1000

    ctdb-tests: Replace md5sum with posix cksum
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 07844c2ec9583362594241e607d81aaead8f1a99
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jul 19 15:27:51 2018 +1000

    ctdb-tests: Use portable wc -c instead of stat -c "%s"
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 96d5c7de82f795e33e9998e0fe94ddcb50e7421d
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jul 19 14:43:09 2018 +1000

    ctdb-scripts: date "+%N" is non-portable
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 68542dbb5ab7b9d17b476937d1c84fe19d893255
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jul 19 12:08:20 2018 +1000

    ctdb-tests: Simplify pattern matching for ctime output
    
    On freebsd, sed does not accept multiple pattern strings.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 4152e98c0e95a938e17f95c543c2114bbf54b136
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jul 19 14:30:17 2018 +1000

    ctdb-tests: Do not try to match pstree output in eventd tests
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 3bf753e830c20183ef4f3278880d3be362e53bef
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Jul 18 19:00:42 2018 +1000

    ctdb-common: Add fd argument to ctdb_connection_list_read()
    
    This makes testing easier.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit c9b42d27e6cf9e6ae36f44970f0a388edc737a7a
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Jul 11 18:35:46 2018 +1000

    ctdb-protocol: Avoid fgets in ctdb_connection_list_read
    
    C library buffering API can behave in unexpected fashion if underlying
    fd for stdin, stdout or stderr is closed and re-opened.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit c7041b0faf490661818244dd032ad413ce906e5c
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Jul 18 18:42:10 2018 +1000

    ctdb-common: Add line based I/O
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 0273171c30a5bcfdfc0b3f74c1d5a89dbaa5b204
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Jul 11 17:23:43 2018 +1000

    ctdb-tests: Porting tests should ignore unsupported features
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 23952c9165bbdcae8f34b7dfefdbb4a499a55362
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jul 10 19:11:18 2018 +1000

    ctdb-tests: Use sigcode to match signals
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit b0028dd5bf2d5466a50dfd12a82a23f30e9ccf48
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jul 10 19:09:00 2018 +1000

    ctdb-tests: Add signal code matching utility
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit b7dbe9f306fda0d8f1dcc8dd81864539f6ff2632
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jul 10 18:54:11 2018 +1000

    ctdb-tests: Add ps output filter for freebsd
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit e1236a855ffc493efb5e9cb7b295034376e56d3a
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jul 10 18:48:53 2018 +1000

    ctdb-client: Switch to ETIMEDOUT instead of ETIME
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit b886a95eca306d0062240e5710ae0ed4505b1068
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jul 10 18:18:33 2018 +1000

    ctdb-daemon: Switch to using ETIMEDOUT instead of ETIME
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit c8756ec17be11e40bc7e75aac7afdb323acb42e2
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jul 10 18:34:13 2018 +1000

    ctdb-event: Switch to ETIMEDOUT instead of ETIME
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit a42a7232990fa163d046fb07be351ea3e0467046
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jul 10 18:19:09 2018 +1000

    ctdb-common: Switch to ETIMEDOUT from ETIME
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit e8a1b3db7abfa9e4a53e98a0aa21dfc268a21c92
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jul 10 18:47:27 2018 +1000

    ctdb-tests: Add required_error() to match on error codes
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit af8c31ead80d6c74b0e9d057cb47dff6552178a9
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jul 10 17:38:42 2018 +1000

    ctdb-tests: Add errno matching utility
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit f13824b291fca9cdaa936c238d7e9bcb73927da7
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Jul 1 13:39:57 2018 +1000

    ctdb-tests: Switch some test stubs to use /bin/sh
    
    They don't use any bash features.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 2f2c35a1cb4afe38e869882e8f18a62d4daac981
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Jul 1 13:28:40 2018 +1000

    ctdb-tests: Improve portability by not using mktemp --tmpdir option
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 896c77df1ce2645c6dd7898b59ea802e204dc7d9
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Jul 1 19:58:02 2018 +1000

    ctdb-tests: Avoid use of non-portable getopt in stubs
    
    getopt is being used with non-portable options.  In most cases use
    simpler, POSIX-compliant getopts instead.
    
    In the case of the ctdb test stub command, options can appear after
    other arguments, so this requires an additional nested loop.
    
    In the case of smnotify, there are no short options, so handle the
    long options manually.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 56ffca3e79923a028ff96fbd50706d808b9dd215
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Jul 8 21:54:40 2018 +1000

    ctdb-tests: Avoid use of non-portable getopt in run_tests.sh
    
    getopt is being used with non-portable options.  Use simpler,
    POSIX-compliant getopts instead.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 4a39bc4aaad541f1e89c0eb3e98d4104bcc25025
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Jul 1 18:43:06 2018 +1000

    ctdb-tools: Avoid use of non-portable getopt in onnode
    
    getopt is being used with non-portable options.  Use simpler,
    POSIX-compliant getopts instead.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit dd9d8a20aa6948a5d1e7fb532842b7ff5bc0f550
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Jul 1 13:30:06 2018 +1000

    ctdb-tests: Improve portability by not using /bin/bash directly
    
    FreeBSD and others do not have /bin/bash, so use "/usr/bin/env bash"
    for better flexibility.
    
    There are still many integration tests that use /bin/bash but this at
    least lets FreeBSD start running tests.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 73298ac8a9a87dcf3b3699dfdd39a8e865291620
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Jul 1 19:47:37 2018 +1000

    ctdb-tools: Improve portability by not using /bin/bash directly
    
    FreeBSD and others do not have /bin/bash, so use "/usr/bin/env bash"
    for better flexibility.
    
    There are still many integration tests that use /bin/bash but this at
    least lets FreeBSD start running tests.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

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

Summary of changes:
 ctdb/client/client.h                             |   2 +-
 ctdb/client/client_connect.c                     |   2 +-
 ctdb/common/line.c                               | 145 +++++++++++++++++
 ctdb/common/line.h                               |  62 ++++++++
 ctdb/common/run_event.c                          |   4 +-
 ctdb/common/run_proc.c                           |   2 +-
 ctdb/common/system_socket.c                      |   2 +-
 ctdb/config/events/legacy/00.ctdb.script         |   2 +-
 ctdb/config/functions                            |   9 +-
 ctdb/doc/ctdb-script.options.5.xml               |   5 +-
 ctdb/event/event_cmd.c                           |   4 +-
 ctdb/event/event_tool.c                          |   4 +-
 ctdb/protocol/protocol_util.c                    |  88 ++++++-----
 ctdb/protocol/protocol_util.h                    |   4 +-
 ctdb/server/ctdb_client.c                        |   2 +-
 ctdb/server/ctdb_monitor.c                       |   2 +-
 ctdb/server/ctdb_recover.c                       |   2 +-
 ctdb/server/ctdb_takeover.c                      |   8 +-
 ctdb/server/eventscript.c                        |   4 +-
 ctdb/tests/cunit/line_test_001.sh                |  90 +++++++++++
 ctdb/tests/cunit/pidfile_test_001.sh             |   2 +-
 ctdb/tests/cunit/porting_tests_001.sh            |  13 +-
 ctdb/tests/cunit/run_event_001.sh                |   8 +-
 ctdb/tests/cunit/run_proc_001.sh                 |  19 +--
 ctdb/tests/cunit/sock_daemon_test_001.sh         |  26 ++--
 ctdb/tests/eventd/etc-ctdb/debug-script.sh       |   2 +-
 ctdb/tests/eventd/eventd_001.sh                  |   6 +-
 ctdb/tests/eventd/eventd_002.sh                  |   8 +-
 ctdb/tests/eventd/eventd_003.sh                  |  11 +-
 ctdb/tests/eventd/eventd_004.sh                  |   2 +-
 ctdb/tests/eventd/eventd_006.sh                  |   2 +-
 ctdb/tests/eventd/eventd_007.sh                  |   4 +-
 ctdb/tests/eventd/eventd_011.sh                  |   4 +-
 ctdb/tests/eventd/eventd_012.sh                  |   4 +-
 ctdb/tests/eventd/eventd_013.sh                  |   4 +-
 ctdb/tests/eventd/eventd_021.sh                  |   2 +-
 ctdb/tests/eventd/eventd_022.sh                  |   3 +-
 ctdb/tests/eventd/eventd_023.sh                  |   2 +-
 ctdb/tests/eventd/eventd_024.sh                  |   2 +-
 ctdb/tests/eventd/eventd_032.sh                  |   6 +-
 ctdb/tests/eventd/eventd_033.sh                  |  12 +-
 ctdb/tests/eventd/eventd_042.sh                  |   2 +-
 ctdb/tests/eventd/eventd_043.sh                  |   4 +-
 ctdb/tests/eventd/eventd_052.sh                  |   4 +-
 ctdb/tests/eventd/scripts/local.sh               |   6 +-
 ctdb/tests/eventscripts/00.ctdb.init.009.sh      |   1 +
 ctdb/tests/eventscripts/13.per_ip_routing.024.sh |   2 +-
 ctdb/tests/eventscripts/scripts/00.ctdb.sh       |   3 +-
 ctdb/tests/eventscripts/scripts/11.natgw.sh      |   8 +-
 ctdb/tests/eventscripts/stubs/ctdb               |  38 +++--
 ctdb/tests/eventscripts/stubs/ip                 |   2 +-
 ctdb/tests/eventscripts/stubs/rpcinfo            |  34 ++--
 ctdb/tests/eventscripts/stubs/smnotify           |  17 +-
 ctdb/tests/eventscripts/stubs/ss                 |  28 ++--
 ctdb/tests/run_tests.sh                          |  48 +++---
 ctdb/tests/scripts/integration.bash              |   2 +-
 ctdb/tests/scripts/unit.sh                       |   7 +
 ctdb/tests/src/dummy_client.c                    |   2 +-
 ctdb/tests/src/errcode.c                         | 189 +++++++++++++++++++++++
 ctdb/tests/src/line_test.c                       | 102 ++++++++++++
 ctdb/tests/src/porting_tests.c                   |  10 +-
 ctdb/tests/src/protocol_util_test.c              |  18 +--
 ctdb/tests/src/sigcode.c                         | 120 ++++++++++++++
 ctdb/tests/takeover_helper/210.sh                |   6 +-
 ctdb/tests/takeover_helper/211.sh                |   6 +-
 ctdb/tests/takeover_helper/220.sh                |   6 +-
 ctdb/tests/takeover_helper/230.sh                |   8 +-
 ctdb/tests/takeover_helper/240.sh                |   6 +-
 ctdb/tests/takeover_helper/250.sh                |   6 +-
 ctdb/tests/takeover_helper/260.sh                |   6 +-
 ctdb/tests/takeover_helper/scripts/local.sh      |   4 +-
 ctdb/tools/ctdb.c                                |   6 +-
 ctdb/tools/ctdb_killtcp.c                        |   2 +-
 ctdb/tools/onnode                                |  55 +++----
 ctdb/wscript                                     |  17 +-
 75 files changed, 1043 insertions(+), 317 deletions(-)
 create mode 100644 ctdb/common/line.c
 create mode 100644 ctdb/common/line.h
 create mode 100755 ctdb/tests/cunit/line_test_001.sh
 create mode 100644 ctdb/tests/src/errcode.c
 create mode 100644 ctdb/tests/src/line_test.c
 create mode 100644 ctdb/tests/src/sigcode.c


Changeset truncated at 500 lines:

diff --git a/ctdb/client/client.h b/ctdb/client/client.h
index 2eec3ea..d4d1450 100644
--- a/ctdb/client/client.h
+++ b/ctdb/client/client.h
@@ -184,7 +184,7 @@ void ctdb_client_wait(struct tevent_context *ev, bool *done);
  * @param[in] ev Tevent context
  * @param[in] done Boolean flag to indicate when to stop waiting
  * @param[in] timeout How long to wait
- * @return 0 on succes, ETIME on timeout, and errno on failure
+ * @return 0 on succes, ETIMEDOUT on timeout, and errno on failure
  */
 int ctdb_client_wait_timeout(struct tevent_context *ev, bool *done,
 			     struct timeval timeout);
diff --git a/ctdb/client/client_connect.c b/ctdb/client/client_connect.c
index 1e4157e..0977d71 100644
--- a/ctdb/client/client_connect.c
+++ b/ctdb/client/client_connect.c
@@ -363,7 +363,7 @@ int ctdb_client_wait_timeout(struct tevent_context *ev, bool *done,
 	talloc_free(mem_ctx);
 
 	if (timed_out) {
-		return ETIME;
+		return ETIMEDOUT;
 	}
 
 	return 0;
diff --git a/ctdb/common/line.c b/ctdb/common/line.c
new file mode 100644
index 0000000..c4c6726
--- /dev/null
+++ b/ctdb/common/line.c
@@ -0,0 +1,145 @@
+/*
+   Line based I/O over fds
+
+   Copyright (C) Amitay Isaacs  2018
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+
+#include <talloc.h>
+
+#include "lib/util/sys_rw.h"
+
+#include "common/line.h"
+
+struct line_read_state {
+	line_process_fn_t callback;
+	void *private_data;
+	char *buf;
+	size_t hint, len, offset;
+	int num_lines;
+};
+
+static bool line_read_one(char *buf, size_t start, size_t len, size_t *pos)
+{
+	size_t i;
+
+	for (i=start; i<len; i++) {
+		if (buf[i] == '\n' || buf[i] == '\0') {
+			*pos = i;
+			return true;
+		}
+	}
+
+	return false;
+}
+
+static int line_read_process(struct line_read_state *state)
+{
+	size_t start = 0;
+	size_t pos = 0;
+
+	while (1) {
+		int ret;
+		bool ok;
+
+		ok = line_read_one(state->buf, start, state->offset, &pos);
+		if (! ok) {
+			break;
+		}
+
+		state->buf[pos] = '\0';
+		state->num_lines += 1;
+
+		ret = state->callback(state->buf + start, state->private_data);
+		if (ret != 0) {
+			return ret;
+		}
+
+		start = pos+1;
+	}
+
+	if (pos > 0) {
+		if (pos+1 < state->offset) {
+			memmove(state->buf,
+				state->buf + pos+1,
+				state->offset - (pos+1));
+		}
+		state->offset -= (pos+1);
+	}
+
+	return 0;
+}
+
+int line_read(int fd,
+	      size_t length,
+	      TALLOC_CTX *mem_ctx,
+	      line_process_fn_t callback,
+	      void *private_data,
+	      int *num_lines)
+{
+	struct line_read_state state;
+
+	if (length < 32) {
+		length = 32;
+	}
+
+	state = (struct line_read_state) {
+		.callback = callback,
+		.private_data = private_data,
+		.hint = length,
+	};
+
+	while (1) {
+		ssize_t n;
+		int ret;
+
+		if (state.offset == state.len) {
+			state.len += state.hint;
+			state.buf = talloc_realloc_size(mem_ctx,
+							state.buf,
+							state.len);
+			if (state.buf == NULL) {
+				return ENOMEM;
+			}
+		}
+
+		n = sys_read(fd,
+			     state.buf + state.offset,
+			     state.len - state.offset);
+		if (n < 0) {
+			return errno;
+		}
+		if (n == 0) {
+			break;
+		}
+
+		state.offset += n;
+
+		ret = line_read_process(&state);
+		if (ret != 0) {
+			if (num_lines != NULL) {
+				*num_lines = state.num_lines;
+			}
+			return ret;
+		}
+	}
+
+	if (num_lines != NULL) {
+		*num_lines = state.num_lines;
+	}
+	return 0;
+}
diff --git a/ctdb/common/line.h b/ctdb/common/line.h
new file mode 100644
index 0000000..6b67f1e
--- /dev/null
+++ b/ctdb/common/line.h
@@ -0,0 +1,62 @@
+/*
+   Line based I/O over fds
+
+   Copyright (C) Amitay Isaacs  2018
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __CTDB_LINE_H__
+#define __CTDB_LINE_H__
+
+#include <talloc.h>
+
+/**
+ * @file line.h
+ *
+ * @brief Line based I/O over pipes and sockets
+ */
+
+/**
+ * @brief The callback routine called to process a line
+ *
+ * @param[in]  line The line read
+ * @param[in]  private_data Private data for callback
+ * @return 0 to continue processing lines, non-zero to stop reading
+ */
+typedef int (*line_process_fn_t)(char *line, void *private_data);
+
+/**
+ * @brief Read a line (terminated by \n or \0)
+ *
+ * If there is any read error on fd, then errno will be returned.
+ * If callback function returns a non-zero value, then that value will be
+ * returned.
+ *
+ * @param[in]  fd The file descriptor
+ * @param[in]  length The expected length of a line (this is only a hint)
+ * @param[in]  mem_ctx Talloc memory context
+ * @param[in]  callback Callback function called when a line is read
+ * @param[in]  private_data Private data for callback
+ * @param[out] num_lines Number of lines read so far
+ * @return 0 on on success, errno on failure
+ */
+int line_read(int fd,
+	      size_t length,
+	      TALLOC_CTX *mem_ctx,
+	      line_process_fn_t callback,
+	      void *private_data,
+	      int *num_lines);
+
+#endif /* __CTDB_LINE_H__ */
diff --git a/ctdb/common/run_event.c b/ctdb/common/run_event.c
index 20e5be8..a215550 100644
--- a/ctdb/common/run_event.c
+++ b/ctdb/common/run_event.c
@@ -844,11 +844,11 @@ static void run_event_next_script(struct tevent_req *subreq)
 		if (! state->continue_on_failure) {
 			state->script_list->num_scripts = state->index + 1;
 
-			if (script->summary == -ETIME && pid != -1) {
+			if (script->summary == -ETIMEDOUT && pid != -1) {
 				run_event_debug(req, pid);
 			}
 			D_NOTICE("%s event %s\n", state->event_str,
-				 (script->summary == -ETIME) ?
+				 (script->summary == -ETIMEDOUT) ?
 				  "timed out" :
 				  "failed");
 			run_event_stop_running(state->run_ctx);
diff --git a/ctdb/common/run_proc.c b/ctdb/common/run_proc.c
index ee83d86..97895b3 100644
--- a/ctdb/common/run_proc.c
+++ b/ctdb/common/run_proc.c
@@ -452,7 +452,7 @@ static void run_proc_timedout(struct tevent_req *subreq)
 		return;
 	}
 
-	state->result.err = ETIME;
+	state->result.err = ETIMEDOUT;
 	if (state->proc->output != NULL) {
 		state->output = talloc_steal(state, state->proc->output);
 	}
diff --git a/ctdb/common/system_socket.c b/ctdb/common/system_socket.c
index 562b2bf..22776f7 100644
--- a/ctdb/common/system_socket.c
+++ b/ctdb/common/system_socket.c
@@ -775,7 +775,7 @@ int ctdb_sys_read_tcp_packet(int s,
 
 		/* make sure its not a short packet */
 		if (offsetof(struct tcphdr, th_ack) + 4 +
-		    (ip->ip_hl*4) > ret) {
+		    (ip->ip_hl*4) > pkthdr.len) {
 			return -1;
 		}
 		/* TCP */
diff --git a/ctdb/config/events/legacy/00.ctdb.script b/ctdb/config/events/legacy/00.ctdb.script
index 8db4a19..05ce2be 100755
--- a/ctdb/config/events/legacy/00.ctdb.script
+++ b/ctdb/config/events/legacy/00.ctdb.script
@@ -83,7 +83,7 @@ check_non_persistent_databases ()
     for _db in "${_dir}/"*.tdb.*[0-9] ; do
 	[ -r "$_db" ] || continue
 	check_tdb "$_db" || {
-	    _backup="${_db}.$(date +'%Y%m%d.%H%M%S.%N').corrupt"
+	    _backup="${_db}.$(date +'%Y%m%d.%H%M%S').corrupt"
 	    cat <<EOF
 WARNING: database ${_db} is corrupted.
  Moving to backup ${_backup} for later analysis.
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 5cc995a..7a47c9d 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -750,7 +750,10 @@ ctdb_counter_incr () {
 ctdb_counter_get () {
     _ctdb_counter_common "$1"
     # unary counting!
-    stat -c "%s" "$_counter_file" 2>/dev/null || echo 0
+    _val=$(wc -c < "$_counter_file" 2>/dev/null || echo 0)
+    # Strip leading spaces from ouput of wc (on freebsd)
+    # shellcheck disable=SC2086
+    echo $_val
 }
 
 ########################################################
@@ -864,8 +867,8 @@ if ! type mktemp >/dev/null 2>&1 ; then
 	fi
 	_d="${TMPDIR:-/tmp}"
 	_hex10=$(dd if=/dev/urandom count=20 2>/dev/null | \
-	    md5sum | \
-	    sed -e 's@\(..........\).*@\1@')
+	    cksum | \
+	    awk '{print $1}')
 	_t="${_d}/tmp.${_hex10}"
 	(
 	    umask 077
diff --git a/ctdb/doc/ctdb-script.options.5.xml b/ctdb/doc/ctdb-script.options.5.xml
index be8d4f4..9d545b5 100644
--- a/ctdb/doc/ctdb-script.options.5.xml
+++ b/ctdb/doc/ctdb-script.options.5.xml
@@ -1010,8 +1010,9 @@ CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=9000
 	      and those processes are matched in pstree output.
 	      REGEXP is an extended regexp so choices are separated by
 	      pipes ('|').  However, REGEXP should not contain
-	      parentheses.  See also
-	      <citetitle>CTDB_DEBUG_HUNG_SCRIPT</citetitle>.
+	      parentheses.  See also the <citerefentry><refentrytitle>ctdb.conf</refentrytitle>
+	      <manvolnum>5</manvolnum></citerefentry>
+	      [event] "debug script" option.
 	    </para>
 	    <para>
 	      Default is "exportfs|rpcinfo".
diff --git a/ctdb/event/event_cmd.c b/ctdb/event/event_cmd.c
index c116341..db39e4d 100644
--- a/ctdb/event/event_cmd.c
+++ b/ctdb/event/event_cmd.c
@@ -130,8 +130,8 @@ static void event_cmd_run_done(struct tevent_req *subreq)
 		goto done;
 	}
 
-	if (script_list->summary == -ETIME) {
-		state->reply->result = ETIME;
+	if (script_list->summary == -ETIMEDOUT) {
+		state->reply->result = ETIMEDOUT;
 	} else if (script_list->summary != 0) {
 		state->reply->result = ENOEXEC;
 	}
diff --git a/ctdb/event/event_tool.c b/ctdb/event/event_tool.c
index 3a99de5..9f75585 100644
--- a/ctdb/event/event_tool.c
+++ b/ctdb/event/event_tool.c
@@ -145,7 +145,7 @@ static int event_command_run(TALLOC_CTX *mem_ctx,
 
 	if (result == ENOENT) {
 		printf("Event dir for %s does not exist\n", argv[1]);
-	} else if (result == ETIME) {
+	} else if (result == ETIMEDOUT) {
 		printf("Event %s in %s timed out\n", argv[2], argv[1]);
 	} else if (result == ECANCELED) {
 		printf("Event %s in %s got cancelled\n", argv[2], argv[1]);
@@ -170,7 +170,7 @@ static double timeval_delta(struct timeval *tv2, struct timeval *tv)
 
 static void print_status_one(struct ctdb_event_script *script)
 {
-	if (script->result == -ETIME) {
+	if (script->result == -ETIMEDOUT) {
 		printf("%-20s %-10s %s",
 		       script->name,
 		       "TIMEDOUT",
diff --git a/ctdb/protocol/protocol_util.c b/ctdb/protocol/protocol_util.c
index 69bd67b..75427e4 100644
--- a/ctdb/protocol/protocol_util.c
+++ b/ctdb/protocol/protocol_util.c
@@ -22,6 +22,8 @@
 
 #include <talloc.h>
 
+#include "common/line.h"
+
 #include "protocol.h"
 #include "protocol_util.h"
 
@@ -642,56 +644,68 @@ const char *ctdb_connection_list_to_string(
 	return out;
 }
 
-int ctdb_connection_list_read(TALLOC_CTX *mem_ctx, bool client_first,
-			      struct ctdb_connection_list **conn_list)
-{
+struct ctdb_connection_list_read_state {
 	struct ctdb_connection_list *list;
-	char line[128]; /* long enough for IPv6 */
+	bool client_first;
+};
+
+static int ctdb_connection_list_read_line(char *line, void *private_data)
+{
+	struct ctdb_connection_list_read_state *state =
+		(struct ctdb_connection_list_read_state *)private_data;
+	struct ctdb_connection conn;
 	int ret;
 
-	if (conn_list == NULL) {
-		return EINVAL;
+	/* Skip empty lines */
+	if (line[0] == '\0') {
+		return 0;
 	}
 
-	list = talloc_zero(mem_ctx, struct ctdb_connection_list);
-	if (list == NULL) {
-		return ENOMEM;
+	/* Comment */
+	if (line[0] == '#') {
+		return 0;
 	}
 
-	while (fgets(line, sizeof(line), stdin) != NULL) {
-		char *t;
-		struct ctdb_connection conn;
+	ret = ctdb_connection_from_string(line, state->client_first, &conn);
+	if (ret != 0) {
+		return ret;
+	}
 
-		/* Skip empty lines */
-		if (line[0] == '\n') {
-			continue;
-		}
+	ret = ctdb_connection_list_add(state->list, &conn);
+	if (ret != 0) {
+		return ret;
+	}
 
-		/* Comment */
-		if (line[0] == '#') {
-			continue;
-		}
+	return 0;
+}
 
-		t = strtok(line, "\n");
-		if (t == NULL) {
-			goto fail;
-		}
+int ctdb_connection_list_read(TALLOC_CTX *mem_ctx,
+			      int fd,
+			      bool client_first,
+			      struct ctdb_connection_list **conn_list)
+{
+	struct ctdb_connection_list_read_state state;
+	int ret;
 
-		ret = ctdb_connection_from_string(t, client_first, &conn);
-		if (ret != 0) {
-			goto fail;
-		}
+	if (conn_list == NULL) {
+		return EINVAL;
+	}
 
-		ret = ctdb_connection_list_add(list, &conn);
-		if (ret != 0) {
-			goto fail;
-		}
+	state.list = talloc_zero(mem_ctx, struct ctdb_connection_list);
+	if (state.list == NULL) {
+		return ENOMEM;
 	}
 
-	*conn_list = list;
-	return 0;
+	state.client_first = client_first;
+
+	ret = line_read(fd,
+			128,
+			mem_ctx,
+			ctdb_connection_list_read_line,
+			&state,
+			NULL);
 
-fail:
-	talloc_free(list);
-	return EINVAL;
+	*conn_list = state.list;
+
+	return ret;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list