diff options
author | Volker Lendecke <vl@samba.org> | 2019-11-19 17:29:18 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-11-22 23:57:48 +0000 |
commit | d734547488c6fab8d136239a95db640df57dbb97 (patch) | |
tree | 097fcf015a85d929db1d10dd36f000e5c1e9e17c /source3/smbd/server.c | |
parent | effad89f6224fbaeed5ef67016bd23e645763bc9 (diff) | |
download | samba-d734547488c6fab8d136239a95db640df57dbb97.tar.gz |
lib: Change the g_lock data model
Now we have one fixed field for the exclusive lock holder and an array
of shared locks. This way we now prioritize writers over readers: If a
pending write comes in while readers are active, it will put itself
into the exclusive slot. Then it waits for the readers to vanish. Only
when all readers are gone the exclusive lock request is granted. New
readers will just look at the exclusive slot and see it's taken. They
will then line up as watchers, retrying whenever things change.
This also means that it will be cheaper to support many shared locks:
Granting a shared lock just means to extend the array. We don't have
to walk the array for possible conflicts.
This also adds explicit UPGRADE and DOWNGRADE operations for better
error checking.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/smbd/server.c')
-rw-r--r-- | source3/smbd/server.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 20f34bc401b..a8e69e0f0a1 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -1483,7 +1483,7 @@ static NTSTATUS smbd_claim_version(struct messaging_context *msg, return NT_STATUS_OK; } - status = g_lock_lock(ctx, string_term_tdb_data(name), G_LOCK_WRITE, + status = g_lock_lock(ctx, string_term_tdb_data(name), G_LOCK_UPGRADE, (struct timeval) { .tv_sec = 60 }); if (!NT_STATUS_IS_OK(status)) { DBG_WARNING("g_lock_lock(G_LOCK_WRITE) failed: %s\n", |