summaryrefslogtreecommitdiff
path: root/source3/printing/printing.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-10-04 22:53:30 +0000
committerJeremy Allison <jra@samba.org>2002-10-04 22:53:30 +0000
commit9c94d1a2f72b6fcbbd056804837fc8719806491b (patch)
tree71d5b825cc8bebd43bf319b604a003bcddf3cdd7 /source3/printing/printing.c
parentfac6a13fd3cee8f3f4f7f8e3a2dbb700181c67c3 (diff)
downloadsamba-9c94d1a2f72b6fcbbd056804837fc8719806491b.tar.gz
samba-9c94d1a2f72b6fcbbd056804837fc8719806491b.tar.bz2
samba-9c94d1a2f72b6fcbbd056804837fc8719806491b.zip
Add a timeout to tdb_lock_bystring(). Ensure we never have more than
MAX_PRINT_JOBS in a queue. Jeremy. (This used to be commit bb58a08af459b4abae9d53ab98c15f40638ce52b)
Diffstat (limited to 'source3/printing/printing.c')
-rw-r--r--source3/printing/printing.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 6474c92c69..91851a37f8 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -257,7 +257,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) == -1) {
+ if (tdb_lock_bystring(pdb->tdb, sversion, 0) == -1) {
DEBUG(0,("print_backend_init: Failed to open printer %s database\n", lp_const_servicename(snum) ));
return False;
}
@@ -883,7 +883,8 @@ static void print_queue_update(int snum)
/* Lock the queue for the database update */
slprintf(keystr, sizeof(keystr) - 1, "LOCK/%s", printer_name);
- if (tdb_lock_bystring(pdb->tdb, keystr) == -1) {
+ /* Only wait 10 seconds for this. */
+ if (tdb_lock_bystring(pdb->tdb, keystr, 10) == -1) {
DEBUG(0,("print_queue_update: Failed to lock printer %s database\n", printer_name));
release_print_db(pdb);
return;
@@ -1380,9 +1381,8 @@ static int get_queue_status(int snum, print_status_struct *status)
data = tdb_fetch(pdb->tdb, key);
release_print_db(pdb);
if (data.dptr) {
- if (data.dsize == sizeof(print_status_struct)) {
+ if (data.dsize == sizeof(print_status_struct))
memcpy(status, data.dptr, sizeof(print_status_struct));
- }
SAFE_FREE(data.dptr);
}
return status->qcount;
@@ -1465,7 +1465,7 @@ uint32 print_job_start(struct current_user *user, int snum, char *jobname, NT_DE
}
/* Insure the maximum queue size is not violated */
- if (lp_maxprintjobs(snum) && (njobs = print_queue_length(snum,NULL)) > lp_maxprintjobs(snum)) {
+ if ((njobs = print_queue_length(snum,NULL)) > lp_maxprintjobs(snum)) {
DEBUG(3, ("print_job_start: number of jobs (%d) larger than max printjobs per queue (%d).\n",
njobs, lp_maxprintjobs(snum) ));
release_print_db(pdb);
@@ -1473,8 +1473,8 @@ uint32 print_job_start(struct current_user *user, int snum, char *jobname, NT_DE
return (uint32)-1;
}
- /* Lock the database */
- if (tdb_lock_bystring(pdb->tdb, "INFO/nextjob") == -1) {
+ /* Lock the database - only wait 20 seconds. */
+ if (tdb_lock_bystring(pdb->tdb, "INFO/nextjob", 20) == -1) {
DEBUG(0,("print_job_start: failed to lock printing database %s\n", printername ));
release_print_db(pdb);
return (uint32)-1;