From: Martin Mares Date: Fri, 25 Feb 2011 23:23:25 +0000 (+0100) Subject: Main: main_delete() must make the soon-to-be-deleted context current X-Git-Tag: v5.0~129^2~14 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=d8eeaae62e2625f2fc171f9c97ac66e0430bc7bc;p=libucw.git Main: main_delete() must make the soon-to-be-deleted context current Otherwise, it might call signal_del() and file_del() on another (or even undefined) context. --- diff --git a/ucw/mainloop.c b/ucw/mainloop.c index bf72f943..6575210b 100644 --- a/ucw/mainloop.c +++ b/ucw/mainloop.c @@ -83,6 +83,8 @@ main_new(void) void main_delete(struct main_context *m) { + struct main_context *prev = main_switch_context(m); + if (m->sigchld_handler) signal_del(m->sigchld_handler); if (m->sig_pipe_file) @@ -109,6 +111,8 @@ main_delete(struct main_context *m) #endif xfree(m); // FIXME: Some mechanism for cleaning up after fork() + + main_switch_context((prev == m) ? NULL : prev); } struct main_context * @@ -150,8 +154,7 @@ main_init(void) void main_cleanup(void) { - struct main_context *m = main_switch_context(NULL); - main_delete(m); + main_delete(main_current()); } void