[SCM] Samba Shared Repository - branch v3-6-test updated

Björn Jacke bjacke at samba.org
Tue Sep 7 13:26:52 MDT 2010


The branch, v3-6-test has been updated
       via  9234d10 s3/libads: use monotonic clock for ldap connection timeouts
       via  392702b s3: use monotonic clock for aio timeout
       via  4c31ca5 s3/nmbd: tidy up debug message: ttl isn't a hex value
       via  4c7dd75 s3/libads: use monotonic clock for DNS timeouts
       via  95afa4f lib/util: add time_mono() for monotonic time a la time()
      from  7f2b1cd s3-proto: remove obsolete prototypes.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit 9234d105d4c2cdaa38a3555f34b2a81a413ab171
Author: Björn Jacke <bj at sernet.de>
Date:   Tue Sep 7 02:15:09 2010 +0200

    s3/libads: use monotonic clock for ldap connection timeouts

commit 392702b82d76b0a3871eb33e4a01b5480f895b6d
Author: Björn Jacke <bj at sernet.de>
Date:   Tue Sep 7 03:29:19 2010 +0200

    s3: use monotonic clock for aio timeout

commit 4c31ca5b5c72e533525ca355be93047c7901720a
Author: Björn Jacke <bj at sernet.de>
Date:   Tue Sep 7 03:05:35 2010 +0200

    s3/nmbd: tidy up debug message: ttl isn't a hex value

commit 4c7dd759985647c6990040e1bfb6fa9f55ef0723
Author: Björn Jacke <bj at sernet.de>
Date:   Tue Sep 7 01:54:01 2010 +0200

    s3/libads: use monotonic clock for DNS timeouts

commit 95afa4f0d11c7a6fe6b4b6cb271665cc26dfafc9
Author: Björn Jacke <bj at sernet.de>
Date:   Mon Sep 6 20:27:24 2010 +0200

    lib/util: add time_mono() for monotonic time a la time()

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

Summary of changes:
 lib/util/time.c                |   21 +++++++++++++++++++++
 lib/util/time.h                |    5 +++++
 source3/include/ads.h          |    2 +-
 source3/libads/dns.c           |   10 +++++-----
 source3/libads/ldap.c          |    2 +-
 source3/libads/ldap_utils.c    |    2 +-
 source3/nmbd/nmbd_winsserver.c |    2 +-
 source3/smbd/aio.c             |    4 ++--
 8 files changed, 37 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/time.c b/lib/util/time.c
index 5ecf93c..ed3b4f8 100644
--- a/lib/util/time.c
+++ b/lib/util/time.c
@@ -65,6 +65,27 @@ _PUBLIC_ void clock_gettime_mono(struct timespec *tp)
 	}
 }
 
+/**
+a wrapper to preferably get the monotonic time in seconds
+as this is only second resolution we can use the cached
+(and much faster) COARS clock variant
+**/
+_PUBLIC_ time_t time_mono(time_t *t)
+{
+	struct timespec tp;
+	int rc = -1;
+#ifdef CLOCK_MONOTONIC_COARSE
+	rc = clock_gettime(CLOCK_MONOTONIC_COARSE,&tp);
+#endif
+	if (rc != 0) {
+		clock_gettime_mono(&tp);
+	}
+	if (t != NULL) {
+		*t = tp.tv_sec;
+	}
+	return tp.tv_sec;
+}
+
 
 #define TIME_FIXUP_CONSTANT 11644473600LL
 
diff --git a/lib/util/time.h b/lib/util/time.h
index 720a262..345382b 100644
--- a/lib/util/time.h
+++ b/lib/util/time.h
@@ -56,6 +56,11 @@ a wrapper to preferably get the monotonic time
 _PUBLIC_ void clock_gettime_mono(struct timespec *tp);
 
 /**
+a wrapper to preferably get the monotonic time in s
+**/
+_PUBLIC_ time_t time_mono(time_t *t);
+
+/**
 interpret an 8 byte "filetime" structure to a time_t
 It's originally in "100ns units since jan 1st 1601"
 **/
diff --git a/source3/include/ads.h b/source3/include/ads.h
index b45d53d..6ef5455 100644
--- a/source3/include/ads.h
+++ b/source3/include/ads.h
@@ -65,7 +65,7 @@ typedef struct ads_struct {
 	struct {
 		LDAP *ld;
 		struct sockaddr_storage ss; /* the ip of the active connection, if any */
-		time_t last_attempt; /* last attempt to reconnect */
+		time_t last_attempt; /* last attempt to reconnect, monotonic clock */
 		int port;
 
 		enum ads_saslwrap_type wrap_type;
diff --git a/source3/libads/dns.c b/source3/libads/dns.c
index 8d23ce1..e7d8a40 100644
--- a/source3/libads/dns.c
+++ b/source3/libads/dns.c
@@ -297,7 +297,7 @@ static NTSTATUS dns_send_req( TALLOC_CTX *ctx, const char *name, int q_type,
 	int resp_len = NS_PACKETSZ;
 	static time_t last_dns_check = 0;
 	static NTSTATUS last_dns_status = NT_STATUS_OK;
-	time_t now = time(NULL);
+	time_t now = time_mono(NULL);
 
 	/* Try to prevent bursts of DNS lookups if the server is down */
 
@@ -332,7 +332,7 @@ static NTSTATUS dns_send_req( TALLOC_CTX *ctx, const char *name, int q_type,
 				DEBUG(0,("ads_dns_lookup_srv: "
 					"talloc() failed!\n"));
 				last_dns_status = NT_STATUS_NO_MEMORY;
-				last_dns_check = time(NULL);
+				last_dns_check = time_mono(NULL);
 				return last_dns_status;
 			}
 		}
@@ -351,7 +351,7 @@ static NTSTATUS dns_send_req( TALLOC_CTX *ctx, const char *name, int q_type,
 			if (errno == ECONNREFUSED) {
 				last_dns_status = NT_STATUS_CONNECTION_REFUSED;
 			}
-			last_dns_check = time(NULL);
+			last_dns_check = time_mono(NULL);
 			return last_dns_status;
 		}
 
@@ -365,7 +365,7 @@ static NTSTATUS dns_send_req( TALLOC_CTX *ctx, const char *name, int q_type,
 					name));
 				TALLOC_FREE( buffer );
 				last_dns_status = NT_STATUS_BUFFER_TOO_SMALL;
-				last_dns_check = time(NULL);
+				last_dns_check = time_mono(NULL);
 				return last_dns_status;
 			}
 
@@ -378,7 +378,7 @@ static NTSTATUS dns_send_req( TALLOC_CTX *ctx, const char *name, int q_type,
 	*buf = buffer;
 	*resp_length = resp_len;
 
-	last_dns_check = time(NULL);
+	last_dns_check = time_mono(NULL);
 	last_dns_status = NT_STATUS_OK;
 	return last_dns_status;
 }
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 77ab51e..970f20a 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -596,7 +596,7 @@ ADS_STATUS ads_connect(ADS_STRUCT *ads)
 	char addr[INET6_ADDRSTRLEN];
 
 	ZERO_STRUCT(ads->ldap);
-	ads->ldap.last_attempt	= time(NULL);
+	ads->ldap.last_attempt	= time_mono(NULL);
 	ads->ldap.wrap_type	= ADS_SASLWRAP_TYPE_PLAIN;
 
 	/* try with a user specified server */
diff --git a/source3/libads/ldap_utils.c b/source3/libads/ldap_utils.c
index c0c1adb..0c07961 100644
--- a/source3/libads/ldap_utils.c
+++ b/source3/libads/ldap_utils.c
@@ -40,7 +40,7 @@ static ADS_STATUS ads_do_search_retry_internal(ADS_STRUCT *ads, const char *bind
 	*res = NULL;
 
 	if (!ads->ldap.ld &&
-	    time(NULL) - ads->ldap.last_attempt < ADS_RECONNECT_TIME) {
+	    time_mono(NULL) - ads->ldap.last_attempt < ADS_RECONNECT_TIME) {
 		return ADS_ERROR(LDAP_SERVER_DOWN);
 	}
 
diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c
index 4232afc..5f3a9c3 100644
--- a/source3/nmbd/nmbd_winsserver.c
+++ b/source3/nmbd/nmbd_winsserver.c
@@ -425,7 +425,7 @@ static void update_wins_flag(struct name_record *namerec, int flags)
 	/* and add the given bits */
 	namerec->data.wins_flags|=flags;
 
-	DEBUG(8,("update_wins_flag: nbflags: 0x%x, ttl: 0x%d, flags: 0x%x, winsflags: 0x%x\n", 
+	DEBUG(8,("update_wins_flag: nbflags: 0x%x, ttl: %d, flags: 0x%x, winsflags: 0x%x\n", 
 		 namerec->data.nb_flags, (int)namerec->data.death_time, flags, namerec->data.wins_flags));
 }
 
diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c
index 29b2fc4..4fdb00e 100644
--- a/source3/smbd/aio.c
+++ b/source3/smbd/aio.c
@@ -899,7 +899,7 @@ int wait_for_aio_completion(files_struct *fsp)
 	struct aio_extra *aio_ex;
 	const SMB_STRUCT_AIOCB **aiocb_list;
 	int aio_completion_count = 0;
-	time_t start_time = time(NULL);
+	time_t start_time = time_mono(NULL);
 	int seconds_left;
 
 	for (seconds_left = SMB_TIME_FOR_AIO_COMPLETE_WAIT;
@@ -974,7 +974,7 @@ int wait_for_aio_completion(files_struct *fsp)
 
 		SAFE_FREE(aiocb_list);
 		seconds_left = SMB_TIME_FOR_AIO_COMPLETE_WAIT
-			- (time(NULL) - start_time);
+			- (time_mono(NULL) - start_time);
 	}
 
 	/* We timed out - we don't know why. Return ret if already an error,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list