Răsfoiți Sursa

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)
Daniel-Constantin Mierla 14 ani în urmă
părinte
comite
d3408c64b6
1 a modificat fișierele cu 7 adăugiri și 0 ștergeri
  1. 7 0
      sr_module.c

+ 7 - 0
sr_module.c

@@ -775,12 +775,19 @@ void destroy_modules()
 {
 	struct sr_module* t, *foo;
 
+	/* call first destroy function from each module */
 	t=modules;
 	while(t) {
 		foo=t->next;
 		if (t->exports.destroy_f){
 			t->exports.destroy_f();
 		}
+		t=foo;
+	}
+	/* free module exports structures */
+	t=modules;
+	while(t) {
+		foo=t->next;
 		pkg_free(t);
 		t=foo;
 	}