summaryrefslogtreecommitdiff
path: root/ctdb/common
Commit message (Collapse)AuthorAgeFilesLines
* ctdb/common/srvid.h: typo fixesBjörn Jacke2019-10-311-1/+1
| | | | | Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb: Avoid malloc/memcpy/free in ctdb_ltdb_fetch()Volker Lendecke2019-10-241-31/+72
| | | | | | | Make use of tdb_parse_record() Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Mark VacuumLimit tunable as obsoleteMartin Schwenke2019-10-041-1/+1
| | | | | | | | | | | Use of this tunable was dropped over 5 years ago in commit 16837bc309aa9a86fc21d7f59a8fce0b947428a3. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Fri Oct 4 07:07:21 UTC 2019 on sn-devel-184
* Spelling fixes s/advertisment/advertisement/Mathieu Parent2019-09-011-1/+1
| | | | | | Signed-off-by: Mathieu Parent <math.parent@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* ctdb-common: Return value of ctdb_queue_length() should be unsignedMartin Schwenke2019-08-142-2/+2
| | | | | | | | | | | | | | | | Compiling with -Wsign-compare complains: ctdb/server/ctdb_daemon.c: scope_hint: In function ‘daemon_queue_send’ ctdb/server/ctdb_daemon.c:259:40: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare] ... The struct ctdb_queue member out_queue_length is actually uint32_t, so just return that type. Found by csbuild. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Fix empty value handling in confAmitay Isaacs2019-07-261-0/+8
| | | | | | | | | | | | In tini, allow_empty_value=false causes the parser to ignore the lines without '=' sign, but lines with nothing after '=' sign are allowed and cause empty string ("") to be passed as a value. This is counter-intuitive, so conf requires special handling for empty values (which are treated as invalid). Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: Mark ctdb_fatal() and ctdb_die() as _NORETURN_Martin Schwenke2019-07-051-2/+4
| | | | | | | | This avoids static analysers continuing analysis after calls to these functions and producing incorrect warnings. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Fix signed/unsigned comparisons by declaring as unsignedMartin Schwenke2019-07-052-5/+5
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Fix error handlingMartin Schwenke2019-07-051-4/+14
| | | | | | | | | | | | | According to the documentation, sendto() should either send the packet as given or return with an error. However, given that it can return the number of bytes sent, treat the theoretical error of a short packet send separately, since errno would not be set in this case. Similarly, treat a short packet recv() separately from an error where errno is set. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Fix signed/unsigned comparisons by castingMartin Schwenke2019-07-053-4/+7
| | | | | | | One case needs an extra variable declared. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Avoid unused value warningMartin Schwenke2019-06-051-1/+1
| | | | | | | | The incremented value of argc is indeed never used. Leave it as a comment to warn anyone cutting and pasting the code. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Avoid warning for potentially uninitialised pointersMartin Schwenke2019-06-051-2/+2
| | | | | | | s_list generates a warning, but initialise them both. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Use #ifdef to avoid TEST_RB_TREE not definedMartin Schwenke2019-06-051-2/+2
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Fix signed/unsigned comparisons by castingMartin Schwenke2019-06-052-8/+8
| | | | | | | | In one case, given triviality of change, add missing braces and fix whitespace. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Fix signed/unsigned comparisons by declaring as unsignedMartin Schwenke2019-06-053-8/+10
| | | | | | | | | Simple cases where a variable (usually a loop variable) needs to be declared as an unsigned type (unsigned int or size_t) instead of an int. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb: Make TDB_SEQNUM work synchronously with ctdbVolker Lendecke2019-05-241-19/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Old war story completely from memory, I could not find the commit that introduced TDB_SEQNUM so far...: Back in the days when ctdb was initially developed, TDB_SEQNUM's only user was the notify.tdb that held one huge record for all notify records. With that use case in mind it made perfect sense to keep the SEQNUM stable locally, sacrificing precision. By now notify.tdb is long gone, an the only user of TDB_SEQNUM right now is brlock.tdb, which contains special case code for the imprecise ctdb implementation of TDB_SEQNUM. With this commit, that special code can go: The TDB_SEQNUM will also increment when just the DMASTER header field changes, indicating to smbd that someone else might have changed the record. This will of course increase the SEQNUM frequency, but it should not increase the load on ctdb: If you look at the brlock.c workaround, it just does not do the caching that is possible with precise TDB_SEQNUMs working. How did I get here? I want to move brl_num_read_oplocks() from brlock.tdb into locking.tdb, and for that I need precise TDB_SEQNUMs for locking.tdb. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri May 24 00:42:17 UTC 2019 on sn-devel-184
* ctdb: Remove unused ctdb_ltdb_fetch_with_header()Volker Lendecke2019-05-232-39/+0
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu May 23 18:08:36 UTC 2019 on sn-devel-184
* ctdb-common: Fix memory leak in run_procAmitay Isaacs2019-05-141-2/+5
| | | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13943 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Tue May 14 08:59:03 UTC 2019 on sn-devel-184
* ctdb-common: Fix memory leakMartin Schwenke2019-05-141-1/+2
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13943 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb:common: Do not print NULL if we don't get a sockpathAndreas Schneider2019-05-081-1/+1
| | | | | | | | | sock_socket_start_recv() might not fill sockpath if we return early. Found by GCC 9. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* ctdb-common: Avoid race between fd and signal eventsAmitay Isaacs2019-04-121-0/+7
| | | | | | | | | | | | | | | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13895 In run_proc, there was an implicit assumption that when a process exits, fd event (pipe between parent and child) would be processed first and signal event (SIGCHLD for the child) would be processed later. However, that is not the case. SIGCHLD can be received asynchronously any time even when the pipe data has not fully been read. This causes run_proc to miss some of the output from child process in tests. When SIGCHLD is being processed, if the pipe between parent and child is still open, then do an explict read from the pipe to ensure we read any data still in the pipe before closing the pipe. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Fri Apr 12 08:19:29 UTC 2019 on sn-devel-144
* ctdb-version: Simplify version string usageAmitay Isaacs2019-03-152-38/+0
| | | | | | | | | | | | | | | There is no need to write SAMBA_VERSION_STRING as CTDB_VERSION_STRING. Wherever required use SAMBA_VERSION_STRING directly. Avoids the confusion with two version.h files. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13789 Signed-off-by: Amitay Isaacs <amitay@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Fri Mar 15 06:31:50 UTC 2019 on sn-devel-144
* ctdb: buffer write beyond limitsSwen Schillig2019-02-221-1/+12
| | | | | | | | | | | | | | In order to calculate the number of bytes correctly which are to be read into the buffer, the buffer.offset must be taken into account. This patch fixes a regression introduced by 382705f495dd. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13791 Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Christof Schmitt <cs@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
* spelling of associatedDouglas Bagnall2019-02-131-1/+1
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ctdb:common: Use C99 initializer for 'struct ifreq'Andreas Schneider2019-01-281-2/+10
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ctdb: Use C99 initializer for last element of tunablesAndreas Schneider2019-01-281-1/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ctdb: Adding memory pool for queue callbackSwen Schillig2018-12-071-1/+8
| | | | | | | | | | | | | | | | | The received packet is copied into a newly allocated memory chunk for further processing by the assigned callback. Once this is done, the memory is free'd. This is repeated for each received packet making the memory allocation / free an expensive task. To optimize this process, a memory pool is defined which is sized identically to the queue's buffer. During tests it could be seen that more than 95% of all messages were sized below the standard buffer_size of 1k. Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Christof Schmitt <cs@samba.org> Autobuild-User(master): Christof Schmitt <cs@samba.org> Autobuild-Date(master): Fri Dec 7 23:27:16 CET 2018 on sn-devel-144
* ctdb: Introduce buffer.offset to avoid memmoveSwen Schillig2018-12-071-16/+39
| | | | | | | | | | | | | | | | The memmove operation is quite expensive, therefore, a new buffer attribute "offset" is introduced to support an optimized buffer processing. The optimization is to "walk" through the buffer and process each packet until the buffer is fully processed (empty) without requiring any memmove. Only if a packet is in-complete, the buffer content is moved and the new data is read from the queue. This way almost all memmove operations are eliminated. Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Christof Schmitt <cs@samba.org>
* ctdb: Use #ifdef instead of #if for config.h definitionsAndreas Schneider2018-11-281-6/+6
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* ctdb: Fix an out of bound array accessAndreas Schneider2018-11-141-1/+1
| | | | | | | | | Found by cppcheck. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13680 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* debug: Use debuglevel_(get|set) functionAndreas Schneider2018-11-083-4/+8
| | | | | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu Nov 8 11:03:11 CET 2018 on sn-devel-144
* ctdb-common: Allow path_socket() to use $CTDB_SOCKETMartin Schwenke2018-11-061-0/+8
| | | | | | | | | Use of CTDB_SOCKET is being generally removed. However, this override is being added to allow test code outside of ctdb/ to be able to specify the socket, if desired. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Set close-on-exec for startup fdAmitay Isaacs2018-10-222-2/+9
| | | | | | | | | | | | The startup_fd should not be propagated to the child processes created from a daemon. It should only be used in the daemon code to return the status of the startup. Another use of startup_fd is to notify the parent if the daemon process has exited. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13659 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: Process the whole config file even if an error occursMartin Schwenke2018-09-031-6/+10
| | | | | | | | | | | At the moment multiple errors will be encountered one at a time, on each load or validate. Instead, allow all configuration errors to printed in a single pass. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13589 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Avoid ENOENT for unknown conf optionsMartin Schwenke2018-09-031-6/+6
| | | | | | | | | Only use ENOENT for missing configuration file. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13589 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Avoid ENOENT for unknown conf type tagsMartin Schwenke2018-09-031-2/+2
| | | | | | | | | Only use ENOENT for missing configuration file. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13589 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Log a message when an invalid conf value is encounteredMartin Schwenke2018-09-031-0/+4
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13589 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Log a message for unknown conf optionMartin Schwenke2018-09-031-0/+6
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13589 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Fix log message for conf option with unknown sectionMartin Schwenke2018-09-031-2/+3
| | | | | | | | | | This covers both options that appear before a section and options in unknown sections. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13589 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Clean up comments in TCP packet parsingMartin Schwenke2018-08-301-10/+4
| | | | | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Thu Aug 30 07:50:04 CEST 2018 on sn-devel-144
* ctdb-common: Check the version field in IPv6 packetsMartin Schwenke2018-08-301-0/+5
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Improve TCP packet size and offset calculationsMartin Schwenke2018-08-301-5/+7
| | | | | | | | | | | | | The IPv4 check for short packets was strange. It appeared to ensure that the capture included everything up to and including the window size. The checksum field immediately follows the window size field, so just ensure that the packet is large enough to contain everything up to the start of the checksum. Add a similar check for IPv6 packets. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Factor out TCP packet parsing codeMartin Schwenke2018-08-301-147/+149
| | | | | | | This can be tested separately. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Clean up types/declarations in TCP socket readingMartin Schwenke2018-08-301-7/+6
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Fix error handling when parsing TCP packetsMartin Schwenke2018-08-301-14/+14
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Fix a bug in non-Linux (PCAP) TCP packet capturingMartin Schwenke2018-08-301-1/+1
| | | | | | | | | Captured packets include a link-layer header, which is considered in the Linux code but not the PCAP code. Also, the actual captured length is in caplen, not len. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Don't modify a const argumentMartin Schwenke2018-08-301-11/+9
| | | | | | | | | The current code might be slightly more efficient but intentionally (although temporarily) modifying a const argument just seems wrong. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Avoid magic numbers when building TCP packetsMartin Schwenke2018-08-301-5/+5
| | | | | | | | | Most packet sizes and offsets are multiples of 32-bit words. The IPv6 payload length is in octets. The IPv6 version is the top 4 bits of the relevant field. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Factor out TCP packet marshalling codeMartin Schwenke2018-08-301-59/+151
| | | | | | | This can be tested separately. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Avoid single line multi-assignmentMartin Schwenke2018-08-301-1/+2
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>