summaryrefslogtreecommitdiff
path: root/source3/lib/g_lock.c
AgeCommit message (Collapse)AuthorFilesLines
2013-02-19s3:lib: make use of samba_tevent_context_init()Stefan Metzmacher1-2/+2
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2012-08-24s3:g_lock: use serverid_exists() with SERVERID_UNIQUE_ID_NOT_TO_VERIFYStefan Metzmacher1-1/+10
metze
2012-08-16s3-g_lock: Make g_lock_lock more robustVolker Lendecke1-0/+24
If for some reason the cleanup of dbwrap_watch_send does not work properly, we might starve indefinitely. Make the lock routine more robust by retrying every 5-10 seconds. g_lock_trylock will clean up orphaned entries. Signed-off-by: Christian Ambach <ambi@samba.org> Autobuild-User(master): Christian Ambach <ambi@samba.org> Autobuild-Date(master): Thu Aug 16 19:44:00 CEST 2012 on sn-devel-104
2012-08-16s3-g_lock: Properly free "rec" on retry to avoid deadlockVolker Lendecke1-0/+1
Signed-off-by: Christian Ambach <ambi@samba.org>
2012-06-21s3:util: rename procid_equal() to serverid_equal()Michael Adam1-2/+2
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2012-04-19s3-g_lock: Use dbwrap_record_watch_send/recvVolker Lendecke1-446/+170
This simplifies the g_lock implementation. The new implementation tries to acquire a lock. If that fails due to a lock conflict, wait for the g_lock record to change. Upon change, just try again. The old logic had to cope with pending records and an ugly hack into ctdb itself. As a bonus, we now get a really clean async g_lock_lock_send/recv that can asynchronously wait for a global lock. This would have been almost impossible to do without the dbwrap_record_watch infrastructure.
2012-02-16lib/util: Remove sys_poll as it is no longer neededAndrew Bartlett1-6/+6
sys_poll() is only needed if the signal pipe is set up and used, but as no signal handler ever writes to the pipe, this can all be removed. signal based events are now handled via tevent. Andrew Bartlett Signed-off-by: Jeremy Allison <jra@samba.org>
2012-01-18s3: Add a "lock_order" argument to db_openVolker Lendecke1-1/+2
This will be used to enforce a lock hierarchy between the databases. We have seen deadlocks between locking.tdb, brlock.tdb, serverid.tdb and notify*.tdb. These should be fixed by refusing a dbwrap_fetch_locked that does not follow a defined lock hierarchy.
2011-12-12s3: Remove a bunch of calls to procid_self()Volker Lendecke1-4/+3
All callers to messaging_[re]init only used procid_self()
2011-10-11s3:g_lock: convert to use only dbwrap wrapper functions.Michael Adam1-15/+30
Avoid direct use of the db_record and db_context structs.
2011-09-20s3:g_lock: add a missing \n to a debug message in g_lock_initMichael Adam1-1/+1
2011-09-07s3: let g_lock_unlock() return more specific status codes on failureGregor Beck1-2/+2
Signed-off-by: Michael Adam <obnox@samba.org>
2011-07-29s3:dbwrap: move all .c and .h files of dbwrap to lib/dbwrap/Michael Adam1-1/+1
Autobuild-User: Michael Adam <obnox@samba.org> Autobuild-Date: Fri Jul 29 13:34:22 CEST 2011 on sn-devel-104
2011-07-29s3:dbwrap: move db_open() to a file dbwrap_open.c of its own.Michael Adam1-0/+1
Also start new folder lib/dbwrap/ where dbwrap_open.c is stored and make the fallbacke implementation functoins non-static and create a dbwrap_private.h header file that contains their prototypes.
2011-07-29s3:g_lock: explicitly include dbwrap.hMichael Adam1-0/+1
2011-06-27s3:g_lock: g_lock.tdb should not be executableChristian Ambach1-1/+2
TDBs are not executable, so do not create the file with the execution bit set Autobuild-User: Christian Ambach <ambi@samba.org> Autobuild-Date: Mon Jun 27 17:09:12 CEST 2011 on sn-devel-104
2011-06-09lib/util Bring procid_str() into lib/util as server_id_string()Andrew Bartlett1-5/+5
This is needed for OpenChange, which prints Samba struct server_id values in debug messages. Andrew Bartlett
2011-06-09s3-talloc Change TALLOC_ARRAY() to talloc_array()Andrew Bartlett1-1/+1
Using the standard macro makes it easier to move code into common, as TALLOC_ARRAY isn't standard talloc.
2011-05-06s3: only include tdb headers where needed.Günther Deschner1-0/+1
Guenther
2011-03-30s3: Fix g_lock_lock after the select/poll conversionVolker Lendecke1-1/+1
Without clustering we don't have an fd to listen on, and sys_poll needs one element of space Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Wed Mar 30 18:36:50 CEST 2011 on sn-devel-104
2011-03-30s3-messages: make ndr_messaging.h part of messages.h.Günther Deschner1-1/+0
Guenther
2011-03-30s3-messages: only include messages.h where needed.Günther Deschner1-0/+1
Guenther
2011-03-30s3-includes: only include system/filesys.h when needed.Günther Deschner1-0/+1
Guenther
2011-02-28s3: Eliminate sys_select from g_lock_lockVolker Lendecke1-11/+31
2010-10-01samba: share select wrappers.Günther Deschner1-0/+1
Guenther
2010-09-27Change to using TDB_INCOMPATIBLE_HASH (the jenkins hash) on allJeremy Allison1-1/+1
TDB_CLEAR_IF_FIRST tdb's. For tdb's like gencache where we open without CLEAR_IF_FIRST and then with CLEAR_IF_FIRST if corrupt this is still safe to use as if opening an existing tdb the new hash will be ignored - it's only used on creating a new tdb not opening an old one. Jeremy.
2010-09-20s3-build: only include ctdbd_conn.h where needed.Günther Deschner1-0/+1
Guenther
2010-08-31s3: messaging_ctdbd_connection() was only called with procid_self()Volker Lendecke1-8/+3
Eventually we'll get this right...
2010-08-28s3: Remove the dependency of g_lock on procid_selfVolker Lendecke1-9/+13
procid_self() references global vars, don't depend on them unnecessarily
2010-07-05s3: Pass procid_self() explicitly to messaging_ctdbd_connection()Volker Lendecke1-3/+6
2010-05-06s3: only include gen_ndr headers where needed.Günther Deschner1-0/+1
This shrinks include/includes.h.gch by the size of 7 MB and reduces build time as follows: ccache build w/o patch real 4m21.529s ccache build with patch real 3m6.402s pch build w/o patch real 4m26.318s pch build with patch real 3m6.932s Guenther
2010-03-12s3: Add "g_lock_do" as a convenience wrapper functionVolker Lendecke1-0/+64
2010-02-16s3: Fix timeout calculation if g_lock_lock is given a timeout < 60sVolker Lendecke1-1/+6
Detected while showing this code to obnox :-)
2010-02-16s3: Slightly increase parallelism in g_lockVolker Lendecke1-1/+7
There's no need to still hold the g_lock tdb-level lock while telling the waiters to retry
2010-02-16s3: Avoid starving locks when many processes die at the same timeVolker Lendecke1-6/+4
In g_lock_unlock we have a little race between the process_exists and messaging_send call: We only send to 5 waiters now, they all might have died between us checking their existence and sending the message. This change makes g_lock_lock retry at least once every minute.
2010-02-16s3: Avoid a thundering herd in g_lock_unlockVolker Lendecke1-1/+16
Only notify the first 5 pending lock waiters. This avoids a thundering herd problem that is really nasty in a cluster. It also makes acquiring a lock a bit more FIFO, lock waiters are added to the end of the array.
2010-02-16s3: Optimize g_lock_lock for a heavily contended caseVolker Lendecke1-3/+36
Only check the existence of the lock owner in g_lock_parse, check the rest of the records only when we got the lock successfully. This reduces the load on process_exists which can involve a network roundtrip in the clustered case.
2010-02-16s3: Fix handling of processes that died in g_lockVolker Lendecke1-3/+5
g_lock_parse might have thrown away entries from the locks array because the processes were not around anymore. Don't store the orphaned entries.
2010-02-15s3: Fix a typoVolker Lendecke1-1/+1
2010-02-12Fix warning messages on compile in g_lock.c Volker & Michael please check.Jeremy Allison1-14/+4
Jeremy.
2010-02-12s3:g_lock: remove a nested event loop, replacing the inner loop by selectMichael Adam1-38/+101
This made smbd crash in g_lock_lock() when trying to start a transaction on a db with an already started transaction, e.g. in a tcon_and_X where the share_info.tdb was not yet initialized but share_info.tdb was already locked by another process or writing acces to the winreg rpc pipe where the registry tdb was already locked by another process. What we really _want_ to do here by design is to react to MSG_DBWRAP_G_LOCK_RETRY messages that are either sent by a client doing g_lock_unlock or by ourselves when we receive a CTDB_SRVID_SAMBA_NOTIFY or CTDB_SRVID_RECONFIGURE message from ctdbd, i.e. when either a client holding a lock or a complete node has died. Doing this properly involves calling tevent_loop_once(), but doing this here with the main ctdbd messaging context creates a nested event loop when g_lock_lock() is called from the main event loop. So as a quick fix, we act a little corasely here: we do a select on the ctdb connection fd and when it is readable or we get EINTR, then we retry without actually parsing any ctdb packages or dispatching messages. This means that we retry more often than necessary and intended by design, but this does not harm and it is unobtrusive. When we have finished, the main loop will pick up all the messages and ctdb packets. The only extra twist is that we cannot use timed events here but have to handcode a timeout for select. Michael
2010-02-12s3:g_lock: remove an unreached code path.Michael Adam1-4/+0
Michael
2010-02-12s3: Implement global locks in a g_lock tdbVolker Lendecke1-0/+594
This is the basis to implement global locks in ctdb without depending on a shared file system. The initial goal is to make ctdb persistent transactions deterministic without too many timeouts.