summaryrefslogtreecommitdiffstats
path: root/source3/lib/serverid.c
Commit message (Collapse)AuthorAgeFilesLines
* tdb_wrap: Move to specific directory.Jelmer Vernooij2012-03-101-1/+1
| | | | | | | | | | It's a bit confusing to mix low-level and high-level libraries. We had multiple libraries in one directory, and there were have circular dependencies with other libraries outside that directory (in this case, samba-hostconfig). Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Sat Mar 10 23:13:01 CET 2012 on sn-devel-104
* s3: Add SERVERID_UNIQUE_ID_NOT_TO_VERIFY, bug 8760Volker Lendecke2012-02-151-0/+20
| | | | | Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Wed Feb 15 21:10:22 CET 2012 on sn-devel-104
* s3: Add a "lock_order" argument to db_openVolker Lendecke2012-01-181-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.
* s3-dbwrap: Make dbwrap_parse_record return NTSTATUSVolker Lendecke2011-12-151-4/+6
| | | | | | | Also, the parser now returns void. The parser is called if and only if dbwrap_parse_record returns NT_STATUS_OK. Signed-off-by: Michael Adam <obnox@samba.org>
* s3-ctdb: Make use of CTDB_CONTROL_CHECK_SRVIDSVolker Lendecke2011-11-301-0/+13
| | | | | | | | This should be a lot quicker than PROCESS_EXISTS followed by looking at serverid.tdb Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Wed Nov 30 12:47:27 CET 2011 on sn-devel-104
* s3: Add serverids_existVolker Lendecke2011-10-271-0/+34
|
* lib/util: Add back control of mmap and hash size in tdb for top level buildAndrew Bartlett2011-10-131-1/+10
| | | | | | | | This passes down a struct loadparm_context to allow these parameters to be checked. This may be s3 or s4 context, allowing the #if _SAMBA_BUILD_ macro to go away safely. Andrew Bartlett
* s3:serverid: convert to using dbwrap wrapper functions onlyMichael Adam2011-10-111-16/+24
| | | | Avoid direct use of the db_record and db_context structs.
* s3:serverid: use dbwrap_traverse_read() in serverid_traverse_read()Michael Adam2011-10-111-1/+5
| | | | | | This also fixes the return value: originally the int return value of traverse_read which is a count of the records traversed or negative upon failure, was simply casted into a bool return value.
* s3:serverid: use dbwrap_traverse() in serverid_traverse()Michael Adam2011-10-111-1/+4
| | | | | | This also fixes the return value: Originally, the int returned by the traverse method, which is the count of the traverse was casted into a bool return value.
* s3: Slightly simplify serverid_existsVolker Lendecke2011-08-221-1/+1
| | | | | | | procid_is_me() works fine in the clustering case as well Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Mon Aug 22 21:28:13 CEST 2011 on sn-devel-104
* Re-arrange the optimization to reduce tdb fcntl calls if smbd is notIra Cooper2011-08-201-1/+5
| | | | | | | | clustered. procid_is_me() is much cheaper to test and can optimize up to 50% of the calls to serverid_exists(). Volker please check. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Sat Aug 20 01:15:07 CEST 2011 on sn-devel-104
* s3:dbwrap: move all .c and .h files of dbwrap to lib/dbwrap/Michael Adam2011-07-291-1/+1
| | | | | Autobuild-User: Michael Adam <obnox@samba.org> Autobuild-Date: Fri Jul 29 13:34:22 CEST 2011 on sn-devel-104
* s3:dbwrap: move db_open() to a file dbwrap_open.c of its own.Michael Adam2011-07-291-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.
* tdb_compat: Higher level API fixes.Rusty Russell2011-06-201-1/+1
| | | | | | | | | | | | My previous patches fixed up all direct TDB callers, but there are a few utility functions and the db_context functions which are still using the old -1 / 0 return codes. It's clearer to fix up all the callers of these too, so everywhere is consistent: non-zero means an error. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* s3-server_id Add task_id to server_id to match Samba4Andrew Bartlett2011-06-091-0/+3
| | | | | | | | | | This will allow this structure to be shared, and allow us to create a common messaging system between all Samba processes. Samba4 uses the task_id to indicate the different tasks within a single unix process. Andrew Bartlett Signed-off-by: Andrew Tridgell <tridge@samba.org>
* s3: only include tdb headers where needed.Günther Deschner2011-05-061-0/+1
| | | | Guenther
* lib/util Move source3 tdb_wrap_open() into the common code.Andrew Bartlett2011-05-061-0/+1
| | | | | | | | | This #if _SAMBA_BUILD == 3 is very unfortunate, as it means that in the top level build, these options are not available for these databases. However, having two different tdb_wrap lists is a worse fate, so this will do for now. Andrew Bartlett
* s3-includes: only include system/filesys.h when needed.Günther Deschner2011-03-301-0/+1
| | | | Guenther
* s3-cluster Always fill in the clustering vnn elementAndrew Bartlett2011-02-171-6/+0
| | | | | | This avoids this structure being partially uninitialised. Adnrew Bartlett
* s3: Fix serverid_existsVolker Lendecke2010-12-191-0/+4
| | | | | | | In the cluster case it can happen that a node just died and we did not yet have the time to clean up serverid.tdb. If the corresponding serverid.tdb record that represented a process was migrated away from the dead record, it represents existence of a process where it is already dead.
* Change to using TDB_INCOMPATIBLE_HASH (the jenkins hash) on allJeremy Allison2010-09-271-2/+2
| | | | | | | | | | 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.
* s3: Remove talloc_autofree_context() from serverid_db()Volker Lendecke2010-09-261-2/+2
| | | | | If we needed an explicit tdb_close() in the destructor, we'd be hosed long ago.
* s3: Remove talloc_autofree_context() from serverid_parent_init()Volker Lendecke2010-09-261-3/+2
|
* s3-build: use dbwrap.h only where needed.Günther Deschner2010-08-261-0/+1
| | | | Guenther
* s3: Fix serverid_register_msg_flagsVolker Lendecke2010-08-181-4/+2
| | | | Thanks, Andreas, for pointing this out! (How drunk have I been?...)
* s3-lib: Fixed a possible crash bug.Andreas Schneider2010-08-181-0/+2
| | | | Volker please check!
* Fix warning on 64-bit machines.Jeremy Allison2010-07-201-1/+1
| | | | Jeremy.
* s3: Put serverid_key and serverid_data togetherVolker Lendecke2010-07-051-5/+5
|
* s3: Remove an unused variable -- thanks, metze!Volker Lendecke2010-07-041-2/+1
|
* s3: Replace register_message_flags() with serverid_register_msg_flags()Volker Lendecke2010-07-041-0/+52
| | | | | | | message_send_all is now done by walking the serverid.tdb, not the connections.tdb anymore. Günther, Simo, please check!
* s3: Remove serverid_[de]register_selfVolker Lendecke2010-07-041-21/+5
| | | | This removes some deep references to procid_self()
* s3: ALWAYS run make test before checkin ....Volker Lendecke2010-07-041-2/+2
|
* s3: Slight reshaping of server_exists_parseVolker Lendecke2010-07-041-4/+6
| | | | Doing a copy and then do the compare is a bit pointless, use memcmp
* s3: Add a comment to serverid_parent_init, this is pretty confusingVolker Lendecke2010-03-251-0/+6
|
* s3: Make sure our CLEAR_IF_FIRST optimization works for serverid.tdbVolker Lendecke2010-03-251-0/+16
| | | | | | In the child, we fully re-open serverid.tdb, which leads to one fcntl lock for CLEAR_IF_FIRST detection per smbd. This opens the tdb in the parent and holds it, so that tdb_reopen_all correctly catches the CLEAR_IF_FIRST bit.
* s3: Fix a long-standing problem with recycled PIDsVolker Lendecke2010-03-101-0/+293
When a samba server process dies hard, it has no chance to clean up its entries in locking.tdb, brlock.tdb, connections.tdb and sessionid.tdb. For locking.tdb and brlock.tdb Samba is robust by checking every time we read an entry from the database if the corresponding process still exists. If it does not exist anymore, the entry is deleted. This is not 100% failsafe though: On systems with a limited PID space there is a non-zero chance that between the smbd's death and the fresh access, the PID is recycled by another long-running process. This renders all files that had been locked by the killed smbd potentially unusable until the new process also dies. This patch is supposed to fix the problem the following way: Every process ID in every database is augmented by a random 64-bit number that is stored in a serverid.tdb. Whenever we need to check if a process still exists we know its PID and the 64-bit number. We look up the PID in serverid.tdb and compare the 64-bit number. If it's the same, the process still is a valid smbd holding the lock. If it is different, a new smbd has taken over. I believe this is safe against an smbd that has died hard and the PID has been taken over by a non-samba process. This process would not have registered itself with a fresh 64-bit number in serverid.tdb, so the old one still exists in serverid.tdb. We protect against this case by the parent smbd taking care of deregistering PIDs from serverid.tdb and the fact that serverid.tdb is CLEAR_IF_FIRST. CLEAR_IF_FIRST does not work in a cluster, so the automatic cleanup does not work when all smbds are restarted. For this, "net serverid wipe" has to be run before smbd starts up. As a convenience, "net serverid wipedbs" also cleans up sessionid.tdb and connections.tdb. While there, this also cleans up overloading connections.tdb with all the process entries just for messaging_send_all(). Volker