Skip to contentSkip to conversation

tst_module: introduce a timeout to unload modules

PATCH In review Stanislav Kholmanskikh 2 participants 2 messages Feb 2, 2015 – Feb 3, 2015 1 message not in the archive Library code

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v2 2/2 tst_module: introduce a timeout to unload modules

It may happen, that the first execution of 'rmmod module_name' may fail for some reason (like the module is in use for some short time).

Changed tst_module_unload() to execute 'rmmod module_name' multiple times with the total number limited by a timeout.

---
Changes since V1:
* rely on the exit code of rmmod
* removed tst_module_unload
* added missing usleep()

 lib/tst_module.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
lib/tst_module.c +16 -1
index 8104582..0be6ced 100644
@@ -100,6 +100,21 @@ void tst_module_load(void (cleanup_fn)(void),
 
 void tst_module_unload(void (cleanup_fn)(void), const char *mod_name)
 {
+	int i, rc;
+
 	const char *const argv[] = { "rmmod", mod_name, NULL };
-	tst_run_cmd(cleanup_fn, argv, NULL, NULL, 0);
+
+	rc = 1;
+	for (i = 0; i < 50; i++) {
+		rc = tst_run_cmd(NULL, argv, "/dev/null", "/dev/null", 1);
+		if (!rc)
+			break;
+
+		usleep(20000);
+	}
+
+	if (rc) {
+		tst_brkm(TBROK, cleanup_fn,
+			 "could not unload %s module", mod_name);
+	}
 }
Signature · 13 lines
1.7.1


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#2 lore raw

Hi!

Quoted 7 lines

It may happen, that the first execution of 'rmmod module_name' may fail for some reason (like the module is in use for some short time).

Changed tst_module_unload() to execute 'rmmod module_name' multiple times with the total number limited by a timeout.

Acked.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list