summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-04-17 11:49:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:16:23 -0500
commite17302200c138eec7df504a7f4b2bde46073a810 (patch)
tree0973275cef43fef24af3d07530f4464ec0702427 /source3
parent76a2ac3ac324466962adbeaf1f2a85572f631c0a (diff)
downloadsamba-e17302200c138eec7df504a7f4b2bde46073a810.tar.gz
samba-e17302200c138eec7df504a7f4b2bde46073a810.tar.bz2
samba-e17302200c138eec7df504a7f4b2bde46073a810.zip
r15101: Little step towards getting Samba4 tdb into 3: tdb_lock_bystring does not
have the timeout argument in Samba4. Add a new routine tdb_lock_bystring_with_timeout. Volker (This used to be commit b9c6e3f55602fa505859a4b2cd137b74105d685f)
Diffstat (limited to 'source3')
-rw-r--r--source3/groupdb/mapping.c2
-rw-r--r--source3/lib/account_pol.c2
-rw-r--r--source3/lib/gencache.c2
-rw-r--r--source3/lib/sharesec.c2
-rw-r--r--source3/passdb/pdb_tdb.c6
-rw-r--r--source3/passdb/secrets.c4
-rw-r--r--source3/printing/notify.c2
-rw-r--r--source3/printing/nt_printing.c2
-rw-r--r--source3/printing/printing.c10
-rw-r--r--source3/rpc_server/srv_eventlog_lib.c4
-rw-r--r--source3/rpc_server/srv_eventlog_nt.c2
-rw-r--r--source3/tdb/tdbutil.c18
12 files changed, 32 insertions, 24 deletions
diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c
index 5569dbf4ed..c701ef165d 100644
--- a/source3/groupdb/mapping.c
+++ b/source3/groupdb/mapping.c
@@ -63,7 +63,7 @@ static BOOL init_group_mapping(void)
}
/* handle a Samba upgrade */
- tdb_lock_bystring(tdb, vstring, 0);
+ tdb_lock_bystring(tdb, vstring);
/* Cope with byte-reversed older versions of the db. */
vers_id = tdb_fetch_int32(tdb, vstring);
diff --git a/source3/lib/account_pol.c b/source3/lib/account_pol.c
index 0694b1c3f8..6bf7346fe7 100644
--- a/source3/lib/account_pol.c
+++ b/source3/lib/account_pol.c
@@ -269,7 +269,7 @@ BOOL init_account_policy(void)
}
/* handle a Samba upgrade */
- tdb_lock_bystring(tdb, vstring,0);
+ tdb_lock_bystring(tdb, vstring);
if (!tdb_fetch_uint32(tdb, vstring, &version) || version != DATABASE_VERSION) {
tdb_store_uint32(tdb, vstring, DATABASE_VERSION);
diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c
index 89badcd4f9..6725ed4c12 100644
--- a/source3/lib/gencache.c
+++ b/source3/lib/gencache.c
@@ -372,7 +372,7 @@ int gencache_lock_entry( const char *key )
if (!gencache_init())
return -1;
- return tdb_lock_bystring(cache, key, 0);
+ return tdb_lock_bystring(cache, key);
}
/********************************************************************
diff --git a/source3/lib/sharesec.c b/source3/lib/sharesec.c
index b98e304582..8105d5c37a 100644
--- a/source3/lib/sharesec.c
+++ b/source3/lib/sharesec.c
@@ -55,7 +55,7 @@ BOOL share_info_db_init(void)
}
/* handle a Samba upgrade */
- tdb_lock_bystring(share_tdb, vstring, 0);
+ tdb_lock_bystring(share_tdb, vstring);
/* Cope with byte-reversed older versions of the db. */
vers_id = tdb_fetch_int32(share_tdb, vstring);
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index 94ae328812..ba8124d392 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -694,7 +694,7 @@ static BOOL tdbsam_convert(int32 from)
BOOL ret;
/* handle a Samba upgrade */
- tdb_lock_bystring(tdbsam, vstring, 0);
+ tdb_lock_bystring(tdbsam, vstring);
/* Enumerate all records and convert them */
key = tdb_firstkey(tdbsam);
@@ -1420,7 +1420,7 @@ static NTSTATUS tdbsam_rename_sam_account(struct pdb_methods *my_methods,
interim_account = True;
- if ( tdb_lock_bystring(tdbsam, newname, 30) == -1 ) {
+ if ( tdb_lock_bystring_with_timeout(tdbsam, newname, 30) == -1 ) {
goto done;
}
@@ -1492,7 +1492,7 @@ static BOOL init_idmap_tdb(TDB_CONTEXT *tdb)
{
int32 version;
- if (tdb_lock_bystring(tdb, "IDMAP_VERSION", 0) != 0) {
+ if (tdb_lock_bystring(tdb, "IDMAP_VERSION") != 0) {
DEBUG(0, ("Could not lock IDMAP_VERSION\n"));
return False;
}
diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c
index a288e7d169..32793dea58 100644
--- a/source3/passdb/secrets.c
+++ b/source3/passdb/secrets.c
@@ -245,7 +245,7 @@ BOOL secrets_lock_trust_account_password(const char *domain, BOOL dolock)
return False;
if (dolock)
- return (tdb_lock_bystring(tdb, trust_keystr(domain),0) == 0);
+ return (tdb_lock_bystring(tdb, trust_keystr(domain)) == 0);
else
tdb_unlock_bystring(tdb, trust_keystr(domain));
return True;
@@ -774,7 +774,7 @@ BOOL secrets_named_mutex(const char *name, unsigned int timeout)
if (!secrets_init())
return False;
- ret = tdb_lock_bystring(tdb, name, timeout);
+ ret = tdb_lock_bystring_with_timeout(tdb, name, timeout);
if (ret == 0)
DEBUG(10,("secrets_named_mutex: got mutex for %s\n", name ));
diff --git a/source3/printing/notify.c b/source3/printing/notify.c
index e71d9e6f25..f27eb2011f 100644
--- a/source3/printing/notify.c
+++ b/source3/printing/notify.c
@@ -520,7 +520,7 @@ BOOL print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, size_t
return False;
tdb = pdb->tdb;
- if (tdb_read_lock_bystring(tdb, NOTIFY_PID_LIST_KEY, 10) == -1) {
+ if (tdb_read_lock_bystring_with_timeout(tdb, NOTIFY_PID_LIST_KEY, 10) == -1) {
DEBUG(0,("print_notify_pid_list: Failed to lock printer %s database\n",
printername));
if (pdb)
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 727d226e2a..1a664fbb34 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -673,7 +673,7 @@ uint32 update_c_setprinter(BOOL initialize)
int32 c_setprinter;
int32 printer_count = 0;
- tdb_lock_bystring(tdb_printers, GLOBAL_C_SETPRINTER, 0);
+ tdb_lock_bystring(tdb_printers, GLOBAL_C_SETPRINTER);
/* Traverse the tdb, counting the printers */
tdb_traverse(tdb_printers, traverse_counting_printers, (void *)&printer_count);
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index d9acd2de72..b131727f8a 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -197,7 +197,7 @@ BOOL print_backend_init(void)
pdb = get_print_db_byname(lp_const_servicename(snum));
if (!pdb)
continue;
- if (tdb_lock_bystring(pdb->tdb, sversion, 0) == -1) {
+ if (tdb_lock_bystring(pdb->tdb, sversion) == -1) {
DEBUG(0,("print_backend_init: Failed to open printer %s database\n", lp_const_servicename(snum) ));
release_print_db(pdb);
return False;
@@ -1291,7 +1291,7 @@ static void print_queue_update_with_lock( const char *sharename,
slprintf(keystr, sizeof(keystr) - 1, "LOCK/%s", sharename);
/* Only wait 10 seconds for this. */
- if (tdb_lock_bystring(pdb->tdb, keystr, 10) == -1) {
+ if (tdb_lock_bystring_with_timeout(pdb->tdb, keystr, 10) == -1) {
DEBUG(0,("print_queue_update_with_lock: Failed to lock printer %s database\n", sharename));
release_print_db(pdb);
return;
@@ -1563,7 +1563,7 @@ BOOL print_notify_register_pid(int snum)
tdb = pdb->tdb;
}
- if (tdb_lock_bystring(tdb, NOTIFY_PID_LIST_KEY, 10) == -1) {
+ if (tdb_lock_bystring_with_timeout(tdb, NOTIFY_PID_LIST_KEY, 10) == -1) {
DEBUG(0,("print_notify_register_pid: Failed to lock printer %s\n",
printername));
if (pdb)
@@ -1653,7 +1653,7 @@ BOOL print_notify_deregister_pid(int snum)
tdb = pdb->tdb;
}
- if (tdb_lock_bystring(tdb, NOTIFY_PID_LIST_KEY, 10) == -1) {
+ if (tdb_lock_bystring_with_timeout(tdb, NOTIFY_PID_LIST_KEY, 10) == -1) {
DEBUG(0,("print_notify_register_pid: Failed to lock \
printer %s database\n", printername));
if (pdb)
@@ -2205,7 +2205,7 @@ static BOOL allocate_print_jobid(struct tdb_print_db *pdb, int snum, const char
for (i = 0; i < 3; i++) {
/* Lock the database - only wait 20 seconds. */
- if (tdb_lock_bystring(pdb->tdb, "INFO/nextjob", 20) == -1) {
+ if (tdb_lock_bystring_with_timeout(pdb->tdb, "INFO/nextjob", 20) == -1) {
DEBUG(0,("allocate_print_jobid: failed to lock printing database %s\n", sharename));
return False;
}
diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c
index b3d94901ba..acae1c94e9 100644
--- a/source3/rpc_server/srv_eventlog_lib.c
+++ b/source3/rpc_server/srv_eventlog_lib.c
@@ -163,7 +163,7 @@ BOOL make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed,
if ( mem_ctx == NULL )
return False; /* can't allocate memory indicates bigger problems */
/* lock */
- tdb_lock_bystring( the_tdb, EVT_NEXT_RECORD, 1 );
+ tdb_lock_bystring_with_timeout( the_tdb, EVT_NEXT_RECORD, 1 );
/* read */
end_record = tdb_fetch_int32( the_tdb, EVT_NEXT_RECORD );
start_record = tdb_fetch_int32( the_tdb, EVT_OLDEST_ENTRY );
@@ -489,7 +489,7 @@ int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee )
/* need to read the record number and insert it into the entry here */
/* lock */
- tdb_lock_bystring( the_tdb, EVT_NEXT_RECORD, 1 );
+ tdb_lock_bystring_with_timeout( the_tdb, EVT_NEXT_RECORD, 1 );
/* read */
next_record = tdb_fetch_int32( the_tdb, EVT_NEXT_RECORD );
diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c
index a8b9c66717..284ee37348 100644
--- a/source3/rpc_server/srv_eventlog_nt.c
+++ b/source3/rpc_server/srv_eventlog_nt.c
@@ -146,7 +146,7 @@ static BOOL get_num_records_hook( EVENTLOG_INFO * info )
/* lock the tdb since we have to get 2 records */
- tdb_lock_bystring( ELOG_TDB_CTX(info->etdb), EVT_NEXT_RECORD, 1 );
+ tdb_lock_bystring_with_timeout( ELOG_TDB_CTX(info->etdb), EVT_NEXT_RECORD, 1 );
next_record = tdb_fetch_int32( ELOG_TDB_CTX(info->etdb), EVT_NEXT_RECORD);
oldest_record = tdb_fetch_int32( ELOG_TDB_CTX(info->etdb), EVT_OLDEST_ENTRY);
tdb_unlock_bystring( ELOG_TDB_CTX(info->etdb), EVT_NEXT_RECORD);
diff --git a/source3/tdb/tdbutil.c b/source3/tdb/tdbutil.c
index 09baff072f..f1809229f8 100644
--- a/source3/tdb/tdbutil.c
+++ b/source3/tdb/tdbutil.c
@@ -104,11 +104,19 @@ int tdb_chainlock_with_timeout( TDB_CONTEXT *tdb, TDB_DATA key, unsigned int tim
Lock a chain by string. Return -1 if timeout or lock failed.
****************************************************************************/
-int tdb_lock_bystring(TDB_CONTEXT *tdb, const char *keyval, unsigned int timeout)
+int tdb_lock_bystring(TDB_CONTEXT *tdb, const char *keyval)
{
TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
- return tdb_chainlock_with_timeout_internal(tdb, key, timeout, F_WRLCK);
+ return tdb_chainlock(tdb, key);
+}
+
+int tdb_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval,
+ int timeout)
+{
+ TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
+
+ return tdb_chainlock_with_timeout(tdb, key, timeout);
}
/****************************************************************************
@@ -126,7 +134,7 @@ void tdb_unlock_bystring(TDB_CONTEXT *tdb, const char *keyval)
Read lock a chain by string. Return -1 if timeout or lock failed.
****************************************************************************/
-int tdb_read_lock_bystring(TDB_CONTEXT *tdb, const char *keyval, unsigned int timeout)
+int tdb_read_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval, unsigned int timeout)
{
TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1);
@@ -311,7 +319,7 @@ int32 tdb_change_int32_atomic(TDB_CONTEXT *tdb, const char *keystr, int32 *oldva
int32 val;
int32 ret = -1;
- if (tdb_lock_bystring(tdb, keystr,0) == -1)
+ if (tdb_lock_bystring(tdb, keystr) == -1)
return -1;
if ((val = tdb_fetch_int32(tdb, keystr)) == -1) {
@@ -352,7 +360,7 @@ BOOL tdb_change_uint32_atomic(TDB_CONTEXT *tdb, const char *keystr, uint32 *oldv
uint32 val;
BOOL ret = False;
- if (tdb_lock_bystring(tdb, keystr,0) == -1)
+ if (tdb_lock_bystring(tdb, keystr) == -1)
return False;
if (!tdb_fetch_uint32(tdb, keystr, &val)) {