svn commit: samba r7692 - in branches/SAMBA_3_0/source: printing registry

jerry at samba.org jerry at samba.org
Fri Jun 17 15:53:02 GMT 2005


Author: jerry
Date: 2005-06-17 15:53:01 +0000 (Fri, 17 Jun 2005)
New Revision: 7692

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7692

Log:
start versioning the registry.tdb file since it can be modified now


Modified:
   branches/SAMBA_3_0/source/printing/nt_printing.c
   branches/SAMBA_3_0/source/registry/reg_db.c


Changeset:
Modified: branches/SAMBA_3_0/source/printing/nt_printing.c
===================================================================
--- branches/SAMBA_3_0/source/printing/nt_printing.c	2005-06-17 15:35:31 UTC (rev 7691)
+++ branches/SAMBA_3_0/source/printing/nt_printing.c	2005-06-17 15:53:01 UTC (rev 7692)
@@ -412,12 +412,11 @@
 
 BOOL nt_printing_init(void)
 {
-	static pid_t local_pid;
 	const char *vstring = "INFO/version";
 	WERROR win_rc;
 	uint32 vers_id;
 
-	if (tdb_drivers && tdb_printers && tdb_forms && local_pid == sys_getpid())
+	if ( tdb_drivers && tdb_printers && tdb_forms )
 		return True;
  
 	if (tdb_drivers)
@@ -447,8 +446,6 @@
 		return False;
 	}
  
-	local_pid = sys_getpid();
- 
 	/* handle a Samba upgrade */
 	tdb_lock_bystring(tdb_drivers, vstring, 0);
 

Modified: branches/SAMBA_3_0/source/registry/reg_db.c
===================================================================
--- branches/SAMBA_3_0/source/registry/reg_db.c	2005-06-17 15:35:31 UTC (rev 7691)
+++ branches/SAMBA_3_0/source/registry/reg_db.c	2005-06-17 15:53:01 UTC (rev 7692)
@@ -55,6 +55,8 @@
 	"HKU",
 	"HKCR",
 	 NULL };
+
+#define REGVER_V1	1	/* first db version with write support */
 	
 /***********************************************************************
  Open the registry data in the tdb
@@ -125,15 +127,15 @@
  
 BOOL init_registry_db( void )
 {
-	static pid_t local_pid;
+	const char *vstring = "INFO/version";
+	uint32 vers_id;
 
-	if (tdb_reg && local_pid == sys_getpid())
+	if ( tdb_reg )
 		return True;
 
 	/* placeholder tdb; reinit upon startup */
 	
-	tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST, O_RDWR, 0600);
-	if ( !tdb_reg ) 
+	if ( !(tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600)) )
 	{
 		tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
 		if ( !tdb_reg ) {
@@ -145,15 +147,19 @@
 		DEBUG(10,("init_registry: Successfully created registry tdb\n"));
 	}
 		
-	/* create the registry here */
 
-	if ( !init_registry_data() ) {
-		DEBUG(0,("init_registry: Failed to initiailize data in registry!\n"));
-		return False;
+	vers_id = tdb_fetch_int32(tdb_reg, vstring);
+
+	if ( vers_id != REGVER_V1 ) {
+
+		/* create the registry here */
+
+		if ( !init_registry_data() ) {
+			DEBUG(0,("init_registry: Failed to initiailize data in registry!\n"));
+			return False;
+		}
 	}
 
-	local_pid = sys_getpid();
-		
 	return True;
 }
 



More information about the samba-cvs mailing list