svn commit: samba r16188 - in branches/tmp/vl-messaging/source: torture utils

ab at samba.org ab at samba.org
Tue Jun 13 11:53:37 GMT 2006


Author: ab
Date: 2006-06-13 11:53:37 +0000 (Tue, 13 Jun 2006)
New Revision: 16188

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16188

Log:
Fix smbcontrol and msgtest to work with messaging API changes. 
Based on Aleksey Fedoseev <fedoseev at ru.ibm.com> work
Modified:
   branches/tmp/vl-messaging/source/torture/msgtest.c
   branches/tmp/vl-messaging/source/utils/smbcontrol.c


Changeset:
Modified: branches/tmp/vl-messaging/source/torture/msgtest.c
===================================================================
--- branches/tmp/vl-messaging/source/torture/msgtest.c	2006-06-13 11:37:51 UTC (rev 16187)
+++ branches/tmp/vl-messaging/source/torture/msgtest.c	2006-06-13 11:53:37 UTC (rev 16188)
@@ -25,6 +25,7 @@
 
 static int pong_count;
 
+#define  DISPATCH_TIMEOUT	(10 * 1000) 		/* 10 ms */
 
 /* samba4 timeval functions */
 
@@ -56,6 +57,7 @@
 	pid_t pid;
 	int i, n;
 	char buf[12];
+	struct timeval dispatch_timeout = timeval_set(0, DISPATCH_TIMEOUT);
 
 	load_case_tables();
 
@@ -80,8 +82,7 @@
 	}
 
 	while (pong_count < i) {
-		message_dispatch();
-		smb_msleep(1);
+		message_select_and_dispatch(&dispatch_timeout);
 	}
 
 	/* Now test that the duplicate filtering code works. */
@@ -97,8 +98,7 @@
 	}
 
 	for (i=0;i<n;i++) {
-		message_dispatch();
-		smb_msleep(1);
+		message_select_and_dispatch(&dispatch_timeout);
 	}
 
 	if (pong_count != 2) {
@@ -122,14 +122,14 @@
 								NULL, 0, False)) ping_count++;
 
 			while (ping_count > pong_count + 20) {
-				message_dispatch();
+				message_select_and_dispatch(&dispatch_timeout);
 			}
 		}
 		
 		printf("waiting for %d remaining replies (done %d)\n", 
 			   ping_count - pong_count, pong_count);
 		while (timeval_elapsed(&tv) < 30 && pong_count < ping_count) {
-			message_dispatch();
+			message_select_and_dispatch(&dispatch_timeout);
 		}
 		
 		if (ping_count != pong_count) {
@@ -141,6 +141,8 @@
 			   (ping_count+pong_count)/timeval_elapsed(&tv));
 	}
 
+	message_end();
+
 	return (0);
 }
 

Modified: branches/tmp/vl-messaging/source/utils/smbcontrol.c
===================================================================
--- branches/tmp/vl-messaging/source/utils/smbcontrol.c	2006-06-13 11:37:51 UTC (rev 16187)
+++ branches/tmp/vl-messaging/source/utils/smbcontrol.c	2006-06-13 11:53:37 UTC (rev 16188)
@@ -89,10 +89,11 @@
            busy-wait here as there is no nicer way to do it. */
 
 	do {
-		message_dispatch();
-		if (num_replies > 0 && !multiple_replies)
-			break;
-		sleep(1);
+		struct timeval tmo;
+		tmo = timeval_set(timeout - (time(NULL) - start_time), 0);
+		message_select_and_dispatch(&tmo);
+                if (num_replies > 0 && !multiple_replies)
+                        break;
 	} while (timeout - (time(NULL) - start_time) > 0);
 }
 
@@ -1137,7 +1138,7 @@
 int main(int argc, const char **argv)
 {
 	poptContext pc;
-	int opt;
+	int opt, retval;
 
 	static struct poptOption wbinfo_options[] = {
 		{ "timeout", 't', POPT_ARG_INT, &timeout, 't', 
@@ -1201,9 +1202,14 @@
 
 	lp_load(dyn_CONFIGFILE,False,False,False,True);
 
+	retval = do_command(argc, argv);
+
+	/* Deinitialize messaging */
+	message_end();
+
 	/* Need to invert sense of return code -- samba
          * routines mostly return True==1 for success, but
          * shell needs 0. */ 
 	
-	return !do_command(argc, argv);
+	return !retval;
 }



More information about the samba-cvs mailing list