summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-10-10 06:45:09 +0000
committerAndrew Tridgell <tridge@samba.org>2000-10-10 06:45:09 +0000
commit2d33e87424197b993e8e7d218c0945cc2b66078a (patch)
treeec4eeb9c527acd59c9dfdc72cb6be03a5a361540 /source3/printing
parent2a9ce69f3b4a020bd1442901625562c6391746cd (diff)
downloadsamba-2d33e87424197b993e8e7d218c0945cc2b66078a.tar.gz
samba-2d33e87424197b993e8e7d218c0945cc2b66078a.tar.bz2
samba-2d33e87424197b993e8e7d218c0945cc2b66078a.zip
got rid of tdb_writelock() and instead lock a chain. tdb_writelock()
is conceptually flawed (This used to be commit 6e4a3585521b7e5928298bd0f1418ff9fbcacfb4)
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/nt_printing.c9
-rw-r--r--source3/printing/printing.c16
2 files changed, 14 insertions, 11 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 69e9233d27..bd968c66ab 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -50,6 +50,7 @@ open the NT printing tdb
BOOL nt_printing_init(void)
{
static pid_t local_pid;
+ char *vstring = "INFO/version";
if (tdb && local_pid == sys_getpid()) return True;
tdb = tdb_open(lock_path("ntdrivers.tdb"), 0, 0, O_RDWR|O_CREAT, 0600);
@@ -61,12 +62,12 @@ BOOL nt_printing_init(void)
local_pid = sys_getpid();
/* handle a Samba upgrade */
- tdb_writelock(tdb);
- if (tdb_fetch_int(tdb, "INFO/version") != DATABASE_VERSION) {
+ tdb_lock_bystring(tdb, vstring);
+ if (tdb_fetch_int(tdb, vstring) != DATABASE_VERSION) {
tdb_traverse(tdb, (tdb_traverse_func)tdb_delete, NULL);
- tdb_store_int(tdb, "INFO/version", DATABASE_VERSION);
+ tdb_store_int(tdb, vstring, DATABASE_VERSION);
}
- tdb_writeunlock(tdb);
+ tdb_unlock_bystring(tdb, vstring);
return True;
}
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 28b5934c37..b884c5ac99 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -68,6 +68,8 @@ Does not survive a fork
****************************************************************************/
BOOL print_backend_init(void)
{
+ char *sversion = "INFO/version";
+
if (tdb && local_pid == sys_getpid()) return True;
tdb = tdb_open(lock_path("printing.tdb"), 0, 0, O_RDWR|O_CREAT, 0600);
if (!tdb) {
@@ -76,12 +78,12 @@ BOOL print_backend_init(void)
local_pid = sys_getpid();
/* handle a Samba upgrade */
- tdb_writelock(tdb);
- if (tdb_fetch_int(tdb, "INFO/version") != PRINT_DATABASE_VERSION) {
+ tdb_lock_bystring(tdb, sversion);
+ if (tdb_fetch_int(tdb, sversion) != PRINT_DATABASE_VERSION) {
tdb_traverse(tdb, (tdb_traverse_func)tdb_delete, NULL);
- tdb_store_int(tdb, "INFO/version", PRINT_DATABASE_VERSION);
+ tdb_store_int(tdb, sversion, PRINT_DATABASE_VERSION);
}
- tdb_writeunlock(tdb);
+ tdb_unlock_bystring(tdb, sversion);
return nt_printing_init();
}
@@ -678,7 +680,7 @@ int print_job_start(struct current_user *user, int snum, char *jobname)
fstrcpy(pjob.qname, lp_servicename(snum));
/* lock the database */
- tdb_writelock(tdb);
+ tdb_lock_bystring(tdb, "INFO/nextjob");
next_jobnum:
next_jobid = tdb_fetch_int(tdb, "INFO/nextjob");
@@ -712,7 +714,7 @@ int print_job_start(struct current_user *user, int snum, char *jobname)
print_job_store(jobid, &pjob);
- tdb_writeunlock(tdb);
+ tdb_unlock_bystring(tdb, "INFO/nextjob");
/*
* If the printer is marked as postscript output a leading
@@ -732,7 +734,7 @@ int print_job_start(struct current_user *user, int snum, char *jobname)
tdb_delete(tdb, print_key(jobid));
}
- tdb_writeunlock(tdb);
+ tdb_unlock_bystring(tdb, "INFO/nextjob");
return -1;
}