summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-03-07 21:51:59 +0000
committerJeremy Allison <jra@samba.org>2002-03-07 21:51:59 +0000
commit024e69da0b4bbbe4112d3ce5526f90eb0b85bba0 (patch)
tree01ba25a356d7c3aa0616f8a9467246401e45b852 /source3/printing
parentf920d9e3c5d284fade738fb02d9abc467c5c0989 (diff)
downloadsamba-024e69da0b4bbbe4112d3ce5526f90eb0b85bba0.tar.gz
samba-024e69da0b4bbbe4112d3ce5526f90eb0b85bba0.tar.bz2
samba-024e69da0b4bbbe4112d3ce5526f90eb0b85bba0.zip
Fix for machines that have their time changed forward, then back. Ensure
that any cached lpq information gathered during that time doesn't stay around for longer than 1 hour. Jeremy. (This used to be commit 39fca711a5cf15a03d6c79639b202712d1749a64)
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/printing.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 7d4a52c351..81a44d7e69 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -811,14 +811,26 @@ int print_job_write(int jobid, const char *buf, int size)
static BOOL print_cache_expired(int snum)
{
fstring key;
- time_t t2, t = time(NULL);
+ time_t last_qscan_time, time_now = time(NULL);
- slprintf(key, sizeof(key)-1, "CACHE/%s", lp_servicename(snum));
- t2 = tdb_fetch_int32(tdb, key);
- if (t2 == ((time_t)-1) || (t - t2) >= lp_lpqcachetime()) {
+ slprintf(key, sizeof(key), "CACHE/%s", lp_servicename(snum));
+ last_qscan_time = (time_t)tdb_fetch_int32(tdb, key);
+
+ /*
+ * Invalidate the queue for 3 reasons.
+ * (1). last queue scan time == -1.
+ * (2). Current time - last queue scan time > allowed cache time.
+ * (3). last queue scan time > current time + MAX_CACHE_VALID_TIME (1 hour by default).
+ * This last test picks up machines for which the clock has been moved
+ * forward, an lpq scan done and then the clock moved back. Otherwise
+ * that last lpq scan would stay around for a loooong loooong time... :-). JRA.
+ */
+
+ if (last_qscan_time == ((time_t)-1) || (time_now - last_qscan_time) >= lp_lpqcachetime() ||
+ last_qscan_time > (time_now + MAX_CACHE_VALID_TIME)) {
DEBUG(3, ("print cache expired for queue %s \
-(last_cache = %d, time now = %d, qcachetime = %d)\n", lp_servicename(snum),
- (int)t2, (int)t, (int)lp_lpqcachetime() ));
+(last_qscan_time = %d, time now = %d, qcachetime = %d)\n", lp_servicename(snum),
+ (int)last_qscan_time, (int)time_now, (int)lp_lpqcachetime() ));
return True;
}
return False;