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

Björn Jacke bjacke at samba.org
Sun Sep 19 17:41:33 MDT 2010


The branch, v3-6-test has been updated
       via  6fd8f65 s3: remove TvalDiff macro, we can use the shared usec_time_diff function (cherry picked from commit 6bc68fabb81d019e017d7f51fdd0b275b3f78609)
       via  9701d33 s3/s4: merge msleep and smb_msleep
      from  e870231 s3: Add a missing prototype

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


- Log -----------------------------------------------------------------
commit 6fd8f65d48db213956c7b70fbf5be86fe09807f2
Author: Björn Jacke <bj at sernet.de>
Date:   Thu Sep 16 21:36:00 2010 +0200

    s3: remove TvalDiff macro, we can use the shared usec_time_diff function
    (cherry picked from commit 6bc68fabb81d019e017d7f51fdd0b275b3f78609)

commit 9701d33ba38cf69dde801845cc8782dbfe334518
Author: Björn Jacke <bj at sernet.de>
Date:   Thu Sep 16 21:36:37 2010 +0200

    s3/s4: merge msleep and smb_msleep
    
    the merged variant is renamed to smb_msleep as some platforms already have a
    msleep function.
    (cherry picked from commits 2b254c814b139f93997f61525d77b934596c53a3
    1a22b1b44df62931a35254d06d2fc638c996c5f7
    66ad6c75e9efbd9837c70a716b556520c0279597)

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

Summary of changes:
 lib/util/util.c                       |   49 +++++++++++--
 lib/util/util.h                       |    2 +-
 source3/include/proto.h               |    1 -
 source3/include/smb_macros.h          |    9 --
 source3/lib/util.c                    |   49 ------------
 source4/torture/basic/base.c          |    4 +-
 source4/torture/basic/delaywrite.c    |  132 ++++++++++++++++----------------
 source4/torture/basic/delete.c        |    2 +-
 source4/torture/basic/disconnect.c    |    2 +-
 source4/torture/gentest.c             |    2 +-
 source4/torture/nbench/nbio.c         |    4 +-
 source4/torture/nbt/winsreplication.c |    4 +-
 source4/torture/raw/notify.c          |    8 +-
 source4/torture/rpc/handles.c         |    6 +-
 source4/torture/rpc/lsa.c             |    2 +-
 source4/torture/rpc/netlogon.c        |   10 +-
 source4/torture/smb2/lease.c          |    2 +-
 source4/torture/smb2/notify.c         |    8 +-
 source4/torture/util_smb.c            |    4 +-
 19 files changed, 138 insertions(+), 162 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/util.c b/lib/util/util.c
index d645f7e..ff1f607 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -165,15 +165,50 @@ _PUBLIC_ bool directory_create_or_exist(const char *dname, uid_t uid,
  Sleep for a specified number of milliseconds.
 **/
 
-_PUBLIC_ void msleep(unsigned int t)
+_PUBLIC_ void smb_msleep(unsigned int t)
 {
-	struct timeval tval;  
+#if defined(HAVE_NANOSLEEP)
+	struct timespec ts;
+	int ret;
+
+	ts.tv_sec = t/1000;
+	ts.tv_nsec = 1000000*(t%1000);
+
+	do {
+		errno = 0;
+		ret = nanosleep(&ts, &ts);
+	} while (ret < 0 && errno == EINTR && (ts.tv_sec > 0 || ts.tv_nsec > 0));
+#else
+	unsigned int tdiff=0;
+	struct timeval tval,t1,t2;
+	fd_set fds;
 
-	tval.tv_sec = t/1000;
-	tval.tv_usec = 1000*(t%1000);
-	/* this should be the real select - do NOT replace
-	   with sys_select() */
-	select(0,NULL,NULL,NULL,&tval);
+	GetTimeOfDay(&t1);
+	t2 = t1;
+
+	while (tdiff < t) {
+		tval.tv_sec = (t-tdiff)/1000;
+		tval.tv_usec = 1000*((t-tdiff)%1000);
+
+		/* Never wait for more than 1 sec. */
+		if (tval.tv_sec > 1) {
+			tval.tv_sec = 1;
+			tval.tv_usec = 0;
+		}
+
+		FD_ZERO(&fds);
+		errno = 0;
+		select(0,&fds,NULL,NULL,&tval);
+
+		GetTimeOfDay(&t2);
+		if (t2.tv_sec < t1.tv_sec) {
+			/* Someone adjusted time... */
+			t1 = t2;
+		}
+
+		tdiff = usec_time_diff(&t2,&t1)/1000;
+	}
+#endif
 }
 
 /**
diff --git a/lib/util/util.h b/lib/util/util.h
index 8383344..8619bd4 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -655,7 +655,7 @@ _PUBLIC_ int set_blocking(int fd, bool set);
 /**
  Sleep for a specified number of milliseconds.
 **/
-_PUBLIC_ void msleep(unsigned int t);
+_PUBLIC_ void smb_msleep(unsigned int t);
 
 /**
  Get my own name, return in talloc'ed storage.
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 1060e5c..fc9f776 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1204,7 +1204,6 @@ char *unix_clean_name(TALLOC_CTX *ctx, const char *s);
 char *clean_name(TALLOC_CTX *ctx, const char *s);
 ssize_t write_data_at_offset(int fd, const char *buffer, size_t N, SMB_OFF_T pos);
 int set_blocking(int fd, bool set);
-void smb_msleep(unsigned int t);
 NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
 			   struct event_context *ev_ctx,
 			   struct server_id id,
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index 757c8a2..9f4b345 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -144,15 +144,6 @@
 #define ENCRYPTION_REQUIRED(conn) ((conn) ? ((conn)->encrypt_level == Required) : false)
 #define IS_CONN_ENCRYPTED(conn) ((conn) ? (conn)->encrypted_tid : false)
 
-/*******************************************************************
-find the difference in milliseconds between two struct timeval
-values
-********************************************************************/
-
-#define TvalDiff(tvalold,tvalnew) \
-  (((tvalnew)->tv_sec - (tvalold)->tv_sec)*1000 +  \
-	 ((int)(tvalnew)->tv_usec - (int)(tvalold)->tv_usec)/1000)
-
 /****************************************************************************
 true if two IPv4 addresses are equal
 ****************************************************************************/
diff --git a/source3/lib/util.c b/source3/lib/util.c
index efa2ca2..7fd0fc3 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -823,55 +823,6 @@ ssize_t write_data_at_offset(int fd, const char *buffer, size_t N, SMB_OFF_T pos
 #endif
 }
 
-/*******************************************************************
- Sleep for a specified number of milliseconds.
-********************************************************************/
-
-void smb_msleep(unsigned int t)
-{
-#if defined(HAVE_NANOSLEEP)
-	struct timespec tval;
-	int ret;
-
-	tval.tv_sec = t/1000;
-	tval.tv_nsec = 1000000*(t%1000);
-
-	do {
-		errno = 0;
-		ret = nanosleep(&tval, &tval);
-	} while (ret < 0 && errno == EINTR && (tval.tv_sec > 0 || tval.tv_nsec > 0));
-#else
-	unsigned int tdiff=0;
-	struct timeval tval,t1,t2;  
-	fd_set fds;
-
-	GetTimeOfDay(&t1);
-	t2 = t1;
-
-	while (tdiff < t) {
-		tval.tv_sec = (t-tdiff)/1000;
-		tval.tv_usec = 1000*((t-tdiff)%1000);
-
-		/* Never wait for more than 1 sec. */
-		if (tval.tv_sec > 1) {
-			tval.tv_sec = 1; 
-			tval.tv_usec = 0;
-		}
-
-		FD_ZERO(&fds);
-		errno = 0;
-		sys_select_intr(0,&fds,NULL,NULL,&tval);
-
-		GetTimeOfDay(&t2);
-		if (t2.tv_sec < t1.tv_sec) {
-			/* Someone adjusted time... */
-			t1 = t2;
-		}
-
-		tdiff = TvalDiff(&t1,&t2);
-	}
-#endif
-}
 
 NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
 			   struct event_context *ev_ctx,
diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index c9148d1..7b96e1c 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -680,13 +680,13 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
 
 		torture_comment(tctx, "pid %u open %d\n", (unsigned)getpid(), i);
 
-		msleep(10 * msec);
+		smb_msleep(10 * msec);
 		i++;
 		if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) {
 			torture_comment(tctx,"Failed to close %s, error=%s\n", fname, smbcli_errstr(cli->tree));
 			return false;
 		}
-		msleep(2 * msec);
+		smb_msleep(2 * msec);
 	}
 
 	if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) {
diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c
index 0c43c29..f82b32f 100644
--- a/source4/torture/basic/delaywrite.c
+++ b/source4/torture/basic/delaywrite.c
@@ -111,7 +111,7 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
 			break;
 		}
 		fflush(stdout);
-		msleep(1 * msec);
+		smb_msleep(1 * msec);
 	}
 	
 	if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -162,7 +162,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
 
 	/* 3 second delay to ensure we get past any 2 second time
 	   granularity (older systems may have that) */
-	msleep(3 * msec);
+	smb_msleep(3 * msec);
 
 	finfo1.all_info.level = RAW_FILEINFO_ALL_INFO;
 	finfo1.all_info.in.file.fnum = fnum1;
@@ -180,7 +180,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
 
 	/* 3 second delay to ensure we get past any 2 second time
 	   granularity (older systems may have that) */
-	msleep(3 * msec);
+	smb_msleep(3 * msec);
 
 	/* Do a zero length SMBwrite call to truncate. */
 	written = smbcli_smbwrite(cli->tree, fnum1, "x", 1024, 0);
@@ -231,7 +231,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
 			break;
 		}
 		fflush(stdout);
-		msleep(1 * msec);
+		smb_msleep(1 * msec);
 	}
 
 	if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) {
@@ -241,7 +241,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
 	}
 
 	fflush(stdout);
-	msleep(2 * msec);
+	smb_msleep(2 * msec);
 
 	/* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */
 	written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1);
@@ -282,7 +282,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
 			break;
 		}
 		fflush(stdout);
-		msleep(1 * msec);
+		smb_msleep(1 * msec);
 	}
 
 	if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
@@ -292,7 +292,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
 	}
 
 	fflush(stdout);
-	msleep(2 * msec);
+	smb_msleep(2 * msec);
 
 	/* the close should trigger an write time update */
 	smbcli_close(cli->tree, fnum1);
@@ -353,7 +353,7 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
 
 	/* 3 second delay to ensure we get past any 2 second time
 	   granularity (older systems may have that) */
-	msleep(3 * msec);
+	smb_msleep(3 * msec);
 
 	finfo1.all_info.level = RAW_FILEINFO_ALL_INFO;
 	finfo1.all_info.in.file.fnum = fnum1;
@@ -418,7 +418,7 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
 			break;
 		}
 		fflush(stdout);
-		msleep(1 * msec);
+		smb_msleep(1 * msec);
 	}
 
 	if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) {
@@ -428,7 +428,7 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
 	}
 
 	fflush(stdout);
-	msleep(2 * msec);
+	smb_msleep(2 * msec);
 
 	/* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */
 	written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1);
@@ -467,7 +467,7 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
 			break;
 		}
 		fflush(stdout);
-		msleep(1 * msec);
+		smb_msleep(1 * msec);
 	}
 
 	if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
@@ -535,7 +535,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
 
 	/* 3 second delay to ensure we get past any 2 second time
 	   granularity (older systems may have that) */
-	msleep(3 * msec);
+	smb_msleep(3 * msec);
 
 	finfo1.all_info.level = RAW_FILEINFO_ALL_INFO;
 	finfo1.all_info.in.file.fnum = fnum1;
@@ -596,7 +596,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
 			break;
 		}
 		fflush(stdout);
-		msleep(1 * msec);
+		smb_msleep(1 * msec);
 	}
 
 	if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) {
@@ -606,7 +606,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
 	}
 
 	fflush(stdout);
-	msleep(2 * msec);
+	smb_msleep(2 * msec);
 
 	/* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */
 	written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1);
@@ -644,7 +644,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb
 			break;
 		}
 		fflush(stdout);
-		msleep(1 * msec);
+		smb_msleep(1 * msec);
 	}
 
 	if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
@@ -710,7 +710,7 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
 
 	/* 3 second delay to ensure we get past any 2 second time
 	   granularity (older systems may have that) */
-	msleep(3 * msec);
+	smb_msleep(3 * msec);
 
 	finfo1.all_info.level = RAW_FILEINFO_ALL_INFO;
 	finfo1.all_info.in.file.fnum = fnum1;
@@ -776,7 +776,7 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
 			break;
 		}
 		fflush(stdout);
-		msleep(1 * msec);
+		smb_msleep(1 * msec);
 	}
 
 	if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) {
@@ -786,7 +786,7 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
 	}
 
 	fflush(stdout);
-	msleep(2 * msec);
+	smb_msleep(2 * msec);
 
 	/* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */
 	written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1);
@@ -822,7 +822,7 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb
 			break;
 		}
 		fflush(stdout);
-		msleep(1 * msec);
+		smb_msleep(1 * msec);
 	}
 
 	if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
@@ -900,7 +900,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
 
 	/* 3 second delay to ensure we get past any 2 second time
 	   granularity (older systems may have that) */
-	msleep(3 * msec);
+	smb_msleep(3 * msec);
 
 	{
 		/* Try using setfileinfo instead of write to update write time. */
@@ -1007,7 +1007,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
 			break;
 		}
 		fflush(stdout);
-		msleep(1 * msec);
+		smb_msleep(1 * msec);
 	}
 	
 	if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -1015,7 +1015,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
 	}
 
 	fflush(stdout);
-	msleep(2 * msec);
+	smb_msleep(2 * msec);
 
 	fnum2 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
 	if (fnum2 == -1) {
@@ -1099,7 +1099,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
 			break;
 		}
 		fflush(stdout);
-		msleep(1 * msec);
+		smb_msleep(1 * msec);
 	}
 	
 	if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -1131,7 +1131,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
 	torture_comment(tctx, "Second open initial write time %s\n", 
 	       nt_time_string(tctx, finfo1.basic_info.out.write_time));
 
-	msleep(10 * msec);
+	smb_msleep(10 * msec);
 	torture_comment(tctx, "Doing a 10 byte write to extend the file to see if this changes the last write time.\n");
 
 	written =  smbcli_write(cli->tree, fnum1, 0, "0123456789", 31, 10);
@@ -1187,7 +1187,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
 			break;
 		}
 		fflush(stdout);
-		msleep(1*msec);
+		smb_msleep(1*msec);
 	}
 	
 	if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -1258,7 +1258,7 @@ static bool test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
 		goto done;
 	}
 
-	msleep(1 * msec);
+	smb_msleep(1 * msec);
 
 	written =  smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
 
@@ -1573,7 +1573,7 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
 					diff, sec);
 			break;
 		}
-		msleep(0.5 * msec);
+		smb_msleep(0.5 * msec);
 	}
 
 	GET_INFO_BOTH(finfo1,pinfo1);
@@ -1602,7 +1602,7 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
 			ret = false;
 			break;
 		}
-		msleep(1 * msec);
+		smb_msleep(1 * msec);
 	}
 
 	GET_INFO_BOTH(finfo2,pinfo2);
@@ -1612,7 +1612,7 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
 	}
 
 	/* sleep */
-	msleep(5 * msec);
+	smb_msleep(5 * msec);
 
 	GET_INFO_BOTH(finfo3,pinfo3);
 	COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2);
@@ -1699,7 +1699,7 @@ static bool test_delayed_write_update3a(struct torture_context *tctx,
 	 * sleep some time, to demonstrate the handling of write times
 	 * doesn't depend on the time since the open
 	 */
-	msleep(5 * msec);
+	smb_msleep(5 * msec);
 
 	/* get the initial times */
 	GET_INFO_BOTH(finfo1,pinfo1);
@@ -1739,20 +1739,20 @@ static bool test_delayed_write_update3a(struct torture_context *tctx,
 					diff, sec);
 			break;
 		}
-		msleep(0.5 * msec);
+		smb_msleep(0.5 * msec);
 	}
 
 	GET_INFO_BOTH(finfo1,pinfo1);
 	COMPARE_WRITE_TIME_GREATER(pinfo1, pinfo0);
 
-	msleep(3 * msec);
+	smb_msleep(3 * msec);
 
 	/*
 	 * demonstrate that a truncate write always
 	 * updates the write time immediately
 	 */
 	for (i=0; i < 3; i++) {
-		msleep(2 * msec);
+		smb_msleep(2 * msec);
 		/* do a write */
 		torture_comment(tctx, "Do a truncate SMBwrite [%d] on the file handle\n", i);
 		written = smbcli_smbwrite(cli->tree, fnum1, "x", 10240, 0);
@@ -1767,7 +1767,7 @@ static bool test_delayed_write_update3a(struct torture_context *tctx,
 		finfo1 = finfo2;
 	}
 
-	msleep(3 * msec);
+	smb_msleep(3 * msec);
 
 	/* sure any further write doesn't update the write time */
 	start = timeval_current();
@@ -1792,7 +1792,7 @@ static bool test_delayed_write_update3a(struct torture_context *tctx,
 			ret = false;
 			break;
 		}
-		msleep(1 * msec);
+		smb_msleep(1 * msec);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list