[SCM] Samba Shared Repository - branch master updated

Björn Jacke bjacke at samba.org
Wed Sep 15 14:42:38 MDT 2010


The branch, master has been updated
       via  aa7df7b s3/printing: make clock jump save and use monotonic time for cache timeout
      from  adf8ca6 subunit: Re-add outputmsg.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit aa7df7b7379cc437515774d0ea91fb106aba5dc8
Author: Björn Jacke <bj at sernet.de>
Date:   Wed Sep 15 18:23:50 2010 +0200

    s3/printing: make clock jump save and use monotonic time for cache timeout

-----------------------------------------------------------------------

Summary of changes:
 source3/printing/pcap.c         |    2 +-
 source3/printing/printer_list.c |   27 ++++++++++++++-------------
 2 files changed, 15 insertions(+), 14 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c
index 3bc8e9e..1b8f46d 100644
--- a/source3/printing/pcap.c
+++ b/source3/printing/pcap.c
@@ -82,7 +82,7 @@ void pcap_cache_destroy_specific(struct pcap_cache **pp_cache)
 bool pcap_cache_add(const char *name, const char *comment)
 {
 	NTSTATUS status;
-	time_t t = time(NULL);
+	time_t t = time_mono(NULL);
 
 	status = printer_list_set_printer(talloc_tos(), name, comment, t);
 	return NT_STATUS_IS_OK(status);
diff --git a/source3/printing/printer_list.c b/source3/printing/printer_list.c
index 6392755..d02ab88 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;
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list