summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
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;
}