Browse code

core: at shutdown, first call the destroy module functions then free module exports structure

- some modules may need access to other modules at shut down
- reported by Juha Heinanen
(cherry picked from commit 2396dde7230e04f853e6936cfff9059661c55635)
(cherry picked from commit d3408c64b6c07806a51e1e72589f8e124c8c651c)

Daniel-Constantin Mierla authored on 16/11/2011 06:50:42
Showing 1 changed files
... ...
@@ -725,12 +725,19 @@ void destroy_modules()
725 725
 {
726 726
 	struct sr_module* t, *foo;
727 727
 
728
+	/* call first destroy function from each module */
728 729
 	t=modules;
729 730
 	while(t) {
730 731
 		foo=t->next;
731 732
 		if (t->exports.destroy_f){
732 733
 			t->exports.destroy_f();
733 734
 		}
735
+		t=foo;
736
+	}
737
+	/* free module exports structures */
738
+	t=modules;
739
+	while(t) {
740
+		foo=t->next;
734 741
 		pkg_free(t);
735 742
 		t=foo;
736 743
 	}