mirror of
https://github.com/samba-team/samba.git
synced 2025-11-27 08:23:49 +03:00
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 commit is contained in:
committed by
Gerald (Jerry) Carter
parent
d3d388180d
commit
b9c6e3f556
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 ));
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user