diff options
author | Jeremy Allison <jra@samba.org> | 2003-03-20 00:52:37 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2003-03-20 00:52:37 +0000 |
commit | bf795b684e608f82db822e0759e7b69afd451b65 (patch) | |
tree | 0ebca706c3507d48ca8ff8fe5ec486bf34434ecc | |
parent | 55681422e97ede0ff9446925c7678d6254b13878 (diff) | |
download | samba-bf795b684e608f82db822e0759e7b69afd451b65.tar.gz samba-bf795b684e608f82db822e0759e7b69afd451b65.tar.xz samba-bf795b684e608f82db822e0759e7b69afd451b65.zip |
lib/messages.c: Check return from chainlock before modifying message queue.
Apply the job returned limit across all requests for job queues.
Jeremy.
-rw-r--r-- | source/lib/messages.c | 4 | ||||
-rw-r--r-- | source/printing/printing.c | 5 | ||||
-rw-r--r-- | source/rpc_server/srv_spoolss_nt.c | 6 |
3 files changed, 8 insertions, 7 deletions
diff --git a/source/lib/messages.c b/source/lib/messages.c index 5ff0e45c61f..c078472880d 100644 --- a/source/lib/messages.c +++ b/source/lib/messages.c @@ -315,7 +315,9 @@ static BOOL retrieve_all_messages(char **msgs_buf, size_t *total_len) kbuf = message_key_pid(sys_getpid()); - tdb_chainlock(tdb, kbuf); + if (tdb_chainlock(tdb, kbuf) == -1) + return False; + dbuf = tdb_fetch(tdb, kbuf); /* * Replace with an empty record to keep the allocated diff --git a/source/printing/printing.c b/source/printing/printing.c index 26ea52e35a3..99578975ca3 100644 --- a/source/printing/printing.c +++ b/source/printing/printing.c @@ -1959,6 +1959,7 @@ int print_queue_status(int snum, TDB_DATA data, key; const char *printername; struct tdb_print_db *pdb; + int max_reported_jobs = lp_max_reported_jobs(snum); /* make sure the database is up to date */ @@ -2033,6 +2034,10 @@ int print_queue_status(int snum, QSORT_CAST(printjob_comp)); *queue = tstruct.queue; + + if (max_reported_jobs && tstruct.qcount > max_reported_jobs) + tstruct.qcount = max_reported_jobs; + return tstruct.qcount; } diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c index 5d63f27d235..a7b73b5ac9d 100644 --- a/source/rpc_server/srv_spoolss_nt.c +++ b/source/rpc_server/srv_spoolss_nt.c @@ -6353,7 +6353,6 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO int snum; print_status_struct prt_status; print_queue_struct *queue=NULL; - int max_rep_jobs; /* that's an [in out] buffer */ spoolss_move_buffer(q_u->buffer, &r_u->buffer); @@ -6367,8 +6366,6 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; - max_rep_jobs = lp_max_reported_jobs(snum); - *returned = print_queue_status(snum, &queue, &prt_status); DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message)); @@ -6377,9 +6374,6 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO return WERR_OK; } - if (max_rep_jobs && (*returned > max_rep_jobs)) - *returned = max_rep_jobs; - switch (level) { case 1: return enumjobs_level1(queue, snum, buffer, offered, needed, returned); |