[Ocfs2-tools-commits] mfasheh commits r604 - trunk/libo2dlm

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Jan 26 17:37:45 CST 2005


Author: mfasheh
Date: 2005-01-26 17:37:43 -0600 (Wed, 26 Jan 2005)
New Revision: 604

Modified:
   trunk/libo2dlm/o2dlm_test.c
Log:
* rework things to print out after the command is executed. This helps
  us determine when we're sleeping on a command...



Modified: trunk/libo2dlm/o2dlm_test.c
===================================================================
--- trunk/libo2dlm/o2dlm_test.c	2005-01-26 23:35:23 UTC (rev 603)
+++ trunk/libo2dlm/o2dlm_test.c	2005-01-26 23:37:43 UTC (rev 604)
@@ -148,13 +148,13 @@
 	return -1;
 }
 
-static void print_command(struct command_s *c)
+static void print_command(struct command_s *c, const char *str)
 {
 	printf("Command: %s ", command_strings[c->c_type]);
 	switch (c->c_type) {
 	case REGISTER:
 	case UNREGISTER:
-		printf("\"%s\"\n", c->c_domain);
+		printf("\"%s\" %s\n", c->c_domain, str);
 		break;
 	case LOCK:
 	case TRYLOCK:
@@ -164,10 +164,10 @@
 			printf("O2DLM_LEVEL_EXMODE ");
 		/* fall through */
 	case UNLOCK:
-		printf("\"%s\"\n", c->c_id);
+		printf("\"%s\" %s\n", c->c_id, str);
 		break;
 	case HELP:
-		printf("\n");
+		printf("%s\n", str);
 		break;
 	default:
 		printf("wha?!?!?\n");
@@ -234,9 +234,9 @@
 	return 0;
 }
 
-static void exec_command(struct command_s *c)
+static errcode_t exec_command(struct command_s *c)
 {
-	errcode_t ret;
+	errcode_t ret = 0;
 
 	switch (c->c_type) {
 	case REGISTER:
@@ -256,18 +256,16 @@
 		ret = o2dlm_lock(dlm_ctxt, c->c_id, O2DLM_TRYLOCK, c->c_level);
 		break;
 	case HELP:
+	default:
 		print_commands();
-		return;
-	default:
-		return;
 	}
 
-	if (ret)
-		com_err(prog, ret, "while executing command");
+	return ret;
 }
 
 int main(int argc, char **argv)
 {
+	errcode_t error;
 	struct command_s c;
 
 	prog = argv[0];
@@ -283,8 +281,13 @@
 	printf("Using fs at %s\n", dlmfs_path);
 
 	while (!get_command(&c)) {
-		print_command(&c);
-		exec_command(&c);
+		error = exec_command(&c);
+
+		if (error) {
+			print_command(&c, "failed!");
+			com_err(prog, error, "returned\n");
+		} else
+			print_command(&c, "succeeded!\n");
 	}
 	return 0;
 }



More information about the Ocfs2-tools-commits mailing list