summaryrefslogtreecommitdiff
path: root/lib/dbwrap
Commit message (Collapse)AuthorAgeFilesLines
* lib:dbwrap: Fix code spellingAndreas Schneider2023-04-032-2/+2
| | | | | | | Best reviewed with: `git show --word-diff`. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib/dbwrap: allow dbwrap_merge_dbufs() to update an existing bufferStefan Metzmacher2022-09-203-12/+21
| | | | | | | | | This will be useful in future... BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib/dbwrap: reset deleted record to tdb_nullRalph Boehme2021-11-041-6/+3
| | | | | | | | | | | | | | | | | | | | This allows the calling the following sequence of dbwrap functions: dbwrap_delete_record(rec); data = dbwrap_record_get_value(rec); without triggering the assert rec->value_valid inside dbwrap_record_get_value(). Note that dbwrap_record_storev() continues to invalidate the record, so this change somewhat blurs our semantics. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14882 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Nov 4 19:49:47 UTC 2021 on sn-devel-184
* dbwrap: Remove "db_context->try_fetch_locked()" fn pointerVolker Lendecke2021-06-042-18/+0
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Remove unused dbwrap_try_fetch_locked()Volker Lendecke2021-06-042-13/+0
| | | | | | | | Small simplification, this has not been used since 2014 when the notifyd went in. Can easily be added if needed again. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap_rbt: support TDB_INSERT and TDB_MODIFY store flagsDavid Disseldorp2020-06-101-0/+8
| | | | | | | | These flags provide insert-new and overwrite-existing record semantics respectively. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Make dbwrap_lock_order_[un]lock() publicVolker Lendecke2020-05-152-4/+9
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Simplify dbwrap_lock_order_[un]lock()Volker Lendecke2020-05-151-34/+49
| | | | | | | | | | | | | | | | | Directly pass the database name and lock order to the core functions, avoid passing struct db_context. In the next steps these functions will become public: locking.tdb will be based on g_lock.c to avoid holding a tdb-level locking.tdb mutex while doing complex file system operations like unlink() which can take ages on FAT for example. This means that g_lock.c will participate in the dbwrap lock order protection and needs access to dbwrap_lock_order_[un]lock() without providing a direct db_context. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Don't set rec->value in dbwrap_do_locked()Volker Lendecke2019-11-222-4/+10
| | | | | | | We pass that via the callback now Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Protect against invalid db_record->valueVolker Lendecke2019-11-224-0/+20
| | | | | | | | | | | After dbwrap_record_storev()/delete(), dbwrap_record_get_value() information is stale. Assert on the attempt to re-fetch data after it became stale. This can't protect against someone copying the result from dbwrap_record_get_value() somewhere else, but it's better than nothing. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Pass "value" to dbwrap_do_locked() callbackVolker Lendecke2019-11-224-4/+14
| | | | | | | | | | | | | | I want to reduce dbwrap_record_get_value(). It makes the caller believe it can make a copy of the TDB_DATA returned and that the value remains constant. It's not, as you can always do a dbwrap_record_store(). This patch removes one requirement for getting the value out of a db_record via dbwrap_record_get_value(). You can still make a copy, but from an API perspective to me it's more obvious that "value" as a parameter to the callback has a limited lifetime. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap_tdb: Return correct error from db_tdb_storev()Volker Lendecke2019-11-221-2/+8
| | | | | | | Don't lose information to NT_STATUS_UNSUCCESSFUL Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap_tdb: Avoid includes.hVolker Lendecke2019-11-221-1/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap_tdb: Avoid a use of talloc_stackframe()Volker Lendecke2019-11-061-10/+10
| | | | | | | For really large keys (that probably don't exist), use dump_data() Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Allow a 4th lock orderVolker Lendecke2019-09-172-2/+3
| | | | | | | We will have another tdb soon Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Initialize state in dbwrap_delete()Volker Lendecke2019-09-101-1/+1
| | | | | | | | Probably not required, but looks safer and gives static checkers less reason to complain about potentially uninitialized variable reads Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Remove an obsolete commentVolker Lendecke2019-09-101-4/+0
| | | | | | | At least as of 2ac9d0afa66 ctdb does not care about db prios anymore Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Micro-optimization for db_tdb_do_locked()Volker Lendecke2019-08-191-2/+2
| | | | | | | We don't need the tdb lock for the talloc_free(buf) anymore Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Böhme <slow@samba.org>
* lib/dwrap: Fix 'Null pointer passed as an argument to a 'nonnull' parameter 'Noel Power2019-06-261-1/+1
| | | | | | | | | | Fixes: lib/dbwrap/dbwrap.c:645:4: warning: Null pointer passed as an argument to a 'nonnull' parameter <--[clang] memcpy(p, dbufs[i].dptr, thislen); Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib/dbwrap: clang: Fix 'all argument is an uninitialized value'Noel Power2019-06-261-2/+3
| | | | | | | | | | | Fixes: lib/dbwrap/dbwrap.c:533:4: warning: 2nd function call argument is an uninitialized value <--[clang] dbwrap_lock_order_unlock(db, lockptr); ^ Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* Fix ubsan null pointer passed as argument 2Gary Lockyer2019-05-271-1/+3
| | | | | | | | | | | | Fix ubsan warning null pointer passed as argument 2 when the source pointer is NULL. The calls to memcpy are now guarded by an if (len > 0) Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Gary Lockyer <gary@samba.org> Autobuild-Date(master): Mon May 27 01:29:48 UTC 2019 on sn-devel-184
* dbwrap: Adapt tdb_data_buf's overflow handling to modern conventionsVolker Lendecke2019-05-081-4/+2
| | | | | | | | This is the way we do it right now, avoid confusion why "tmp" might be needed Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Fix tdb_data_buf()Volker Lendecke2019-05-081-1/+1
| | | | | | | IIRC there are platforms that don't like memcpy() with len=0. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap_tdb: Avoid double-call to talloc_get_type_abortVolker Lendecke2018-09-141-5/+6
| | | | | | | We've already retrieved "ctx" in the callers of db_tdb_fetch_locked_internal(). Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* dbwrap_tdb: use struct initializerRalph Boehme2018-09-121-2/+3
| | | | | | | This ensures all struct members are implicitly initialized. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap_tdb: move a function call out of an if conditionRalph Boehme2018-09-121-3/+6
| | | | | | | | At least for me this improves readability somewhat. No change in behaviour. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Remove a pointless "return;"Volker Lendecke2018-09-071-1/+0
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* dbwrap: Fix a typoVolker Lendecke2018-08-171-1/+1
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Rowland Penny <rpenny@samba.org>
* Convert affected by previous commit lines from DEBUG(10,..) to DBG_DEBUG().Timur I. Bakeyev2018-05-161-2/+2
| | | | | | | | | Signed-off-by: Timur I. Bakeyev <timur@iXsystems.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Wed May 16 21:29:24 CEST 2018 on sn-devel-144
* Remove extra 0x prefix for the "%p" format specifiers, avoiding 0x0x0 ↵Timur I. Bakeyev2018-05-161-1/+1
| | | | | | | | strings in the output. Signed-off-by: Timur I. Bakeyev <timur@iXsystems.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
* dbwrap: Remove dependency on samba-hostconfigVolker Lendecke2018-04-241-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Remove calls to loadparmVolker Lendecke2018-04-242-12/+9
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Simplify dbwrap_unmarshall_fnVolker Lendecke2017-08-161-13/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Simplify dbwrap_trans_deleteVolker Lendecke2017-08-161-10/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Simplify dbwrap_trans_storeVolker Lendecke2017-08-161-9/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Simplify dbwrap_store_uint32_bystringVolker Lendecke2017-08-161-14/+5
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Simplify dbwrap_store_int32_bystringVolker Lendecke2017-08-161-14/+5
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Convert dbwrap_delete to dbwrap_do_lockedVolker Lendecke2017-08-161-9/+16
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Convert dbwrap_store to dbwrap_do_lockedVolker Lendecke2017-08-161-9/+17
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap_tdb: Implement do_lockedVolker Lendecke2017-07-251-0/+47
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* dbwrap: Add dbwrap_do_lockedVolker Lendecke2017-07-253-0/+45
| | | | | | | | | With a proper implementation this enables modifications without having to allocate a record. In really performance sensitive code paths this matters. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* dbwrap: Factor out the core dbwrap lock order logicVolker Lendecke2017-07-251-46/+58
| | | | | | | This will allow dbwrap_do_locked to check the order without talloc Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* dbwrap: Add dbwrap_record_storevVolker Lendecke2017-07-252-2/+10
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* dbwrap: Convert backend store to storevVolker Lendecke2017-07-254-15/+37
| | | | | | | | | | Convert all implementors of dbwrap_store to a storev-style call by using the dbwrap_merge_dbufs call For dbwrap_tdb, this matches tdb_storev. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* dbwrap: Add dbwrap_merge_dbufsVolker Lendecke2017-07-252-0/+51
| | | | | | | Transitional code to implement dbwrap_record_storev Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* dbwrap: Remove unused dbwrap_fileVolker Lendecke2017-06-212-456/+0
| | | | | | | | This has stopped working ages ago. The idea is clear, but if someone wants to revive it, I think it needs a completely fresh start. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Remove unused dbwrap_cacheVolker Lendecke2017-06-213-256/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: add dbwrap_parse_record_send/recvRalph Boehme2017-04-183-1/+146
| | | | | | | | | | | | | | | | | | | | | | | | The req_state parameter tells the caller whether the async request is blocked in a full send queue: req_state >= DBWRAP_REQ_DISPATCHED := request is dispatched req_state < DBWRAP_REQ_DISPATCHED := send queue is full This is useful in a clustered Samba environment where the async dbwrap request is sent over a socket to the local ctdbd. If the send queue is full and the caller was issuing multiple async dbwrap requests in a loop, the caller knows it's probably time to stop sending requests for now and try again later. This will be used in subsequent commits in smbd_smb2_query_directory_send() when implementing async write time updates. Directories may contain umpteen files so we send many requests to ctdb without going through tevent and reading the responses which has the potential to deadlock. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* dbwrap: add parse_record_send/recv to struct db_contextRalph Boehme2017-04-181-0/+12
| | | | | | | The implementation comes next. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* dbwrap: add enum dbwrap_req_stateRalph Boehme2017-04-181-0/+23
| | | | | | | | | | | | | | | | | | | | | This will be used by async dwrap_parse_send() as an out argument, giving the caller an indication about the state of the request. This is can be useful for the caller if it is a sync function and sends multiple async dbwrap requests. As it's a sync function it won't return to the main tevent event loop and so the async dbwrap recv function are not called. As a result the function may deadlock: our receive queue may already be full with results from a peer, the peer might be blocked in his send queue (because we're not receiving), the peer therefor doesn't read from his receive queue so our send queue will block as well. To inform the caller of this situation "send queue full" we return this state information to the caller of the dbwrap send function. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>