diff options
author | Volker Lendecke <vlendec@samba.org> | 2007-02-07 13:26:13 +0000 |
---|---|---|
committer | Volker Lendecke <vlendec@samba.org> | 2007-02-07 13:26:13 +0000 |
commit | 2a03482fc477206064c2d779c3e4658ef64d605e (patch) | |
tree | ece8071efc114679794626d6d8ad4abf124f7f9b | |
parent | 7f21c8e613e089944d0078ede543bac6d68d2497 (diff) | |
download | samba-2a03482fc477206064c2d779c3e4658ef64d605e.tar.gz samba-2a03482fc477206064c2d779c3e4658ef64d605e.tar.xz samba-2a03482fc477206064c2d779c3e4658ef64d605e.zip |
r21219: Speed up the initial startup time of smbd on systems with loaded disk
subsystems. See the comment in the diff.
Volker
-rw-r--r-- | source/registry/reg_db.c | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/source/registry/reg_db.c b/source/registry/reg_db.c index b05e4957b8b..954cb6cf786 100644 --- a/source/registry/reg_db.c +++ b/source/registry/reg_db.c @@ -96,6 +96,20 @@ static BOOL init_registry_data( void ) int i; const char *p, *p2; UNISTR2 data; + + /* + * There are potentially quite a few store operations which are all + * indiviually wrapped in tdb transactions. Wrapping them in a single + * transaction gives just a single transaction_commit() to actually do + * its fsync()s. See tdb/common/transaction.c for info about nested + * transaction behaviour. + */ + + if ( tdb_transaction_start( tdb_reg ) == -1 ) { + DEBUG(0, ("init_registry_data: tdb_transaction_start " + "failed\n")); + return False; + } /* loop over all of the predefined paths and add each component */ @@ -135,14 +149,14 @@ static BOOL init_registry_data( void ) if ( !(subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR )) ) { DEBUG(0,("talloc() failure!\n")); - return False; + goto fail; } regdb_fetch_keys( base, subkeys ); if ( *subkeyname ) regsubkey_ctr_addkey( subkeys, subkeyname ); if ( !regdb_store_keys( base, subkeys )) - return False; + goto fail; TALLOC_FREE( subkeys ); } @@ -153,7 +167,7 @@ static BOOL init_registry_data( void ) for ( i=0; builtin_registry_values[i].path != NULL; i++ ) { if ( !(values = TALLOC_ZERO_P( NULL, REGVAL_CTR )) ) { DEBUG(0,("talloc() failure!\n")); - return False; + goto fail; } regdb_fetch_values( builtin_registry_values[i].path, values ); @@ -190,7 +204,22 @@ static BOOL init_registry_data( void ) TALLOC_FREE( values ); } + if (tdb_transaction_commit( tdb_reg ) == -1) { + DEBUG(0, ("init_registry_data: Could not commit " + "transaction\n")); + return False; + } + return True; + + fail: + + if (tdb_transaction_cancel( tdb_reg ) == -1) { + smb_panic("init_registry_data: tdb_transaction_cancel " + "failed\n"); + } + + return False; } /*********************************************************************** |