diff options
author | Jeremy Allison <jra@samba.org> | 2002-10-04 22:53:30 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-10-04 22:53:30 +0000 |
commit | 9c94d1a2f72b6fcbbd056804837fc8719806491b (patch) | |
tree | 71d5b825cc8bebd43bf319b604a003bcddf3cdd7 /source3/printing | |
parent | fac6a13fd3cee8f3f4f7f8e3a2dbb700181c67c3 (diff) | |
download | samba-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')
-rw-r--r-- | source3/printing/nt_printing.c | 4 | ||||
-rw-r--r-- | source3/printing/printing.c | 14 |
2 files changed, 9 insertions, 9 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 58eba9d87e..fcb493a614 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -287,7 +287,7 @@ BOOL nt_printing_init(void) local_pid = sys_getpid(); /* handle a Samba upgrade */ - tdb_lock_bystring(tdb_drivers, vstring); + tdb_lock_bystring(tdb_drivers, vstring, 0); { int32 vers_id; @@ -362,7 +362,7 @@ uint32 update_c_setprinter(BOOL initialize) int32 c_setprinter; int32 printer_count = 0; - tdb_lock_bystring(tdb_printers, GLOBAL_C_SETPRINTER); + tdb_lock_bystring(tdb_printers, GLOBAL_C_SETPRINTER, 0); /* Traverse the tdb, counting the printers */ tdb_traverse(tdb_printers, traverse_counting_printers, (void *)&printer_count); 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; |