summaryrefslogtreecommitdiff
path: root/source3/printing/printer_list.c
diff options
context:
space:
mode:
authorBjörn Jacke <bj@sernet.de>2010-09-15 18:23:50 +0200
committerBjörn Jacke <bj@sernet.de>2010-09-15 22:43:24 +0200
commitaa7df7b7379cc437515774d0ea91fb106aba5dc8 (patch)
tree0f76ea86aaa23887623368fcca595a27eb4200e1 /source3/printing/printer_list.c
parentadf8ca6ff8c6dbc365034a27f8d27a15aa533f97 (diff)
downloadsamba-aa7df7b7379cc437515774d0ea91fb106aba5dc8.tar.gz
samba-aa7df7b7379cc437515774d0ea91fb106aba5dc8.tar.bz2
samba-aa7df7b7379cc437515774d0ea91fb106aba5dc8.zip
s3/printing: make clock jump save and use monotonic time for cache timeout
Diffstat (limited to 'source3/printing/printer_list.c')
-rw-r--r--source3/printing/printer_list.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/source3/printing/printer_list.c b/source3/printing/printer_list.c
index 6392755cf5..d02ab88663 100644
--- a/source3/printing/printer_list.c
+++ b/source3/printing/printer_list.c
@@ -218,27 +218,28 @@ done:
bool printer_list_need_refresh(void)
{
NTSTATUS status;
- time_t now = time(NULL);
+ time_t now = time_mono(NULL);
time_t last_refresh;
+ int timediff;
status = printer_list_get_last_refresh(&last_refresh);
if (!NT_STATUS_IS_OK(status)) {
return true;
}
+ timediff = now - last_refresh;
- if (now > last_refresh) {
- /* if refresh occurred last than 1 seconds ago,
- * then we probably don't need to refresh */
- if ((now - last_refresh) < 1) {
- return false;
- }
- } else {
- /* last_refresh newer than now, wow, someone just updated the
- * cache under our nose, do not do again. */
- return false;
+ if (timediff > 1 ) {
+ /* if refresh occurred more than 1s (TODO:use lp_printcap_cache_time) ago,
+ * then we need to refresh */
+ return true;
+ } else if (timediff < 0) {
+ /* last_refresh newer than now. Seems we have no monotonic
+ * clock and the clock was adjusted backwards.
+ * we need to refresh which also resets last_refresh */
+ return true;
}
- return true;
+ return false;
}
NTSTATUS printer_list_mark_reload(void)
@@ -246,7 +247,7 @@ NTSTATUS printer_list_mark_reload(void)
struct db_context *db;
TDB_DATA data;
uint32_t time_h, time_l;
- time_t now = time(NULL);
+ time_t now = time_mono(NULL);
NTSTATUS status;
int len;